| 2990 | } |
| 2991 | |
| 2992 | static VkResult CommitUniforms(VulkanContext* context, VkCommandBuffer vk_command_buffer, VkDevice vk_device, |
| 2993 | VulkanProgram* program_ptr, VkPipelineBindPoint bind_point, |
| 2994 | ScratchBuffer* scratch_buffer, uint32_t* dynamic_offsets, const uint32_t alignment) |
| 2995 | { |
| 2996 | const uint32_t num_descriptors = program_ptr->m_TotalResourcesCount; |
| 2997 | const uint32_t num_dynamic_offsets = program_ptr->m_UniformBufferCount; |
| 2998 | |
| 2999 | if (num_descriptors == 0) |
| 3000 | { |
| 3001 | return VK_SUCCESS; |
| 3002 | } |
| 3003 | |
| 3004 | const uint8_t frame_index = (uint8_t) context->m_CurrentFrameInFlight; |
| 3005 | |
| 3006 | DescriptorSetCache* cache = 0x0; |
| 3007 | if (bind_point == VK_PIPELINE_BIND_POINT_GRAPHICS) |
| 3008 | { |
| 3009 | cache = &program_ptr->m_GraphicsDescriptorCache[frame_index]; |
| 3010 | } |
| 3011 | else if (bind_point == VK_PIPELINE_BIND_POINT_COMPUTE) |
| 3012 | { |
| 3013 | cache = &program_ptr->m_ComputeDescriptorCache[frame_index]; |
| 3014 | } |
| 3015 | |
| 3016 | const uint32_t allocator_generation = context->m_DescriptorAllocatorGeneration[frame_index]; |
| 3017 | const uint32_t descriptor_set_count = program_ptr->m_Handle.m_DescriptorSetLayoutsCount; |
| 3018 | uint64_t binding_signature = 0; |
| 3019 | |
| 3020 | VkDescriptorSet* vk_descriptor_set_list = 0x0; |
| 3021 | VkResult res = VK_SUCCESS; |
| 3022 | |
| 3023 | if (cache) |
| 3024 | { |
| 3025 | binding_signature = GetDescriptorBindingSignature(context, program_ptr, scratch_buffer); |
| 3026 | vk_descriptor_set_list = cache->Find(binding_signature, allocator_generation, descriptor_set_count); |
| 3027 | } |
| 3028 | |
| 3029 | const bool cache_hit = vk_descriptor_set_list != 0; |
| 3030 | |
| 3031 | if (!cache_hit) |
| 3032 | { |
| 3033 | res = scratch_buffer->m_DescriptorAllocator->Allocate( |
| 3034 | vk_device, |
| 3035 | program_ptr->m_Handle.m_DescriptorSetLayouts, |
| 3036 | descriptor_set_count, |
| 3037 | num_descriptors, |
| 3038 | &vk_descriptor_set_list); |
| 3039 | if (res != VK_SUCCESS) |
| 3040 | { |
| 3041 | return res; |
| 3042 | } |
| 3043 | |
| 3044 | UpdateDescriptorSets(context, vk_device, vk_descriptor_set_list, program_ptr, scratch_buffer, dynamic_offsets, alignment, true); |
| 3045 | |
| 3046 | if (cache) |
| 3047 | { |
| 3048 | cache->Insert(binding_signature, allocator_generation, descriptor_set_count, vk_descriptor_set_list); |
| 3049 | } |
no test coverage detected