MCPcopy Create free account
hub / github.com/defold/defold / UpdateDescriptorSets

Function UpdateDescriptorSets

engine/graphics/src/vulkan/graphics_vulkan.cpp:2775–2904  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2773 }
2774
2775 static void UpdateDescriptorSets(VulkanContext* context, VkDevice vk_device, VkDescriptorSet* vk_descriptor_sets, VulkanProgram* program, ScratchBuffer* scratch_buffer, uint32_t* dynamic_offsets, uint32_t dynamic_alignment, bool perform_vk_update)
2776 {
2777 const uint32_t max_write_descriptors = MAX_SET_COUNT * MAX_BINDINGS_PER_SET_COUNT;
2778 VkWriteDescriptorSet vk_write_descriptors[max_write_descriptors];
2779 VkDescriptorImageInfo vk_write_image_descriptors[max_write_descriptors];
2780 VkDescriptorBufferInfo vk_write_buffer_descriptors[max_write_descriptors];
2781
2782 uint16_t uniform_to_write_index = 0;
2783 uint16_t image_to_write_index = 0;
2784 uint16_t buffer_to_write_index = 0;
2785
2786 uint32_t dynamic_offset_index = 0;
2787
2788 ProgramResourceBindingIterator it(&program->m_BaseProgram);
2789 const ProgramResourceBinding* next;
2790 while((next = it.Next()))
2791 {
2792 ShaderResourceBinding* res = next->m_Res;
2793
2794 VkWriteDescriptorSet& vk_write_desc_info = vk_write_descriptors[uniform_to_write_index];
2795 vk_write_desc_info.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
2796 vk_write_desc_info.pNext = 0;
2797 vk_write_desc_info.dstSet = vk_descriptor_sets[res->m_Set];
2798 vk_write_desc_info.dstBinding = res->m_Binding;
2799 vk_write_desc_info.dstArrayElement = 0;
2800 vk_write_desc_info.descriptorCount = 1;
2801 vk_write_desc_info.pImageInfo = 0;
2802 vk_write_desc_info.pBufferInfo = 0;
2803 vk_write_desc_info.pTexelBufferView = 0;
2804
2805 switch(res->m_BindingFamily)
2806 {
2807 case BINDING_FAMILY_TEXTURE:
2808 UpdateImageDescriptor(context,
2809 context->m_TextureUnits[next->m_TextureUnit],
2810 res,
2811 vk_write_image_descriptors[image_to_write_index++],
2812 vk_write_desc_info);
2813 break;
2814 case BINDING_FAMILY_STORAGE_BUFFER:
2815 {
2816 const StorageBufferBinding binding = context->m_CurrentStorageBuffers[next->m_StorageBufferUnit];
2817
2818 DeviceBuffer* ssbo_buffer = (DeviceBuffer*) binding.m_Buffer;
2819 TouchResource(context, ssbo_buffer);
2820 UpdateUniformBufferDescriptor(context,
2821 ssbo_buffer->m_Handle.m_Buffer,
2822 VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
2823 vk_write_buffer_descriptors[buffer_to_write_index++],
2824 vk_write_desc_info,
2825 binding.m_BufferOffset,
2826 VK_WHOLE_SIZE);
2827 } break;
2828 case BINDING_FAMILY_UNIFORM_BUFFER:
2829 {
2830 VulkanUniformBuffer* bound_ubo = context->m_CurrentUniformBuffers[res->m_Set][res->m_Binding];
2831
2832 if (bound_ubo)

Callers 1

CommitUniformsFunction · 0.85

Calls 5

UpdateImageDescriptorFunction · 0.85
TouchResourceFunction · 0.85
assertFunction · 0.50
NextMethod · 0.45

Tested by

no test coverage detected