]> git.tdb.fi Git - libs/gl.git/blobdiff - source/backends/vulkan/program_backend.cpp
Fix handling of descriptor set bindings when shader stages change
[libs/gl.git] / source / backends / vulkan / program_backend.cpp
index 68ade90c7f2ef8e15f1f14298877c6d47d59b3f4..728bacbce7c6f75217c258691287e9ee164a2597 100644 (file)
@@ -22,7 +22,8 @@ VulkanProgram::VulkanProgram(VulkanProgram &&other):
        stage_flags(other.stage_flags),
        creation_info(move(other.creation_info)),
        desc_set_layout_handles(move(other.desc_set_layout_handles)),
-       layout_handle(other.layout_handle)
+       layout_handle(other.layout_handle),
+       debug_name(move(other.debug_name))
 {
        other.desc_set_layout_handles.clear();
        other.layout_handle = 0;
@@ -99,6 +100,12 @@ void VulkanProgram::add_spirv_stages(const SpirVModule &mod, const map<string, i
                stage_infos[i].pSpecializationInfo = spec_info;
                ++i;
        }
+
+#if DEBUG
+       if(!debug_name.empty())
+               if(SpirVModule *spirv = static_cast<Program *>(this)->specialized_spirv)
+                       spirv->set_debug_name(debug_name);
+#endif
 }
 
 void VulkanProgram::finalize_uniforms()
@@ -118,10 +125,10 @@ void VulkanProgram::finalize_uniforms()
                        {
                                bindings.emplace_back();
                                VkDescriptorSetLayoutBinding &binding = bindings.back();
-                               binding.binding = b.bind_point;
-                               binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC;
+                               binding.binding = b.bind_point&0xFFFFF;
+                               binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER;
                                binding.descriptorCount = 1;
-                               binding.stageFlags = VK_SHADER_STAGE_ALL;
+                               binding.stageFlags = stage_flags;
                                binding.pImmutableSamplers = 0;
                        }
 
@@ -130,10 +137,10 @@ void VulkanProgram::finalize_uniforms()
                        {
                                bindings.emplace_back();
                                VkDescriptorSetLayoutBinding &binding = bindings.back();
-                               binding.binding = u.binding;
+                               binding.binding = u.binding&0xFFFFF;
                                binding.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER;
                                binding.descriptorCount = 1;
-                               binding.stageFlags = VK_SHADER_STAGE_ALL;
+                               binding.stageFlags = stage_flags;
                                binding.pImmutableSamplers = 0;
                        }
 
@@ -160,5 +167,16 @@ void VulkanProgram::finalize_uniforms()
        vk.CreatePipelineLayout(layout_info, layout_handle);
 }
 
+void VulkanProgram::set_debug_name(const string &name)
+{
+#ifdef DEBUG
+       debug_name = name;
+       if(SpirVModule *spirv = static_cast<Program *>(this)->specialized_spirv)
+               spirv->set_debug_name(debug_name);
+#else
+       (void)name;
+#endif
+}
+
 } // namespace GL
 } // namespace Msp