lavapipe: more descriptor validation

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14656>
This commit is contained in:
Mike Blumenkrantz 2022-01-31 12:00:27 -05:00 committed by Marge Bot
parent 0c130d64d3
commit afb4cced5c
1 changed files with 31 additions and 0 deletions

View File

@ -171,6 +171,37 @@ VKAPI_ATTR VkResult VKAPI_CALL lvp_CreateDescriptorSetLayout(
set_layout->shader_stages |= binding->stageFlags;
}
#ifndef NDEBUG
/* this otherwise crashes later and is annoying to track down */
unsigned array[] = {
VK_SHADER_STAGE_VERTEX_BIT,
VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT,
VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT,
VK_SHADER_STAGE_GEOMETRY_BIT,
VK_SHADER_STAGE_FRAGMENT_BIT,
VK_SHADER_STAGE_COMPUTE_BIT,
};
for (unsigned i = 0; i <= MESA_SHADER_COMPUTE; i++) {
uint16_t const_buffer_count = 0;
uint16_t shader_buffer_count = 0;
uint16_t sampler_count = 0;
uint16_t sampler_view_count = 0;
uint16_t image_count = 0;
if (set_layout->shader_stages & array[i]) {
const_buffer_count += set_layout->stage[i].const_buffer_count;
shader_buffer_count += set_layout->stage[i].shader_buffer_count;
sampler_count += set_layout->stage[i].sampler_count;
sampler_view_count += set_layout->stage[i].sampler_view_count;
image_count += set_layout->stage[i].image_count;
}
assert(const_buffer_count <= device->physical_device->device_limits.maxPerStageDescriptorUniformBuffers);
assert(shader_buffer_count <= device->physical_device->device_limits.maxPerStageDescriptorStorageBuffers);
assert(sampler_count <= device->physical_device->device_limits.maxPerStageDescriptorSamplers);
assert(sampler_view_count <= device->physical_device->device_limits.maxPerStageDescriptorSampledImages);
assert(image_count <= device->physical_device->device_limits.maxPerStageDescriptorStorageImages);
}
#endif
free(bindings);
set_layout->dynamic_offset_count = dynamic_offset_count;