anv: Add a descriptor_count to descriptor sets
This is useful for asserting in-bounds descriptor set access. Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7180>
This commit is contained in:

committed by
Marge Bot

parent
dd1971c9d8
commit
215218f32f
@@ -1241,6 +1241,7 @@ anv_cmd_buffer_push_descriptor_set(struct anv_cmd_buffer *cmd_buffer,
|
||||
}
|
||||
set->size = anv_descriptor_set_layout_size(layout);
|
||||
set->buffer_view_count = layout->buffer_view_count;
|
||||
set->descriptor_count = layout->size;
|
||||
set->buffer_views = (*push_set)->buffer_views;
|
||||
|
||||
if (layout->descriptor_buffer_size &&
|
||||
|
@@ -982,6 +982,8 @@ anv_descriptor_set_create(struct anv_device *device,
|
||||
(struct anv_buffer_view *) &set->descriptors[layout->size];
|
||||
set->buffer_view_count = layout->buffer_view_count;
|
||||
|
||||
set->descriptor_count = layout->size;
|
||||
|
||||
/* By defining the descriptors to be zero now, we can later verify that
|
||||
* a descriptor has not been populated with user data.
|
||||
*/
|
||||
|
@@ -2091,6 +2091,7 @@ struct anv_descriptor_set {
|
||||
/* Link to descriptor pool's desc_sets list . */
|
||||
struct list_head pool_link;
|
||||
|
||||
uint32_t descriptor_count;
|
||||
struct anv_descriptor descriptors[0];
|
||||
};
|
||||
|
||||
|
@@ -2600,8 +2600,10 @@ emit_binding_table(struct anv_cmd_buffer *cmd_buffer,
|
||||
|
||||
default: {
|
||||
assert(binding->set < MAX_SETS);
|
||||
const struct anv_descriptor *desc =
|
||||
&pipe_state->descriptors[binding->set]->descriptors[binding->index];
|
||||
const struct anv_descriptor_set *set =
|
||||
pipe_state->descriptors[binding->set];
|
||||
assert(binding->index < set->descriptor_count);
|
||||
const struct anv_descriptor *desc = &set->descriptors[binding->index];
|
||||
|
||||
switch (desc->type) {
|
||||
case VK_DESCRIPTOR_TYPE_SAMPLER:
|
||||
|
Reference in New Issue
Block a user