MCPcopy Create free account
hub / github.com/comaps/comaps / VulkanProgramPool

Method VulkanProgramPool

libs/shaders/vulkan_program_pool.cpp:88–253  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

86};
87
88struct ReflectionFile
89{
90 std::vector<ReflectionData> m_reflectionData;
91 DECLARE_VISITOR(visitor(m_reflectionData))
92};
93
94std::map<uint8_t, ReflectionData> ReadReflectionFile(std::string const & filename)
95{
96 std::map<uint8_t, ReflectionData> result;
97 std::string jsonStr;
98 try
99 {
100 ReaderPtr<Reader>(GetPlatform().GetReader(filename)).ReadAsString(jsonStr);
101 }
102 catch (RootException const & e)
103 {
104 LOG(LERROR, ("Error reading file ", filename, ":", e.what()));
105 return {};
106 }
107
108 ReflectionFile reflectionFile;
109 try
110 {
111 coding::DeserializerJson des(jsonStr);
112 des(reflectionFile);
113 }
114 catch (base::Json::Exception const & e)
115 {
116 LOG(LERROR, ("Error deserialization reflection file :", e.what()));
117 return {};
118 }
119
120 for (auto & d : reflectionFile.m_reflectionData)
121 {
122 auto const index = d.m_programIndex;
123 std::ranges::sort(d.m_info.m_textures, [](auto const & a, auto const & b) { return a.m_index < b.m_index; });
124 result.insert(std::make_pair(index, std::move(d)));
125 }
126
127 return result;
128}
129
130std::vector<VkDescriptorSetLayoutBinding> GetLayoutBindings(ReflectionInfo const & reflectionInfo,
131 uint32_t maxTextureBindings)
132{
133 std::vector<VkDescriptorSetLayoutBinding> result;
134
135 VkDescriptorSetLayoutBinding uniformsBinding = {};
136 uniformsBinding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC;
137 uniformsBinding.descriptorCount = 1;
138
139 if (reflectionInfo.m_vsUniformsIndex != kInvalidBindingIndex &&
140 reflectionInfo.m_fsUniformsIndex != kInvalidBindingIndex)
141 {
142 CHECK_EQUAL(reflectionInfo.m_vsUniformsIndex, reflectionInfo.m_fsUniformsIndex, ());
143 uniformsBinding.binding = static_cast<uint32_t>(reflectionInfo.m_vsUniformsIndex);
144 uniformsBinding.stageFlags = VK_SHADER_STAGE_ALL_GRAPHICS;
145 result.push_back(std::move(uniformsBinding));

Callers

nothing calls this directly

Calls 6

JoinPathFunction · 0.85
ReadShadersPackFileFunction · 0.85
InitFunction · 0.50
GetDeviceMethod · 0.45
sizeMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected