| 3292 | } |
| 3293 | |
| 3294 | static bool ValidateShaderModule(VulkanContext* context, ShaderMeta* meta, ShaderModule* shader, ShaderStageFlag stage_flags, char* error_buffer, uint32_t error_buffer_size) |
| 3295 | { |
| 3296 | uint32_t stage_uniform_buffers = 0; |
| 3297 | uint32_t stage_storage_buffers = 0; |
| 3298 | uint32_t stage_textures = 0; |
| 3299 | |
| 3300 | for (int i = 0; i < meta->m_UniformBuffers.Size(); ++i) |
| 3301 | { |
| 3302 | if (meta->m_UniformBuffers[i].m_StageFlags & stage_flags) |
| 3303 | stage_uniform_buffers++; |
| 3304 | } |
| 3305 | |
| 3306 | for (int i = 0; i < meta->m_StorageBuffers.Size(); ++i) |
| 3307 | { |
| 3308 | if (meta->m_StorageBuffers[i].m_StageFlags & stage_flags) |
| 3309 | stage_storage_buffers++; |
| 3310 | } |
| 3311 | |
| 3312 | for (int i = 0; i < meta->m_Textures.Size(); ++i) |
| 3313 | { |
| 3314 | if (meta->m_Textures[i].m_StageFlags & stage_flags) |
| 3315 | stage_textures++; |
| 3316 | } |
| 3317 | |
| 3318 | if (stage_uniform_buffers > context->m_PhysicalDevice.m_Properties.limits.maxPerStageDescriptorUniformBuffers) |
| 3319 | { |
| 3320 | dmSnPrintf(error_buffer, error_buffer_size, "Maximum number of uniform buffers exceeded: shader has %d buffers, but maximum is %d.", |
| 3321 | stage_uniform_buffers, context->m_PhysicalDevice.m_Properties.limits.maxPerStageDescriptorUniformBuffers); |
| 3322 | return false; |
| 3323 | } |
| 3324 | else if (stage_storage_buffers > context->m_PhysicalDevice.m_Properties.limits.maxPerStageDescriptorStorageBuffers) |
| 3325 | { |
| 3326 | dmSnPrintf(error_buffer, error_buffer_size, "Maximum number of storage exceeded: shader has %d buffer, but maximum is %d.", |
| 3327 | stage_storage_buffers, context->m_PhysicalDevice.m_Properties.limits.maxPerStageDescriptorStorageBuffers); |
| 3328 | return false; |
| 3329 | } |
| 3330 | else if (stage_textures > context->m_PhysicalDevice.m_Properties.limits.maxPerStageDescriptorSamplers) |
| 3331 | { |
| 3332 | dmSnPrintf(error_buffer, error_buffer_size, "Maximum number of texture samplers exceeded: shader has %d samplers, but maximum is %d.", |
| 3333 | stage_textures, context->m_PhysicalDevice.m_Properties.limits.maxPerStageDescriptorSamplers); |
| 3334 | return false; |
| 3335 | } |
| 3336 | return true; |
| 3337 | } |
| 3338 | |
| 3339 | static void CreatePipelineLayout(VulkanContext* context, VulkanProgram* program, VkDescriptorSetLayoutBinding bindings[MAX_SET_COUNT][MAX_BINDINGS_PER_SET_COUNT], uint32_t max_sets) |
| 3340 | { |
no test coverage detected