]> git.tdb.fi Git - libs/gl.git/blobdiff - source/backends/vulkan/program_backend.cpp
Simplify Program by removing transient data
[libs/gl.git] / source / backends / vulkan / program_backend.cpp
index 61b5efaefd93f4b96fdef3892cf09fc9ff29468b..68ade90c7f2ef8e15f1f14298877c6d47d59b3f4 100644 (file)
@@ -19,6 +19,7 @@ VulkanProgram::VulkanProgram():
 VulkanProgram::VulkanProgram(VulkanProgram &&other):
        device(other.device),
        n_stages(other.n_stages),
+       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)
@@ -42,7 +43,7 @@ bool VulkanProgram::has_stages() const
        return n_stages;
 }
 
-void VulkanProgram::add_glsl_stages(const GlslModule &, const map<string, int> &, TransientData &)
+void VulkanProgram::add_glsl_stages(const GlslModule &, const map<string, int> &)
 {
        throw invalid_operation("VulkanProgram::add_glsl_stages");
 }
@@ -86,8 +87,11 @@ void VulkanProgram::add_spirv_stages(const SpirVModule &mod, const map<string, i
        i = 0;
        for(const SpirVModule::EntryPoint &e: entry_points)
        {
+               unsigned stage_bit = get_vulkan_stage(e.stage);
+               stage_flags |= stage_bit;
+
                stage_infos[i].sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO;
-               stage_infos[i].stage = static_cast<VkShaderStageFlagBits>(get_vulkan_stage(e.stage));
+               stage_infos[i].stage = static_cast<VkShaderStageFlagBits>(stage_bit);
                stage_infos[i].module = handle_cast<::VkShaderModule>(mod.handle);
                strcpy(name_ptr, e.name.c_str());
                stage_infos[i].pName = name_ptr;
@@ -115,7 +119,7 @@ void VulkanProgram::finalize_uniforms()
                                bindings.emplace_back();
                                VkDescriptorSetLayoutBinding &binding = bindings.back();
                                binding.binding = b.bind_point;
-                               binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER;
+                               binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC;
                                binding.descriptorCount = 1;
                                binding.stageFlags = VK_SHADER_STAGE_ALL;
                                binding.pImmutableSamplers = 0;
@@ -142,7 +146,7 @@ void VulkanProgram::finalize_uniforms()
        }
 
        VkPushConstantRange push_const_range = { };
-       push_const_range.stageFlags = VK_SHADER_STAGE_ALL;
+       push_const_range.stageFlags = stage_flags;
        push_const_range.offset = 0;
        push_const_range.size = (push_const_block ? push_const_block->data_size : 0);