Mesa (master): iris: Properly handle new unbind_num_trailing_slots parameters

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Jan 28 10:33:23 UTC 2021


Module: Mesa
Branch: master
Commit: 9d63547f2ff6fa78051157b310d70846684355d1
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=9d63547f2ff6fa78051157b310d70846684355d1

Author: Kenneth Graunke <kenneth at whitecape.org>
Date:   Wed Jan 27 23:27:02 2021 -0800

iris: Properly handle new unbind_num_trailing_slots parameters

Commits 0278d1fa323cf1f289..b688ea31fcf7e20436 added a new parameter
to set_vertex_buffers(), set_shader_images(), and set_sampler_views()
which specifies a number of trailing slots to unbind.  They updated
the iris functions to do the unbinding, but didn't update the code
to mark which things are bound in the bitfields.  This meant that
later code would assume those unbound slots were bound, and crash
on a NULL dereference.  All that's needed is to add that slot count
when unbinding things in the bitfield.

Fixes: 0278d1fa323 ("gallium: add unbind_num_trailing_slots to set_vertex_buffers")
Fixes: 72ff66c3d73 ("gallium: add unbind_num_trailing_slots to set_shader_images")
Fixes: b688ea31fcf ("gallium: add unbind_num_trailing_slots to set_sampler_views")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8758>

---

 src/gallium/drivers/iris/iris_state.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/src/gallium/drivers/iris/iris_state.c b/src/gallium/drivers/iris/iris_state.c
index 40ad5462671..882b112a3f8 100644
--- a/src/gallium/drivers/iris/iris_state.c
+++ b/src/gallium/drivers/iris/iris_state.c
@@ -2752,7 +2752,8 @@ iris_set_shader_images(struct pipe_context *ctx,
    struct brw_image_param *image_params = genx->shaders[stage].image_param;
 #endif
 
-   shs->bound_image_views &= ~u_bit_consecutive(start_slot, count);
+   shs->bound_image_views &=
+      ~u_bit_consecutive(start_slot, count + unbind_num_trailing_slots);
 
    for (unsigned i = 0; i < count; i++) {
       struct iris_image_view *iv = &shs->image[start_slot + i];
@@ -2864,7 +2865,8 @@ iris_set_sampler_views(struct pipe_context *ctx,
    struct iris_shader_state *shs = &ice->state.shaders[stage];
    unsigned i;
 
-   shs->bound_sampler_views &= ~u_bit_consecutive(start, count);
+   shs->bound_sampler_views &=
+      ~u_bit_consecutive(start, count + unbind_num_trailing_slots);
 
    for (i = 0; i < count; i++) {
       struct pipe_sampler_view *pview = views ? views[i] : NULL;
@@ -3441,7 +3443,8 @@ iris_set_vertex_buffers(struct pipe_context *ctx,
    struct iris_screen *screen = (struct iris_screen *)ctx->screen;
    struct iris_genx_state *genx = ice->state.genx;
 
-   ice->state.bound_vertex_buffers &= ~u_bit_consecutive64(start_slot, count);
+   ice->state.bound_vertex_buffers &=
+      ~u_bit_consecutive64(start_slot, count + unbind_num_trailing_slots);
 
    for (unsigned i = 0; i < count; i++) {
       const struct pipe_vertex_buffer *buffer = buffers ? &buffers[i] : NULL;



More information about the mesa-commit mailing list