24 void Push(
const std::string& descriptorName,
const T& descriptor,
25 const std::optional<OffsetSize>& offsetSize = std::nullopt)
32 auto it = m_Descriptors.find(descriptorName);
34 if (it != m_Descriptors.end())
36 if (it->second.m_Descriptor == std::to_address(descriptor) && it->second.m_OffsetSize == offsetSize)
41 m_Descriptors.erase(it);
44 if (!std::to_address(descriptor))
49 auto location = m_Shader->GetDescriptorLocation(descriptorName);
54 if (m_Shader->ReportedNotFound(descriptorName,
true))
56 Log::Error(
"Could not find descriptor '{}' in shader '{}'", descriptorName,
57 m_Shader->GetName().c_str());
63 auto descriptorType = m_Shader->GetDescriptorType(*location);
68 if (m_Shader->ReportedNotFound(descriptorName,
true))
70 Log::Error(
"Could not find descriptor '{}' at location {} in shader '{}'", descriptorName,
71 *location, m_Shader->GetName().c_str());
77 auto writeDescriptor =
78 std::to_address(descriptor)->GetWriteDescriptor(*location, *descriptorType, offsetSize);
79 m_Descriptors.emplace(descriptorName, DescriptorValue{ std::to_address(descriptor),
80 std::move(writeDescriptor), offsetSize, *location });
85 void Push(
const std::string& descriptorName,
const T& descriptor,
WriteDescriptorSet writeDescriptorSet)
92 if (
auto it = m_Descriptors.find(descriptorName); it != m_Descriptors.end())
94 m_Descriptors.erase(it);
97 auto location = m_Shader->GetDescriptorLocation(descriptorName);
99 m_Descriptors.emplace(
101 DescriptorValue{ std::to_address(descriptor), std::move(writeDescriptorSet), std::nullopt, *location });
105 void Push(
const std::string& descriptorName,
UniformHandler& uniformHandler,
106 const std::optional<OffsetSize>& offsetSize = std::nullopt);
107 void Push(
const std::string& descriptorName,
StorageHandler& storageHandler,
108 const std::optional<OffsetSize>& offsetSize = std::nullopt);
109 void Push(
const std::string& descriptorName,
PushHandler& pushHandler,
110 const std::optional<OffsetSize>& offsetSize = std::nullopt);
112 bool Update(
const Pipeline& pipeline);
118 return m_DescriptorSet.get();
122 class DescriptorValue
127 std::optional<OffsetSize> m_OffsetSize;
131 const Shader* m_Shader =
nullptr;
132 bool m_PushDescriptors =
false;
133 std::unique_ptr<DescriptorSet> m_DescriptorSet;
135 std::map<std::string, DescriptorValue> m_Descriptors;
136 std::vector<VkWriteDescriptorSet> m_WriteDescriptorSets;
137 bool m_Changed =
false;