Module: Mesa Branch: master Commit: ebdc0cd4ad95d0f0e218eb3eff87adc5962ee1b2 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=ebdc0cd4ad95d0f0e218eb3eff87adc5962ee1b2
Author: Mike Blumenkrantz <michael.blumenkra...@gmail.com> Date: Thu Nov 5 10:41:21 2020 -0500 zink: improve debug asserts for samplers/images during descriptor updates these are now more accurate for null bufferviews/imageviews Reviewed-by: Dave Airlie <airl...@redhat.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9543> --- src/gallium/drivers/zink/zink_draw.c | 35 ++++++++++++++++++++++++++++------- 1 file changed, 28 insertions(+), 7 deletions(-) diff --git a/src/gallium/drivers/zink/zink_draw.c b/src/gallium/drivers/zink/zink_draw.c index 615d0869997..5f5703ad925 100644 --- a/src/gallium/drivers/zink/zink_draw.c +++ b/src/gallium/drivers/zink/zink_draw.c @@ -31,14 +31,23 @@ desc_set_res_add(struct zink_descriptor_set *zds, struct zink_resource *res, uns } static void -desc_set_sampler_add(struct zink_descriptor_set *zds, struct zink_sampler_view *sv, struct zink_sampler_state *state, unsigned int i, bool cache_hit) +desc_set_sampler_add(struct zink_context *ctx, struct zink_descriptor_set *zds, struct zink_sampler_view *sv, + struct zink_sampler_state *state, unsigned int i, bool is_buffer, bool cache_hit) { /* if we got a cache hit, we have to verify that the cached set is still valid; * we store the vk resource to the set here to avoid a more complex and costly mechanism of maintaining a * hash table on every resource with the associated descriptor sets that then needs to be iterated through * whenever a resource is destroyed */ - assert(!cache_hit || get_sampler_view_hash(zds->sampler_views[i]) == get_sampler_view_hash(sv)); +#ifndef NDEBUG + uint32_t null_hash = is_buffer ? zink_screen(ctx->base.screen)->null_descriptor_hashes.buffer_view : + zink_screen(ctx->base.screen)->null_descriptor_hashes.image_view; + uint32_t cur_hash = get_sampler_view_hash(zds->sampler_views[i]) ? get_sampler_view_hash(zds->sampler_views[i]) : + null_hash; + uint32_t new_hash = get_sampler_view_hash(sv) ? get_sampler_view_hash(sv) : + null_hash; +#endif + assert(!cache_hit || cur_hash == new_hash); assert(!cache_hit || zds->sampler_states[i] == state); if (!cache_hit) { zink_sampler_view_desc_set_add(sv, zds, i); @@ -47,14 +56,23 @@ desc_set_sampler_add(struct zink_descriptor_set *zds, struct zink_sampler_view * } static void -desc_set_image_add(struct zink_descriptor_set *zds, struct zink_image_view *image_view, unsigned int i, bool cache_hit) +desc_set_image_add(struct zink_context *ctx, struct zink_descriptor_set *zds, struct zink_image_view *image_view, + unsigned int i, bool is_buffer, bool cache_hit) { /* if we got a cache hit, we have to verify that the cached set is still valid; * we store the vk resource to the set here to avoid a more complex and costly mechanism of maintaining a * hash table on every resource with the associated descriptor sets that then needs to be iterated through * whenever a resource is destroyed */ - assert(!cache_hit || get_image_view_hash(zds->image_views[i]) == get_image_view_hash(image_view)); +#ifndef NDEBUG + uint32_t null_hash = is_buffer ? zink_screen(ctx->base.screen)->null_descriptor_hashes.buffer_view : + zink_screen(ctx->base.screen)->null_descriptor_hashes.image_view; + uint32_t cur_hash = get_image_view_hash(zds->image_views[i]) ? get_image_view_hash(zds->image_views[i]) : + null_hash; + uint32_t new_hash = get_image_view_hash(image_view) ? get_image_view_hash(image_view) : + null_hash; +#endif + assert(!cache_hit || cur_hash == new_hash); if (!cache_hit) zink_image_view_desc_set_add(image_view, zds, i); } @@ -613,7 +631,6 @@ update_sampler_descriptors(struct zink_context *ctx, struct zink_descriptor_set sampler = ctx->sampler_states[stage][index + k]; } assert(num_resources < num_bindings); - desc_set_sampler_add(zds, sampler_view, sampler, num_resources++, cache_hit); if (res) { if (!cache_hit) add_barrier(res, layout, VK_ACCESS_SHADER_READ_BIT, stage, &zds->barriers, ht); @@ -623,7 +640,9 @@ update_sampler_descriptors(struct zink_context *ctx, struct zink_descriptor_set &wds[num_wds], layout, &num_image_info, &image_infos[num_image_info], &num_buffer_info, &buffer_views[num_buffer_info], sampler, imageview, bufferview, !k); - + desc_set_sampler_add(ctx, zds, sampler_view, sampler, num_resources++, + zink_shader_descriptor_is_buffer(shader, ZINK_DESCRIPTOR_TYPE_SAMPLER_VIEW, j), + cache_hit); struct zink_batch *batch = is_compute ? &ctx->compute_batch : zink_curr_batch(ctx); if (sampler_view) zink_batch_reference_sampler_view(batch, sampler_view); @@ -695,7 +714,9 @@ update_image_descriptors(struct zink_context *ctx, struct zink_descriptor_set *z layout = VK_IMAGE_LAYOUT_GENERAL; } assert(num_resources < num_bindings); - desc_set_image_add(zds, image_view, num_resources++, cache_hit); + desc_set_image_add(ctx, zds, image_view, num_resources++, + zink_shader_descriptor_is_buffer(shader, ZINK_DESCRIPTOR_TYPE_IMAGE, j), + cache_hit); if (res) { VkAccessFlags flags = 0; if (image_view->base.access & PIPE_IMAGE_ACCESS_READ) _______________________________________________ mesa-commit mailing list mesa-commit@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-commit