gallium: add unbind_num_trailing_slots to set_sampler_views
authorMarek Olšák <marek.olsak@amd.com>
Mon, 21 Dec 2020 08:01:34 +0000 (03:01 -0500)
committerMarge Bot <eric+marge@anholt.net>
Wed, 27 Jan 2021 23:53:35 +0000 (23:53 +0000)
Instead of calling this functions again to unbind trailing slots,
extend it to do it when binding. This reduces CPU overhead.

A lot of drivers ignore "start" and always unbind all slots after "count".
Such drivers don't need any changes here.

Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8298>

76 files changed:
src/gallium/auxiliary/cso_cache/cso_context.c
src/gallium/auxiliary/draw/draw_pipe_pstipple.c
src/gallium/auxiliary/driver_ddebug/dd_context.c
src/gallium/auxiliary/driver_noop/noop_state.c
src/gallium/auxiliary/driver_rbug/rbug_context.c
src/gallium/auxiliary/driver_trace/tr_context.c
src/gallium/auxiliary/hud/hud_context.c
src/gallium/auxiliary/postprocess/pp_colors.c
src/gallium/auxiliary/postprocess/pp_mlaa.c
src/gallium/auxiliary/postprocess/pp_run.c
src/gallium/auxiliary/util/u_blitter.c
src/gallium/auxiliary/util/u_compute.c
src/gallium/auxiliary/util/u_tests.c
src/gallium/auxiliary/util/u_threaded_context.c
src/gallium/auxiliary/vl/vl_bicubic_filter.c
src/gallium/auxiliary/vl/vl_compositor_cs.c
src/gallium/auxiliary/vl/vl_compositor_gfx.c
src/gallium/auxiliary/vl/vl_deint_filter.c
src/gallium/auxiliary/vl/vl_idct.c
src/gallium/auxiliary/vl/vl_matrix_filter.c
src/gallium/auxiliary/vl/vl_mc.c
src/gallium/auxiliary/vl/vl_median_filter.c
src/gallium/auxiliary/vl/vl_mpeg12_decoder.c
src/gallium/auxiliary/vl/vl_zscan.c
src/gallium/drivers/d3d12/d3d12_blit.cpp
src/gallium/drivers/d3d12/d3d12_context.cpp
src/gallium/drivers/etnaviv/etnaviv_texture.c
src/gallium/drivers/freedreno/a2xx/fd2_texture.c
src/gallium/drivers/freedreno/a4xx/fd4_texture.c
src/gallium/drivers/freedreno/a5xx/fd5_texture.c
src/gallium/drivers/freedreno/freedreno_texture.c
src/gallium/drivers/freedreno/freedreno_texture.h
src/gallium/drivers/i915/i915_state.c
src/gallium/drivers/iris/iris_state.c
src/gallium/drivers/lima/lima_state.c
src/gallium/drivers/llvmpipe/lp_state_sampler.c
src/gallium/drivers/nouveau/nv30/nv30_fragtex.c
src/gallium/drivers/nouveau/nv50/nv50_state.c
src/gallium/drivers/nouveau/nvc0/nvc0_state.c
src/gallium/drivers/panfrost/pan_context.c
src/gallium/drivers/r300/r300_state.c
src/gallium/drivers/r600/r600_state_common.c
src/gallium/drivers/radeonsi/si_descriptors.c
src/gallium/drivers/softpipe/sp_state.h
src/gallium/drivers/softpipe/sp_state_derived.c
src/gallium/drivers/softpipe/sp_state_sampler.c
src/gallium/drivers/svga/svga_pipe_sampler.c
src/gallium/drivers/swr/swr_state.cpp
src/gallium/drivers/tegra/tegra_context.c
src/gallium/drivers/v3d/v3dx_state.c
src/gallium/drivers/vc4/vc4_blit.c
src/gallium/drivers/vc4/vc4_state.c
src/gallium/drivers/virgl/virgl_context.c
src/gallium/drivers/zink/zink_context.c
src/gallium/frontends/clover/core/kernel.cpp
src/gallium/frontends/lavapipe/lvp_execute.c
src/gallium/frontends/nine/nine_state.c
src/gallium/frontends/xa/xa_composite.c
src/gallium/frontends/xa/xa_context.c
src/gallium/frontends/xa/xa_renderer.c
src/gallium/frontends/xa/xa_yuv.c
src/gallium/include/pipe/p_context.h
src/gallium/tests/graw/fs-test.c
src/gallium/tests/graw/gs-test.c
src/gallium/tests/graw/quad-sample.c
src/gallium/tests/graw/quad-tex.c
src/gallium/tests/graw/tex-srgb.c
src/gallium/tests/graw/tex-swizzle.c
src/gallium/tests/graw/vs-test.c
src/gallium/tests/trivial/compute.c
src/gallium/tests/trivial/quad-tex.c
src/mesa/state_tracker/st_atom_texture.c
src/mesa/state_tracker/st_cb_bitmap.c
src/mesa/state_tracker/st_cb_drawpixels.c
src/mesa/state_tracker/st_cb_readpixels.c
src/mesa/state_tracker/st_cb_texture.c

index 5ba9d59..eaf1b61 100644 (file)
@@ -337,7 +337,7 @@ void cso_destroy_context( struct cso_context *ctx )
                ctx->pipe->bind_sampler_states(ctx->pipe, sh, 0, maxsam, zeros);
             }
             if (maxview > 0) {
-               ctx->pipe->set_sampler_views(ctx->pipe, sh, 0, maxview, views);
+               ctx->pipe->set_sampler_views(ctx->pipe, sh, 0, maxview, 0, views);
             }
             if (maxssbo > 0) {
                ctx->pipe->set_shader_buffers(ctx->pipe, sh, 0, maxssbo, ssbos, 0);
index dbb0545..6477653 100644 (file)
@@ -108,6 +108,7 @@ struct pstip_stage
    void (*driver_set_sampler_views)(struct pipe_context *,
                                     enum pipe_shader_type shader,
                                     unsigned start, unsigned count,
+                                    unsigned unbind_num_trailing_slots,
                                     struct pipe_sampler_view **);
 
    void (*driver_set_polygon_stipple)(struct pipe_context *,
@@ -225,7 +226,7 @@ pstip_first_tri(struct draw_stage *stage, struct prim_header *header)
                                      num_samplers, pstip->state.samplers);
 
    pstip->driver_set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0,
-                                   num_sampler_views, pstip->state.sampler_views);
+                                   num_sampler_views, 0, pstip->state.sampler_views);
 
    draw->suspend_flushing = FALSE;
 
@@ -254,7 +255,7 @@ pstip_flush(struct draw_stage *stage, unsigned flags)
                                      pstip->state.samplers);
 
    pstip->driver_set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0,
-                                   pstip->num_sampler_views,
+                                   pstip->num_sampler_views, 0,
                                    pstip->state.sampler_views);
 
    draw->suspend_flushing = FALSE;
@@ -418,6 +419,7 @@ static void
 pstip_set_sampler_views(struct pipe_context *pipe,
                         enum pipe_shader_type shader,
                         unsigned start, unsigned num,
+                        unsigned unbind_num_trailing_slots,
                         struct pipe_sampler_view **views)
 {
    struct pstip_stage *pstip = pstip_stage_from_pipe(pipe);
@@ -429,11 +431,16 @@ pstip_set_sampler_views(struct pipe_context *pipe,
          pipe_sampler_view_reference(&pstip->state.sampler_views[start + i],
                                      views[i]);
       }
+      for (; i < num + unbind_num_trailing_slots; i++) {
+         pipe_sampler_view_reference(&pstip->state.sampler_views[start + i],
+                                     NULL);
+      }
       pstip->num_sampler_views = num;
    }
 
    /* pass-through */
-   pstip->driver_set_sampler_views(pstip->pipe, shader, start, num, views);
+   pstip->driver_set_sampler_views(pstip->pipe, shader, start, num,
+                                   unbind_num_trailing_slots, views);
 }
 
 
index 211133f..69117f0 100644 (file)
@@ -510,6 +510,7 @@ static void
 dd_context_set_sampler_views(struct pipe_context *_pipe,
                              enum pipe_shader_type shader,
                              unsigned start, unsigned num,
+                             unsigned unbind_num_trailing_slots,
                              struct pipe_sampler_view **views)
 {
    struct dd_context *dctx = dd_context(_pipe);
@@ -517,7 +518,10 @@ dd_context_set_sampler_views(struct pipe_context *_pipe,
 
    safe_memcpy(&dctx->draw_state.sampler_views[shader][start], views,
                sizeof(views[0]) * num);
-   pipe->set_sampler_views(pipe, shader, start, num, views);
+   safe_memcpy(&dctx->draw_state.sampler_views[shader][start + num], views,
+               sizeof(views[0]) * unbind_num_trailing_slots);
+   pipe->set_sampler_views(pipe, shader, start, num,
+                           unbind_num_trailing_slots, views);
 }
 
 static void
index b0315af..b7031c3 100644 (file)
@@ -114,6 +114,7 @@ static struct pipe_surface *noop_create_surface(struct pipe_context *ctx,
 static void noop_set_sampler_views(struct pipe_context *ctx,
                                    enum pipe_shader_type shader,
                                    unsigned start, unsigned count,
+                                   unsigned unbind_num_trailing_slots,
                                    struct pipe_sampler_view **views)
 {
 }
index e0d92ff..225c77e 100644 (file)
@@ -738,6 +738,7 @@ rbug_set_sampler_views(struct pipe_context *_pipe,
                        enum pipe_shader_type shader,
                        unsigned start,
                        unsigned num,
+                       unsigned unbind_num_trailing_slots,
                        struct pipe_sampler_view **_views)
 {
    struct rbug_context *rb_pipe = rbug_context(_pipe);
@@ -766,7 +767,8 @@ rbug_set_sampler_views(struct pipe_context *_pipe,
       views = unwrapped_views;
    }
 
-   pipe->set_sampler_views(pipe, shader, start, num, views);
+   pipe->set_sampler_views(pipe, shader, start, num,
+                           unbind_num_trailing_slots, views);
 
    mtx_unlock(&rb_pipe->call_mutex);
 }
index 3b81b70..9022597 100644 (file)
@@ -987,6 +987,7 @@ trace_context_set_sampler_views(struct pipe_context *_pipe,
                                 enum pipe_shader_type shader,
                                 unsigned start,
                                 unsigned num,
+                                unsigned unbind_num_trailing_slots,
                                 struct pipe_sampler_view **views)
 {
    struct trace_context *tr_ctx = trace_context(_pipe);
@@ -1010,9 +1011,11 @@ trace_context_set_sampler_views(struct pipe_context *_pipe,
    trace_dump_arg(uint, shader);
    trace_dump_arg(uint, start);
    trace_dump_arg(uint, num);
+   trace_dump_arg(uint, unbind_num_trailing_slots);
    trace_dump_arg_array(ptr, views, num);
 
-   pipe->set_sampler_views(pipe, shader, start, num, views);
+   pipe->set_sampler_views(pipe, shader, start, num,
+                           unbind_num_trailing_slots, views);
 
    trace_dump_call_end();
 }
index 8c2146b..487c9fe 100644 (file)
@@ -537,7 +537,7 @@ hud_draw_results(struct hud_context *hud, struct pipe_resource *tex)
    cso_set_vertex_shader_handle(cso, hud->vs);
    cso_set_vertex_elements(cso, &hud->velems);
    cso_set_render_condition(cso, NULL, FALSE, 0);
-   pipe->set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0, 1,
+   pipe->set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0, 1, 0,
                            &hud->font_sampler_view);
    cso_set_samplers(cso, PIPE_SHADER_FRAGMENT, 1, sampler_states);
    pipe->set_constant_buffer(pipe, PIPE_SHADER_VERTEX, 0, false, &hud->constbuf);
@@ -608,7 +608,7 @@ done:
    /* Unbind resources that we have bound. */
    pipe->set_constant_buffer(pipe, PIPE_SHADER_VERTEX, 0, false, NULL);
    pipe->set_vertex_buffers(pipe, 0, 0, 1, NULL);
-   pipe->set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0, 1, NULL);
+   pipe->set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0, 0, 1, NULL);
 
    /* restore states not restored by cso */
    if (hud->st) {
index 4240364..f319ebb 100644 (file)
@@ -47,7 +47,7 @@ pp_nocolor(struct pp_queue_t *ppq, struct pipe_resource *in,
    pp_filter_misc_state(p);
 
    cso_set_samplers(p->cso, PIPE_SHADER_FRAGMENT, 1, samplers);
-   pipe->set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0, 1, &p->view);
+   pipe->set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0, 1, 0, &p->view);
 
    cso_set_vertex_shader_handle(p->cso, ppq->shaders[n][0]);
    cso_set_fragment_shader_handle(p->cso, ppq->shaders[n][1]);
index d37c69e..2bc2ac8 100644 (file)
@@ -134,7 +134,7 @@ pp_jimenezmlaa_run(struct pp_queue_t *ppq, struct pipe_resource *in,
       const struct pipe_sampler_state *samplers[] = {&p->sampler_point};
       cso_set_samplers(p->cso, PIPE_SHADER_FRAGMENT, 1, samplers);
    }
-   pipe->set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0, 1, &p->view);
+   pipe->set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0, 1, 0, &p->view);
 
    cso_set_vertex_shader_handle(p->cso, ppq->shaders[n][1]);    /* offsetvs */
    cso_set_fragment_shader_handle(p->cso, ppq->shaders[n][2]);
@@ -166,7 +166,7 @@ pp_jimenezmlaa_run(struct pp_queue_t *ppq, struct pipe_resource *in,
    }
 
    arr[0] = p->view;
-   pipe->set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0, 3, arr);
+   pipe->set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0, 3, 0, arr);
 
    cso_set_vertex_shader_handle(p->cso, ppq->shaders[n][0]);    /* passvs */
    cso_set_fragment_shader_handle(p->cso, ppq->shaders[n][3]);
@@ -198,7 +198,7 @@ pp_jimenezmlaa_run(struct pp_queue_t *ppq, struct pipe_resource *in,
    }
 
    arr[1] = p->view;
-   pipe->set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0, 2, arr);
+   pipe->set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0, 2, 0, arr);
 
    cso_set_vertex_shader_handle(p->cso, ppq->shaders[n][1]);    /* offsetvs */
    cso_set_fragment_shader_handle(p->cso, ppq->shaders[n][4]);
index 8824507..b0be81c 100644 (file)
@@ -191,7 +191,7 @@ pp_run(struct pp_queue_t *ppq, struct pipe_resource *in,
    pipe->set_constant_buffer(pipe, PIPE_SHADER_VERTEX, 0, false, NULL);
    pipe->set_constant_buffer(pipe, PIPE_SHADER_FRAGMENT, 0, false, NULL);
    pipe->set_vertex_buffers(pipe, 0, 0, 1, NULL);
-   pipe->set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0, 3, NULL);
+   pipe->set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0, 0, 3, NULL);
 
    /* restore states not restored by cso */
    if (ppq->p->st) {
index 3d11bfe..eb28504 100644 (file)
@@ -784,7 +784,7 @@ void util_blitter_restore_textures(struct blitter_context *blitter)
 
    /* Fragment sampler views. */
    pipe->set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0,
-                           ctx->base.saved_num_sampler_views,
+                           ctx->base.saved_num_sampler_views, 0,
                            ctx->base.saved_sampler_views);
 
    for (i = 0; i < ctx->base.saved_num_sampler_views; i++)
@@ -2082,7 +2082,7 @@ void util_blitter_blit_generic(struct blitter_context *blitter,
       views[0] = src;
       views[1] = pipe->create_sampler_view(pipe, src->texture, &templ);
 
-      pipe->set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0, 2, views);
+      pipe->set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0, 2, 0, views);
       pipe->bind_sampler_states(pipe, PIPE_SHADER_FRAGMENT, 0, 2, samplers);
 
       pipe_sampler_view_reference(&views[1], NULL);
@@ -2097,13 +2097,13 @@ void util_blitter_blit_generic(struct blitter_context *blitter,
 
       view = pipe->create_sampler_view(pipe, src->texture, &templ);
 
-      pipe->set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0, 1, &view);
+      pipe->set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0, 1, 0, &view);
       pipe->bind_sampler_states(pipe, PIPE_SHADER_FRAGMENT,
                                 0, 1, &sampler_state);
 
       pipe_sampler_view_reference(&view, NULL);
    } else {
-      pipe->set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0, 1, &src);
+      pipe->set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0, 1, 0, &src);
       pipe->bind_sampler_states(pipe, PIPE_SHADER_FRAGMENT,
                                 0, 1, &sampler_state);
    }
@@ -2250,7 +2250,7 @@ void util_blitter_generate_mipmap(struct blitter_context *blitter,
       src_templ.format = format;
       src_view = pipe->create_sampler_view(pipe, tex, &src_templ);
 
-      pipe->set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0, 1, &src_view);
+      pipe->set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0, 1, 0, &src_view);
 
       do_blits(ctx, dst_view, &dstbox, src_view, tex->width0, tex->height0,
                &srcbox, is_depth, false);
@@ -2884,7 +2884,7 @@ util_blitter_stencil_fallback(struct blitter_context *blitter,
                                 true);
    }
 
-   pipe->set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0, 1, &src_view);
+   pipe->set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0, 1, 0, &src_view);
    pipe->bind_sampler_states(pipe, PIPE_SHADER_FRAGMENT, 0, 1, &ctx->sampler_state);
 
    unsigned stencil_bits =
index dcfc266..79755ab 100644 (file)
@@ -138,7 +138,7 @@ void util_compute_blit(struct pipe_context *ctx, struct pipe_blit_info *blit_inf
    u_sampler_view_default_template(&src_templ, src, src->format);
    src_templ.format = util_format_linear(blit_info->src.format);
    src_view = ctx->create_sampler_view(ctx, src, &src_templ);
-   ctx->set_sampler_views(ctx, PIPE_SHADER_COMPUTE, 0, 1, &src_view);
+   ctx->set_sampler_views(ctx, PIPE_SHADER_COMPUTE, 0, 1, 0, &src_view);
 
    if (!*compute_state)
      *compute_state = blit_compute_shader(ctx);
@@ -159,7 +159,7 @@ void util_compute_blit(struct pipe_context *ctx, struct pipe_blit_info *blit_inf
 
    ctx->set_shader_images(ctx, PIPE_SHADER_COMPUTE, 0, 0, 1, NULL);
    ctx->set_constant_buffer(ctx, PIPE_SHADER_COMPUTE, 0, false, NULL);
-   ctx->set_sampler_views(ctx, PIPE_SHADER_COMPUTE, 0, 1, NULL);
+   ctx->set_sampler_views(ctx, PIPE_SHADER_COMPUTE, 0, 0, 1, NULL);
    pipe_sampler_view_reference(&src_view, NULL);
    ctx->delete_sampler_state(ctx, sampler_state_p);
    ctx->bind_compute_state(ctx, NULL);
index f73123b..47f479c 100644 (file)
@@ -388,7 +388,7 @@ null_sampler_view(struct pipe_context *ctx, unsigned tgsi_tex_target)
                               PIPE_FORMAT_R8G8B8A8_UNORM, 0);
    util_set_common_states_and_clear(cso, ctx, cb);
 
-   ctx->set_sampler_views(ctx, PIPE_SHADER_FRAGMENT, 0, 1, NULL);
+   ctx->set_sampler_views(ctx, PIPE_SHADER_FRAGMENT, 0, 0, 1, NULL);
 
    /* Fragment shader. */
    fs = util_make_fragment_tex_shader(ctx, tgsi_tex_target,
@@ -698,7 +698,7 @@ test_texture_barrier(struct pipe_context *ctx, bool use_fbfetch,
       templ.swizzle_b = PIPE_SWIZZLE_Z;
       templ.swizzle_a = PIPE_SWIZZLE_W;
       view = ctx->create_sampler_view(ctx, cb, &templ);
-      ctx->set_sampler_views(ctx, PIPE_SHADER_FRAGMENT, 0, 1, &view);
+      ctx->set_sampler_views(ctx, PIPE_SHADER_FRAGMENT, 0, 1, 0, &view);
 
       /* Fragment shader. */
       if (num_samples > 1) {
index 9c07888..f5c4b01 100644 (file)
@@ -941,7 +941,7 @@ tc_set_window_rectangles(struct pipe_context *_pipe, bool include,
 }
 
 struct tc_sampler_views {
-   ubyte shader, start, count;
+   ubyte shader, start, count, unbind_num_trailing_slots;
    struct pipe_sampler_view *slot[0]; /* more will be allocated if needed */
 };
 
@@ -951,7 +951,8 @@ tc_call_set_sampler_views(struct pipe_context *pipe, union tc_payload *payload)
    struct tc_sampler_views *p = (struct tc_sampler_views *)payload;
    unsigned count = p->count;
 
-   pipe->set_sampler_views(pipe, p->shader, p->start, p->count, p->slot);
+   pipe->set_sampler_views(pipe, p->shader, p->start, p->count,
+                           p->unbind_num_trailing_slots, p->slot);
    for (unsigned i = 0; i < count; i++)
       pipe_sampler_view_reference(&p->slot[i], NULL);
 }
@@ -960,9 +961,10 @@ static void
 tc_set_sampler_views(struct pipe_context *_pipe,
                      enum pipe_shader_type shader,
                      unsigned start, unsigned count,
+                     unsigned unbind_num_trailing_slots,
                      struct pipe_sampler_view **views)
 {
-   if (!count)
+   if (!count && !unbind_num_trailing_slots)
       return;
 
    struct threaded_context *tc = threaded_context(_pipe);
@@ -972,6 +974,7 @@ tc_set_sampler_views(struct pipe_context *_pipe,
    p->shader = shader;
    p->start = start;
    p->count = count;
+   p->unbind_num_trailing_slots = unbind_num_trailing_slots;
 
    if (views) {
       for (unsigned i = 0; i < count; i++) {
index d6e128a..3058d9f 100644 (file)
@@ -452,7 +452,7 @@ vl_bicubic_filter_render(struct vl_bicubic_filter *filter,
    filter->pipe->bind_sampler_states(filter->pipe, PIPE_SHADER_FRAGMENT,
                                      0, 1, &filter->sampler);
    filter->pipe->set_sampler_views(filter->pipe, PIPE_SHADER_FRAGMENT,
-                                   0, 1, &src);
+                                   0, 1, 0, &src);
    filter->pipe->bind_vs_state(filter->pipe, filter->vs);
    filter->pipe->bind_fs_state(filter->pipe, filter->fs);
    filter->pipe->set_framebuffer_state(filter->pipe, &fb_state);
index c8a375c..813aa14 100644 (file)
@@ -727,14 +727,14 @@ draw_layers(struct vl_compositor       *c,
          c->pipe->bind_sampler_states(c->pipe, PIPE_SHADER_COMPUTE, 0,
                         num_sampler_views, layer->samplers);
          c->pipe->set_sampler_views(c->pipe, PIPE_SHADER_COMPUTE, 0,
-                        num_sampler_views, samplers);
+                        num_sampler_views, 0, samplers);
 
          cs_launch(c, layer->cs, &(drawn.area));
 
          /* Unbind. */
          c->pipe->set_shader_images(c->pipe, PIPE_SHADER_COMPUTE, 0, 0, 1, NULL);
          c->pipe->set_constant_buffer(c->pipe, PIPE_SHADER_COMPUTE, 0, false, NULL);
-         c->pipe->set_sampler_views(c->pipe, PIPE_SHADER_FRAGMENT, 0,
+         c->pipe->set_sampler_views(c->pipe, PIPE_SHADER_FRAGMENT, 0, 0,
                         num_sampler_views, NULL);
          c->pipe->bind_compute_state(c->pipe, NULL);
          c->pipe->bind_sampler_states(c->pipe, PIPE_SHADER_COMPUTE, 0,
index b1a6d20..344de4e 100644 (file)
@@ -665,7 +665,7 @@ draw_layers(struct vl_compositor *c, struct vl_compositor_state *s, struct u_rec
          c->pipe->bind_sampler_states(c->pipe, PIPE_SHADER_FRAGMENT, 0,
                                       num_sampler_views, layer->samplers);
          c->pipe->set_sampler_views(c->pipe, PIPE_SHADER_FRAGMENT, 0,
-                                    num_sampler_views, samplers);
+                                    num_sampler_views, 0, samplers);
 
          util_draw_arrays(c->pipe, PIPE_PRIM_QUADS, vb_index * 4, 4);
          vb_index++;
index 3754e00..d840c9d 100644 (file)
@@ -497,7 +497,7 @@ vl_deint_filter_render(struct vl_deint_filter *filter,
       sampler_views[1] = prev_sv[k];
       sampler_views[2] = cur_sv[k];
       sampler_views[3] = next_sv[k];
-      filter->pipe->set_sampler_views(filter->pipe, PIPE_SHADER_FRAGMENT, 0, 4, sampler_views);
+      filter->pipe->set_sampler_views(filter->pipe, PIPE_SHADER_FRAGMENT, 0, 4, 0, sampler_views);
 
       /* blit current field */
       fb_state.cbufs[0] = blit_surf;
index 1c35ef9..f3ad2fb 100644 (file)
@@ -827,7 +827,7 @@ vl_idct_flush(struct vl_idct *idct, struct vl_idct_buffer *buffer, unsigned num_
    idct->pipe->bind_sampler_states(idct->pipe, PIPE_SHADER_FRAGMENT,
                                    0, 2, idct->samplers);
 
-   idct->pipe->set_sampler_views(idct->pipe, PIPE_SHADER_FRAGMENT, 0, 2,
+   idct->pipe->set_sampler_views(idct->pipe, PIPE_SHADER_FRAGMENT, 0, 2, 0,
                                  buffer->sampler_views.stage[0]);
 
    /* mismatch control */
@@ -855,6 +855,6 @@ vl_idct_prepare_stage2(struct vl_idct *idct, struct vl_idct_buffer *buffer)
    idct->pipe->bind_sampler_states(idct->pipe, PIPE_SHADER_FRAGMENT,
                                    0, 2, idct->samplers);
    idct->pipe->set_sampler_views(idct->pipe, PIPE_SHADER_FRAGMENT,
-                                 0, 2, buffer->sampler_views.stage[1]);
+                                 0, 2, 0, buffer->sampler_views.stage[1]);
 }
 
index bbc09bf..d79ecaa 100644 (file)
@@ -291,7 +291,7 @@ vl_matrix_filter_render(struct vl_matrix_filter *filter,
    filter->pipe->bind_sampler_states(filter->pipe, PIPE_SHADER_FRAGMENT,
                                      0, 1, &filter->sampler);
    filter->pipe->set_sampler_views(filter->pipe, PIPE_SHADER_FRAGMENT,
-                                   0, 1, &src);
+                                   0, 1, 0, &src);
    filter->pipe->bind_vs_state(filter->pipe, filter->vs);
    filter->pipe->bind_fs_state(filter->pipe, filter->fs);
    filter->pipe->set_framebuffer_state(filter->pipe, &fb_state);
index 414aff9..ff923df 100644 (file)
@@ -618,7 +618,7 @@ vl_mc_render_ref(struct vl_mc *renderer, struct vl_mc_buffer *buffer, struct pip
    renderer->pipe->bind_fs_state(renderer->pipe, renderer->fs_ref);
 
    renderer->pipe->set_sampler_views(renderer->pipe, PIPE_SHADER_FRAGMENT,
-                                     0, 1, &ref);
+                                     0, 1, 0, &ref);
    renderer->pipe->bind_sampler_states(renderer->pipe, PIPE_SHADER_FRAGMENT,
                                        0, 1, &renderer->sampler_ref);
 
index 6b69295..02b205e 100644 (file)
@@ -395,7 +395,7 @@ vl_median_filter_render(struct vl_median_filter *filter,
    filter->pipe->bind_sampler_states(filter->pipe, PIPE_SHADER_FRAGMENT,
                                      0, 1, &filter->sampler);
    filter->pipe->set_sampler_views(filter->pipe, PIPE_SHADER_FRAGMENT,
-                                   0, 1, &src);
+                                   0, 1, 0, &src);
    filter->pipe->bind_vs_state(filter->pipe, filter->vs);
    filter->pipe->bind_fs_state(filter->pipe, filter->fs);
    filter->pipe->set_framebuffer_state(filter->pipe, &fb_state);
index 7a617d3..a406f08 100644 (file)
@@ -830,7 +830,7 @@ vl_mpeg12_end_frame(struct pipe_video_codec *decoder,
             vl_idct_prepare_stage2(i ? &dec->idct_c : &dec->idct_y, &buf->idct[plane]);
          else {
             dec->context->set_sampler_views(dec->context,
-                                            PIPE_SHADER_FRAGMENT, 0, 1,
+                                            PIPE_SHADER_FRAGMENT, 0, 1, 0,
                                             &mc_source_sv[plane]);
             dec->context->bind_sampler_states(dec->context,
                                               PIPE_SHADER_FRAGMENT,
index 82f7a5e..0450126 100644 (file)
@@ -604,7 +604,7 @@ vl_zscan_render(struct vl_zscan *zscan, struct vl_zscan_buffer *buffer, unsigned
    zscan->pipe->set_framebuffer_state(zscan->pipe, &buffer->fb_state);
    zscan->pipe->set_viewport_states(zscan->pipe, 0, 1, &buffer->viewport);
    zscan->pipe->set_sampler_views(zscan->pipe, PIPE_SHADER_FRAGMENT,
-                                  0, 3, &buffer->src);
+                                  0, 3, 0, &buffer->src);
    zscan->pipe->bind_vs_state(zscan->pipe, zscan->vs);
    zscan->pipe->bind_fs_state(zscan->pipe, zscan->fs);
    util_draw_arrays_instanced(zscan->pipe, PIPE_PRIM_QUADS, 0, 4, 0, num_instances);
index e5216e4..0311a6c 100644 (file)
@@ -739,7 +739,7 @@ resolve_stencil_to_temp(struct d3d12_context *ctx,
    void *sampler_state = get_sampler_state(ctx);
 
    util_blit_save_state(ctx);
-   pctx->set_sampler_views(pctx, PIPE_SHADER_FRAGMENT, 0, 1, &src_view);
+   pctx->set_sampler_views(pctx, PIPE_SHADER_FRAGMENT, 0, 1, 0, &src_view);
    pctx->bind_sampler_states(pctx, PIPE_SHADER_FRAGMENT, 0, 1, &sampler_state);
    util_blitter_custom_shader(ctx->blitter, dst_surf,
                               get_stencil_resolve_vs(ctx),
index f288746..3c7ddac 100644 (file)
@@ -924,10 +924,10 @@ d3d12_set_sampler_views(struct pipe_context *pctx,
                         enum pipe_shader_type shader_type,
                         unsigned start_slot,
                         unsigned num_views,
+                        unsigned unbind_num_trailing_slots,
                         struct pipe_sampler_view **views)
 {
    struct d3d12_context *ctx = d3d12_context(pctx);
-   assert(views);
    unsigned shader_bit = (1 << shader_type);
    ctx->has_int_samplers &= ~shader_bit;
 
@@ -964,6 +964,11 @@ d3d12_set_sampler_views(struct pipe_context *pctx,
          swizzle_state.swizzle_a = ss->swizzle_override_a;
       }
    }
+
+   for (unsigned i = 0; i < unbind_num_trailing_slots; i++)
+      pipe_sampler_view_reference(
+         &ctx->sampler_views[shader_type][start_slot + num_views + i], NULL);
+
    ctx->num_sampler_views[shader_type] = start_slot + num_views;
    ctx->shader_dirty[shader_type] |= D3D12_SHADER_DIRTY_SAMPLER_VIEWS;
 }
index ac3f852..add31ff 100644 (file)
@@ -293,6 +293,7 @@ etna_vertex_set_sampler_views(struct etna_context *ctx, unsigned nr,
 static void
 etna_set_sampler_views(struct pipe_context *pctx, enum pipe_shader_type shader,
                        unsigned start_slot, unsigned num_views,
+                       unsigned unbind_num_trailing_slots,
                        struct pipe_sampler_view **views)
 {
    struct etna_context *ctx = etna_context(pctx);
index 57cab74..cc9e4d8 100644 (file)
@@ -212,7 +212,7 @@ fd2_sampler_view_create(struct pipe_context *pctx, struct pipe_resource *prsc,
 
 static void
 fd2_set_sampler_views(struct pipe_context *pctx, enum pipe_shader_type shader,
-               unsigned start, unsigned nr,
+               unsigned start, unsigned nr, unsigned unbind_num_trailing_slots,
                struct pipe_sampler_view **views)
 {
        if (shader == PIPE_SHADER_FRAGMENT) {
@@ -226,7 +226,7 @@ fd2_set_sampler_views(struct pipe_context *pctx, enum pipe_shader_type shader,
                        ctx->dirty |= FD_DIRTY_TEXSTATE;
        }
 
-       fd_set_sampler_views(pctx, shader, start, nr, views);
+       fd_set_sampler_views(pctx, shader, start, nr, unbind_num_trailing_slots, views);
 }
 
 /* map gallium sampler-id to hw const-idx.. adreno uses a flat address
index e1f9f24..16fbb46 100644 (file)
@@ -320,7 +320,7 @@ fd4_sampler_view_create(struct pipe_context *pctx, struct pipe_resource *prsc,
 
 static void
 fd4_set_sampler_views(struct pipe_context *pctx, enum pipe_shader_type shader,
-               unsigned start, unsigned nr,
+               unsigned start, unsigned nr, unsigned unbind_num_trailing_slots,
                struct pipe_sampler_view **views)
 {
        struct fd_context *ctx = fd_context(pctx);
@@ -337,7 +337,7 @@ fd4_set_sampler_views(struct pipe_context *pctx, enum pipe_shader_type shader,
                }
        }
 
-       fd_set_sampler_views(pctx, shader, start, nr, views);
+       fd_set_sampler_views(pctx, shader, start, nr, unbind_num_trailing_slots, views);
 
        if (shader == PIPE_SHADER_FRAGMENT) {
                fd4_ctx->fastc_srgb = astc_srgb;
index 84e66d5..370b9e9 100644 (file)
@@ -319,7 +319,7 @@ fd5_sampler_view_create(struct pipe_context *pctx, struct pipe_resource *prsc,
 
 static void
 fd5_set_sampler_views(struct pipe_context *pctx, enum pipe_shader_type shader,
-               unsigned start, unsigned nr,
+               unsigned start, unsigned nr, unsigned unbind_num_trailing_slots,
                struct pipe_sampler_view **views)
 {
        struct fd_context *ctx = fd_context(pctx);
@@ -336,7 +336,7 @@ fd5_set_sampler_views(struct pipe_context *pctx, enum pipe_shader_type shader,
                }
        }
 
-       fd_set_sampler_views(pctx, shader, start, nr, views);
+       fd_set_sampler_views(pctx, shader, start, nr, unbind_num_trailing_slots, views);
 
        if (shader == PIPE_SHADER_FRAGMENT) {
                fd5_ctx->fastc_srgb = astc_srgb;
index 7ffa5c1..f70c372 100644 (file)
@@ -66,7 +66,9 @@ static void bind_sampler_states(struct fd_texture_stateobj *tex,
 }
 
 static void set_sampler_views(struct fd_texture_stateobj *tex,
-               unsigned start, unsigned nr, struct pipe_sampler_view **views)
+                             unsigned start, unsigned nr,
+                             unsigned unbind_num_trailing_slots,
+                             struct pipe_sampler_view **views)
 {
        unsigned i;
        unsigned samplers = 0;
@@ -82,6 +84,11 @@ static void set_sampler_views(struct fd_texture_stateobj *tex,
                        tex->valid_textures &= ~(1 << p);
                }
        }
+       for (; i < nr + unbind_num_trailing_slots; i++) {
+               unsigned p = i + start;
+               pipe_sampler_view_reference(&tex->textures[p], NULL);
+               tex->valid_textures &= ~(1 << p);
+       }
 
        tex->num_textures = util_last_bit(tex->valid_textures);
 
@@ -107,12 +114,12 @@ fd_sampler_states_bind(struct pipe_context *pctx,
 
 void
 fd_set_sampler_views(struct pipe_context *pctx, enum pipe_shader_type shader,
-               unsigned start, unsigned nr,
+               unsigned start, unsigned nr, unsigned unbind_num_trailing_slots,
                struct pipe_sampler_view **views)
 {
        struct fd_context *ctx = fd_context(pctx);
 
-       set_sampler_views(&ctx->tex[shader], start, nr, views);
+       set_sampler_views(&ctx->tex[shader], start, nr, unbind_num_trailing_slots, views);
        ctx->dirty_shader[shader] |= FD_DIRTY_SHADER_TEX;
        ctx->dirty |= FD_DIRTY_TEX;
 }
index 94fb2e8..f38dd9b 100644 (file)
@@ -36,6 +36,7 @@ void fd_sampler_states_bind(struct pipe_context *pctx,
 void fd_set_sampler_views(struct pipe_context *pctx,
                                                  enum pipe_shader_type shader,
                                                  unsigned start, unsigned nr,
+                                                 unsigned unbind_num_trailing_slots,
                                                  struct pipe_sampler_view **views);
 
 void fd_texture_init(struct pipe_context *pctx);
index f7da9f5..ea26e47 100644 (file)
@@ -746,7 +746,7 @@ static void i915_set_fragment_sampler_views(struct pipe_context *pipe,
    assert(num <= PIPE_MAX_SAMPLERS);
 
    /* Check for no-op */
-   if (num == i915->num_fragment_sampler_views &&
+   if (views && num == i915->num_fragment_sampler_views &&
        !memcmp(i915->fragment_sampler_views, views, num * sizeof(struct pipe_sampler_view *)))
       return;
 
@@ -773,7 +773,7 @@ i915_set_vertex_sampler_views(struct pipe_context *pipe,
    assert(num <= ARRAY_SIZE(i915->vertex_sampler_views));
 
    /* Check for no-op */
-   if (num == i915->num_vertex_sampler_views &&
+   if (views && num == i915->num_vertex_sampler_views &&
        !memcmp(i915->vertex_sampler_views, views, num * sizeof(struct pipe_sampler_view *))) {
       return;
    }
@@ -795,7 +795,7 @@ i915_set_vertex_sampler_views(struct pipe_context *pipe,
 
 static void
 i915_set_sampler_views(struct pipe_context *pipe, enum pipe_shader_type shader,
-                       unsigned start, unsigned num,
+                       unsigned start, unsigned num, unsigned unbind_num_trailing_slots,
                        struct pipe_sampler_view **views)
 {
    assert(start == 0);
index be9862a..510615c 100644 (file)
@@ -2856,15 +2856,17 @@ static void
 iris_set_sampler_views(struct pipe_context *ctx,
                        enum pipe_shader_type p_stage,
                        unsigned start, unsigned count,
+                       unsigned unbind_num_trailing_slots,
                        struct pipe_sampler_view **views)
 {
    struct iris_context *ice = (struct iris_context *) ctx;
    gl_shader_stage stage = stage_from_pipe(p_stage);
    struct iris_shader_state *shs = &ice->state.shaders[stage];
+   unsigned i;
 
    shs->bound_sampler_views &= ~u_bit_consecutive(start, count);
 
-   for (unsigned i = 0; i < count; i++) {
+   for (i = 0; i < count; i++) {
       struct pipe_sampler_view *pview = views ? views[i] : NULL;
       pipe_sampler_view_reference((struct pipe_sampler_view **)
                                   &shs->textures[start + i], pview);
@@ -2879,6 +2881,10 @@ iris_set_sampler_views(struct pipe_context *ctx,
                                     &view->surface_state, view->res->bo);
       }
    }
+   for (; i < count + unbind_num_trailing_slots; i++) {
+      pipe_sampler_view_reference((struct pipe_sampler_view **)
+                                  &shs->textures[start + i], NULL);
+   }
 
    ice->state.stage_dirty |= (IRIS_STAGE_DIRTY_BINDINGS_VS << stage);
    ice->state.dirty |=
index e7d682a..1c8fbf3 100644 (file)
@@ -371,6 +371,7 @@ static void
 lima_set_sampler_views(struct pipe_context *pctx,
                       enum pipe_shader_type shader,
                       unsigned start, unsigned nr,
+                       unsigned unbind_num_trailing_slots,
                       struct pipe_sampler_view **views)
 {
    struct lima_context *ctx = lima_context(pctx);
index 4f8217b..613e528 100644 (file)
@@ -119,6 +119,7 @@ llvmpipe_set_sampler_views(struct pipe_context *pipe,
                            enum pipe_shader_type shader,
                            unsigned start,
                            unsigned num,
+                           unsigned unbind_num_trailing_slots,
                            struct pipe_sampler_view **views)
 {
    struct llvmpipe_context *llvmpipe = llvmpipe_context(pipe);
@@ -153,6 +154,11 @@ llvmpipe_set_sampler_views(struct pipe_context *pipe,
                                   view);
    }
 
+   for (; i < num + unbind_num_trailing_slots; i++) {
+      pipe_sampler_view_reference(&llvmpipe->sampler_views[shader][start + i],
+                                  NULL);
+   }
+
    /* find highest non-null sampler_views[] entry */
    {
       unsigned j = MAX2(llvmpipe->num_sampler_views[shader], start + num);
index a6bfee6..bfd3cf2 100644 (file)
@@ -198,6 +198,7 @@ nv30_fragtex_set_sampler_views(struct pipe_context *pipe, unsigned nr,
 static void
 nv30_set_sampler_views(struct pipe_context *pipe, enum pipe_shader_type shader,
                        unsigned start, unsigned nr,
+                       unsigned unbind_num_trailing_slots,
                        struct pipe_sampler_view **views)
 {
    assert(start == 0);
index f3d67bd..e40ab1b 100644 (file)
@@ -725,6 +725,7 @@ nv50_stage_set_sampler_views(struct nv50_context *nv50, int s,
 static void
 nv50_set_sampler_views(struct pipe_context *pipe, enum pipe_shader_type shader,
                        unsigned start, unsigned nr,
+                       unsigned unbind_num_trailing_slots,
                        struct pipe_sampler_view **views)
 {
    assert(start == 0);
index 02942d5..ade5880 100644 (file)
@@ -569,6 +569,7 @@ nvc0_stage_set_sampler_views(struct nvc0_context *nvc0, int s,
 static void
 nvc0_set_sampler_views(struct pipe_context *pipe, enum pipe_shader_type shader,
                        unsigned start, unsigned nr,
+                       unsigned unbind_num_trailing_slots,
                        struct pipe_sampler_view **views)
 {
    const unsigned s = nvc0_shader_stage(shader);
index 1600e26..396ce1c 100644 (file)
@@ -1185,6 +1185,7 @@ panfrost_set_sampler_views(
         struct pipe_context *pctx,
         enum pipe_shader_type shader,
         unsigned start_slot, unsigned num_views,
+        unsigned unbind_num_trailing_slots,
         struct pipe_sampler_view **views)
 {
         struct panfrost_context *ctx = pan_context(pctx);
index 9049c30..1caf3e3 100644 (file)
@@ -1518,6 +1518,7 @@ static uint32_t r300_assign_texture_cache_region(unsigned index, unsigned num)
 static void r300_set_sampler_views(struct pipe_context* pipe,
                                    enum pipe_shader_type shader,
                                    unsigned start, unsigned count,
+                                   unsigned unbind_num_trailing_slots,
                                    struct pipe_sampler_view** views)
 {
     struct r300_context* r300 = r300_context(pipe);
index ce4e784..d787be3 100644 (file)
@@ -632,6 +632,7 @@ void r600_sampler_views_dirty(struct r600_context *rctx,
 static void r600_set_sampler_views(struct pipe_context *pipe,
                                   enum pipe_shader_type shader,
                                   unsigned start, unsigned count,
+                                  unsigned unbind_num_trailing_slots,
                                   struct pipe_sampler_view **views)
 {
        struct r600_context *rctx = (struct r600_context *) pipe;
index 6139769..426591c 100644 (file)
@@ -573,12 +573,14 @@ static void si_update_shader_needs_decompress_mask(struct si_context *sctx, unsi
 }
 
 static void si_set_sampler_views(struct pipe_context *ctx, enum pipe_shader_type shader,
-                                 unsigned start, unsigned count, struct pipe_sampler_view **views)
+                                 unsigned start, unsigned count,
+                                 unsigned unbind_num_trailing_slots,
+                                 struct pipe_sampler_view **views)
 {
    struct si_context *sctx = (struct si_context *)ctx;
    int i;
 
-   if (!count || shader >= SI_NUM_SHADERS)
+   if ((!count && !unbind_num_trailing_slots) || shader >= SI_NUM_SHADERS)
       return;
 
    if (views) {
@@ -589,6 +591,9 @@ static void si_set_sampler_views(struct pipe_context *ctx, enum pipe_shader_type
          si_set_sampler_view(sctx, shader, start + i, NULL, false);
    }
 
+   for (; i < count + unbind_num_trailing_slots; i++)
+      si_set_sampler_view(sctx, shader, start + i, NULL, false);
+
    si_update_shader_needs_decompress_mask(sctx, shader);
 }
 
index a9ae401..3971bbf 100644 (file)
@@ -175,6 +175,7 @@ softpipe_set_sampler_views(struct pipe_context *pipe,
                            enum pipe_shader_type shader,
                            unsigned start,
                            unsigned num,
+                           unsigned unbind_num_trailing_slots,
                            struct pipe_sampler_view **views);
 
 
index b4f87e0..d120abf 100644 (file)
@@ -420,7 +420,7 @@ update_polygon_stipple_enable(struct softpipe_context *softpipe, unsigned prim)
 
       /* sampler view state */
       softpipe_set_sampler_views(&softpipe->pipe, PIPE_SHADER_FRAGMENT,
-                                 unit, 1, &softpipe->pstipple.sampler_view);
+                                 unit, 1, 0, &softpipe->pstipple.sampler_view);
 
       softpipe->dirty |= SP_NEW_SAMPLER;
    }
index 70d34ed..b6a97c1 100644 (file)
@@ -100,6 +100,7 @@ softpipe_set_sampler_views(struct pipe_context *pipe,
                            enum pipe_shader_type shader,
                            unsigned start,
                            unsigned num,
+                           unsigned unbind_num_trailing_slots,
                            struct pipe_sampler_view **views)
 {
    struct softpipe_context *softpipe = softpipe_context(pipe);
@@ -134,6 +135,12 @@ softpipe_set_sampler_views(struct pipe_context *pipe,
          memset(sp_sviewdst, 0,  sizeof(*sp_sviewsrc));
       }
    }
+   for (; i < num + unbind_num_trailing_slots; i++) {
+      struct pipe_sampler_view **pview = &softpipe->sampler_views[shader][start + i];
+      pipe_sampler_view_reference(pview, NULL);
+      sp_tex_tile_cache_set_sampler_view(softpipe->tex_cache[shader][start + i],
+                                         NULL);
+   }
 
 
    /* find highest non-null sampler_views[] entry */
index d73a581..eb23b7b 100644 (file)
@@ -414,6 +414,7 @@ svga_set_sampler_views(struct pipe_context *pipe,
                        enum pipe_shader_type shader,
                        unsigned start,
                        unsigned num,
+                       unsigned unbind_num_trailing_slots,
                        struct pipe_sampler_view **views)
 {
    struct svga_context *svga = svga_context(pipe);
@@ -475,6 +476,14 @@ svga_set_sampler_views(struct pipe_context *pipe,
       }
    }
 
+   for (; i < num + unbind_num_trailing_slots; i++) {
+      if (svga->curr.sampler_views[shader][start + i]) {
+         pipe_sampler_view_reference(&svga->curr.sampler_views[shader][start + i],
+                                     NULL);
+         any_change = TRUE;
+      }
+   }
+
    if (!any_change) {
       goto done;
    }
index 3089baf..bde7f35 100644 (file)
@@ -300,6 +300,7 @@ swr_set_sampler_views(struct pipe_context *pipe,
                       enum pipe_shader_type shader,
                       unsigned start,
                       unsigned num,
+                      unsigned unbind_num_trailing_slots,
                       struct pipe_sampler_view **views)
 {
    struct swr_context *ctx = swr_context(pipe);
@@ -316,6 +317,10 @@ swr_set_sampler_views(struct pipe_context *pipe,
       pipe_sampler_view_reference(&ctx->sampler_views[shader][start + i],
                                   views[i]);
    }
+   for (; i < num + unbind_num_trailing_slots; i++) {
+      pipe_sampler_view_reference(&ctx->sampler_views[shader][start + i],
+                                  NULL);
+   }
 
    ctx->dirty |= SWR_NEW_SAMPLER_VIEW;
 }
index aca2568..bda565b 100644 (file)
@@ -564,6 +564,7 @@ tegra_set_viewport_states(struct pipe_context *pcontext, unsigned start_slot,
 static void
 tegra_set_sampler_views(struct pipe_context *pcontext, unsigned shader,
                         unsigned start_slot, unsigned num_views,
+                        unsigned unbind_num_trailing_slots,
                         struct pipe_sampler_view **pviews)
 {
    struct pipe_sampler_view *views[PIPE_MAX_SHADER_SAMPLER_VIEWS];
@@ -574,7 +575,8 @@ tegra_set_sampler_views(struct pipe_context *pcontext, unsigned shader,
       views[i] = tegra_sampler_view_unwrap(pviews[i]);
 
    context->gpu->set_sampler_views(context->gpu, shader, start_slot,
-                                   num_views, views);
+                                   num_views, unbind_num_trailing_slots,
+                                   views);
 }
 
 static void
index 86fe97d..1074ef5 100644 (file)
@@ -1156,6 +1156,7 @@ static void
 v3d_set_sampler_views(struct pipe_context *pctx,
                       enum pipe_shader_type shader,
                       unsigned start, unsigned nr,
+                      unsigned unbind_num_trailing_slots,
                       struct pipe_sampler_view **views)
 {
         struct v3d_context *v3d = v3d_context(pctx);
index 87de661..5e50559 100644 (file)
@@ -381,7 +381,7 @@ vc4_yuv_blit(struct pipe_context *pctx, const struct pipe_blit_info *info)
         /* Unbind the textures, to make sure we don't try to recurse into the
          * shadow blit.
          */
-        pctx->set_sampler_views(pctx, PIPE_SHADER_FRAGMENT, 0, 0, NULL);
+        pctx->set_sampler_views(pctx, PIPE_SHADER_FRAGMENT, 0, 0, 0, NULL);
         pctx->bind_sampler_states(pctx, PIPE_SHADER_FRAGMENT, 0, 0, NULL);
 
         util_blitter_custom_shader(vc4->blitter, dst_surf,
index 3c17418..4e4cff1 100644 (file)
@@ -649,6 +649,7 @@ static void
 vc4_set_sampler_views(struct pipe_context *pctx,
                       enum pipe_shader_type shader,
                       unsigned start, unsigned nr,
+                      unsigned unbind_num_trailing_slots,
                       struct pipe_sampler_view **views)
 {
         struct vc4_context *vc4 = vc4_context(pctx);
index 2e42f1b..0db8232 100644 (file)
@@ -1015,6 +1015,7 @@ static void virgl_set_sampler_views(struct pipe_context *ctx,
                                    enum pipe_shader_type shader_type,
                                    unsigned start_slot,
                                    unsigned num_views,
+                                   unsigned unbind_num_trailing_slots,
                                    struct pipe_sampler_view **views)
 {
    struct virgl_context *vctx = virgl_context(ctx);
@@ -1038,6 +1039,11 @@ static void virgl_set_sampler_views(struct pipe_context *ctx,
    virgl_encode_set_sampler_views(vctx, shader_type,
          start_slot, num_views, (struct virgl_sampler_view **)binding->views);
    virgl_attach_res_sampler_views(vctx, shader_type);
+
+   if (unbind_num_trailing_slots) {
+      virgl_set_sampler_views(ctx, shader_type, start_slot + num_views,
+                              unbind_num_trailing_slots, 0, NULL);
+   }
 }
 
 static void
index eec6f16..bfd3bf3 100644 (file)
@@ -674,15 +674,23 @@ zink_set_sampler_views(struct pipe_context *pctx,
                        enum pipe_shader_type shader_type,
                        unsigned start_slot,
                        unsigned num_views,
+                       unsigned unbind_num_trailing_slots,
                        struct pipe_sampler_view **views)
 {
    struct zink_context *ctx = zink_context(pctx);
-   for (unsigned i = 0; i < num_views; ++i) {
+   unsigned i;
+
+   for (i = 0; i < num_views; ++i) {
       struct pipe_sampler_view *pview = views ? views[i] : NULL;
       pipe_sampler_view_reference(
          &ctx->sampler_views[shader_type][start_slot + i],
          pview);
    }
+   for (; i < num_views + unbind_num_trailing_slots; ++i) {
+      pipe_sampler_view_reference(
+         &ctx->sampler_views[shader_type][start_slot + i],
+         NULL);
+   }
    ctx->num_sampler_views[shader_type] = start_slot + num_views;
 }
 
index fad6b75..1629e34 100644 (file)
@@ -82,7 +82,7 @@ kernel::launch(command_queue &q,
                                exec.samplers.data());
 
    q.pipe->set_sampler_views(q.pipe, PIPE_SHADER_COMPUTE, 0,
-                             exec.sviews.size(), exec.sviews.data());
+                             exec.sviews.size(), 0, exec.sviews.data());
    q.pipe->set_shader_images(q.pipe, PIPE_SHADER_COMPUTE, 0,
                              exec.iviews.size(), 0, exec.iviews.data());
    q.pipe->set_compute_resources(q.pipe, 0, exec.resources.size(),
@@ -104,7 +104,7 @@ kernel::launch(command_queue &q,
    q.pipe->set_shader_images(q.pipe, PIPE_SHADER_COMPUTE, 0,
                              0, exec.iviews.size(), NULL);
    q.pipe->set_sampler_views(q.pipe, PIPE_SHADER_COMPUTE, 0,
-                             exec.sviews.size(), NULL);
+                             0, exec.sviews.size(), NULL);
    q.pipe->bind_sampler_states(q.pipe, PIPE_SHADER_COMPUTE, 0,
                                exec.samplers.size(), NULL);
 
index be624c9..ae1b169 100644 (file)
@@ -162,7 +162,7 @@ static void emit_compute_state(struct rendering_state *state)
 
    if (state->sv_dirty[PIPE_SHADER_COMPUTE]) {
       state->pctx->set_sampler_views(state->pctx, PIPE_SHADER_COMPUTE, 0, state->num_sampler_views[PIPE_SHADER_COMPUTE],
-                                     state->sv[PIPE_SHADER_COMPUTE]);
+                                     0, state->sv[PIPE_SHADER_COMPUTE]);
       state->sv_dirty[PIPE_SHADER_COMPUTE] = false;
    }
 
@@ -292,7 +292,7 @@ static void emit_state(struct rendering_state *state)
          continue;
 
       state->pctx->set_sampler_views(state->pctx, sh, 0, state->num_sampler_views[sh],
-                                     state->sv[sh]);
+                                     0, state->sv[sh]);
       state->sv_dirty[sh] = false;
    }
 
index 3d0461d..85bc920 100644 (file)
@@ -1013,7 +1013,7 @@ update_textures_and_samplers(struct NineDevice9 *device)
         context->bound_samplers_mask_ps |= (1 << s);
     }
 
-    pipe->set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0, num_textures, view);
+    pipe->set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0, num_textures, 0, view);
 
     if (commit_samplers)
         cso_single_sampler_done(context->cso, PIPE_SHADER_FRAGMENT);
@@ -1061,7 +1061,7 @@ update_textures_and_samplers(struct NineDevice9 *device)
         context->bound_samplers_mask_vs |= (1 << i);
     }
 
-    pipe->set_sampler_views(pipe, PIPE_SHADER_VERTEX, 0, num_textures, view);
+    pipe->set_sampler_views(pipe, PIPE_SHADER_VERTEX, 0, num_textures, 0, view);
 
     if (commit_samplers)
         cso_single_sampler_done(context->cso, PIPE_SHADER_VERTEX);
@@ -2913,8 +2913,8 @@ nine_context_clear(struct NineDevice9 *device)
     cso_set_samplers(cso, PIPE_SHADER_VERTEX, 0, NULL);
     cso_set_samplers(cso, PIPE_SHADER_FRAGMENT, 0, NULL);
 
-    pipe->set_sampler_views(pipe, PIPE_SHADER_VERTEX, 0, NINE_MAX_SAMPLERS_VS, NULL);
-    pipe->set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0, NINE_MAX_SAMPLERS_PS, NULL);
+    pipe->set_sampler_views(pipe, PIPE_SHADER_VERTEX, 0, 0, NINE_MAX_SAMPLERS_VS, NULL);
+    pipe->set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0, 0, NINE_MAX_SAMPLERS_PS, NULL);
 
     pipe->set_vertex_buffers(pipe, 0, 0, device->caps.MaxStreams, NULL);
 
index 45bc031..c0d8085 100644 (file)
@@ -504,7 +504,7 @@ bind_samplers(struct xa_context *ctx,
 
     cso_set_samplers(ctx->cso, PIPE_SHADER_FRAGMENT, num_samplers,
                     (const struct pipe_sampler_state **)samplers);
-    pipe->set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0, num_samplers,
+    pipe->set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0, num_samplers, 0,
                             ctx->bound_sampler_views);
     ctx->num_bound_samplers = num_samplers;
 }
index dc9586d..4307e3f 100644 (file)
@@ -327,7 +327,7 @@ xa_solid_prepare(struct xa_context *ctx, struct xa_surface *dst,
     renderer_bind_destination(ctx, ctx->srf);
     bind_solid_blend_state(ctx);
     cso_set_samplers(ctx->cso, PIPE_SHADER_FRAGMENT, 0, NULL);
-    ctx->pipe->set_sampler_views(ctx->pipe, PIPE_SHADER_FRAGMENT, 0, XA_MAX_SAMPLERS, NULL);
+    ctx->pipe->set_sampler_views(ctx->pipe, PIPE_SHADER_FRAGMENT, 0, 0, XA_MAX_SAMPLERS, NULL);
 
     shader = xa_shaders_get(ctx->shaders, vs_traits, fs_traits);
     cso_set_vertex_shader_handle(ctx->cso, shader.vs);
index 91d129b..7b7fdce 100644 (file)
@@ -442,7 +442,7 @@ renderer_copy_prepare(struct xa_context *r,
        u_sampler_view_default_template(&templ,
                                        src_texture, src_texture->format);
        src_view = pipe->create_sampler_view(pipe, src_texture, &templ);
-       pipe->set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0, 1, &src_view);
+       pipe->set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0, 1, 0, &src_view);
        pipe_sampler_view_reference(&src_view, NULL);
     }
 
index ce49aa2..58d43b6 100644 (file)
@@ -93,7 +93,7 @@ xa_yuv_bind_samplers(struct xa_context *r, struct xa_surface *yuv[])
     }
     r->num_bound_samplers = 3;
     cso_set_samplers(r->cso, PIPE_SHADER_FRAGMENT, 3, (const struct pipe_sampler_state **)samplers);
-    r->pipe->set_sampler_views(r->pipe, PIPE_SHADER_FRAGMENT, 0, 3, r->bound_sampler_views);
+    r->pipe->set_sampler_views(r->pipe, PIPE_SHADER_FRAGMENT, 0, 3, 0, r->bound_sampler_views);
 }
 
 static void
index 1f653e1..d99aa16 100644 (file)
@@ -443,6 +443,7 @@ struct pipe_context {
    void (*set_sampler_views)(struct pipe_context *,
                              enum pipe_shader_type shader,
                              unsigned start_slot, unsigned num_views,
+                             unsigned unbind_num_trailing_slots,
                              struct pipe_sampler_view **views);
 
    void (*set_tess_state)(struct pipe_context *,
index 92b233b..5d71772 100644 (file)
@@ -350,7 +350,7 @@ static void init_tex( void )
    if (sv == NULL)
       exit(5);
 
-   ctx->set_sampler_views(ctx, PIPE_SHADER_FRAGMENT, 0, 1, &sv);
+   ctx->set_sampler_views(ctx, PIPE_SHADER_FRAGMENT, 0, 1, 0, &sv);
    
 
    memset(&sampler_desc, 0, sizeof sampler_desc);
index 2e74dbe..c172686 100644 (file)
@@ -440,7 +440,7 @@ static void init_tex( void )
    if (sv == NULL)
       exit(5);
 
-   ctx->set_sampler_views(ctx, PIPE_SHADER_FRAGMENT, 0, 1, &sv);
+   ctx->set_sampler_views(ctx, PIPE_SHADER_FRAGMENT, 0, 1, 0, &sv);
    
 
    memset(&sampler_desc, 0, sizeof sampler_desc);
index 711f04e..b64827e 100644 (file)
@@ -265,7 +265,7 @@ static void init_tex( void )
    if (sv == NULL)
       exit(5);
 
-   ctx->set_sampler_views(ctx, PIPE_SHADER_FRAGMENT, 0, 1, &sv);
+   ctx->set_sampler_views(ctx, PIPE_SHADER_FRAGMENT, 0, 1, 0, &sv);
    
 
    memset(&sampler_desc, 0, sizeof sampler_desc);
index 474344f..481c371 100644 (file)
@@ -168,7 +168,7 @@ static void init_tex( void )
                                     PIPE_FORMAT_B8G8R8A8_UNORM, tex2d);
 
    sv = graw_util_create_simple_sampler_view(&info, texture);
-   info.ctx->set_sampler_views(info.ctx, PIPE_SHADER_FRAGMENT, 0, 1, &sv);
+   info.ctx->set_sampler_views(info.ctx, PIPE_SHADER_FRAGMENT, 0, 1, 0, &sv);
 
    sampler = graw_util_create_simple_sampler(&info, 
                                              PIPE_TEX_WRAP_REPEAT,
index baa4876..da4e40b 100644 (file)
@@ -129,11 +129,11 @@ static void draw( void )
 
    info.ctx->clear(info.ctx, PIPE_CLEAR_COLOR, NULL, &clear_color, 0, 0);
 
-   info.ctx->set_sampler_views(info.ctx, PIPE_SHADER_FRAGMENT, 0, 1, &linear_sv);
+   info.ctx->set_sampler_views(info.ctx, PIPE_SHADER_FRAGMENT, 0, 1, 0, &linear_sv);
    set_vertices(vertices1, 4);
    util_draw_arrays(info.ctx, PIPE_PRIM_QUADS, 0, 4);
 
-   info.ctx->set_sampler_views(info.ctx, PIPE_SHADER_FRAGMENT, 0, 1, &srgb_sv);
+   info.ctx->set_sampler_views(info.ctx, PIPE_SHADER_FRAGMENT, 0, 1, 0, &srgb_sv);
    set_vertices(vertices2, 4);
    util_draw_arrays(info.ctx, PIPE_PRIM_QUADS, 0, 4);
 
index f21c76a..c867c15 100644 (file)
@@ -147,7 +147,7 @@ init_tex(const unsigned swizzle[4])
    if (sv == NULL)
       exit(5);
 
-   info.ctx->set_sampler_views(info.ctx, PIPE_SHADER_FRAGMENT, 0, 1, &sv);
+   info.ctx->set_sampler_views(info.ctx, PIPE_SHADER_FRAGMENT, 0, 1, 0, &sv);
 
    sampler = graw_util_create_simple_sampler(&info,
                                              PIPE_TEX_WRAP_REPEAT,
index 969ffe7..9423803 100644 (file)
@@ -338,7 +338,7 @@ static void init_tex( void )
    if (sv == NULL)
       exit(5);
 
-   ctx->set_sampler_views(ctx, PIPE_SHADER_FRAGMENT, 0, 1, &sv);
+   ctx->set_sampler_views(ctx, PIPE_SHADER_FRAGMENT, 0, 1, 0, &sv);
    
 
    memset(&sampler_desc, 0, sizeof sampler_desc);
index 94599e9..a1ca7f3 100644 (file)
@@ -315,7 +315,7 @@ static void init_sampler_views(struct context *ctx, const int *slots)
                 assert(ctx->view[i]);
         }
 
-        pipe->set_sampler_views(pipe, PIPE_SHADER_COMPUTE, 0, i, ctx->view);
+        pipe->set_sampler_views(pipe, PIPE_SHADER_COMPUTE, 0, i, 0, ctx->view);
 }
 
 static void destroy_sampler_views(struct context *ctx)
@@ -323,7 +323,7 @@ static void destroy_sampler_views(struct context *ctx)
         struct pipe_context *pipe = ctx->pipe;
         int i;
 
-        pipe->set_sampler_views(pipe, PIPE_SHADER_COMPUTE, 0, MAX_RESOURCES, NULL);
+        pipe->set_sampler_views(pipe, PIPE_SHADER_COMPUTE, 0, 0, MAX_RESOURCES, NULL);
 
         for (i = 0; i < MAX_RESOURCES; ++i) {
                 if (ctx->view[i]) {
index cc4e011..563e4f3 100644 (file)
@@ -322,7 +322,7 @@ static void draw(struct program *p)
        cso_set_samplers(p->cso, PIPE_SHADER_FRAGMENT, 1, samplers);
 
        /* texture sampler view */
-       p->pipe->set_sampler_views(p->pipe, PIPE_SHADER_FRAGMENT, 0, 1, &p->view);
+       p->pipe->set_sampler_views(p->pipe, PIPE_SHADER_FRAGMENT, 0, 1, 0, &p->view);
 
        /* shaders */
        cso_set_fragment_shader_handle(p->cso, p->fs);
index 2c8cf56..117c5b5 100644 (file)
@@ -252,7 +252,7 @@ update_textures(struct st_context *st,
    for (unsigned i = 0; i < num_unbind; i++)
       pipe_sampler_view_reference(&sampler_views[num_textures + i], NULL);
 
-   pipe->set_sampler_views(pipe, shader_stage, 0, num_textures + num_unbind,
+   pipe->set_sampler_views(pipe, shader_stage, 0, num_textures, num_unbind,
                            sampler_views);
    st->state.num_sampler_views[shader_stage] = num_textures;
 }
index 63d8ac8..92d3aef 100644 (file)
@@ -247,7 +247,8 @@ setup_render_state(struct gl_context *ctx,
       memcpy(sampler_views, st->state.frag_sampler_views,
              sizeof(sampler_views));
       sampler_views[fpv->bitmap_sampler] = sv;
-      pipe->set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0, num, sampler_views);
+      pipe->set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0, num, 0,
+                              sampler_views);
       st->state.num_sampler_views[PIPE_SHADER_FRAGMENT] =
          MAX2(st->state.num_sampler_views[PIPE_SHADER_FRAGMENT], num);
    }
@@ -279,10 +280,9 @@ restore_render_state(struct gl_context *ctx)
    /* Unbind all because st/mesa won't do it if the current shader doesn't
     * use them.
     */
-   static struct pipe_sampler_view *null[PIPE_MAX_SAMPLERS];
-   pipe->set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0,
+   pipe->set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0, 0,
                            st->state.num_sampler_views[PIPE_SHADER_FRAGMENT],
-                           null);
+                           NULL);
    st->state.num_sampler_views[PIPE_SHADER_FRAGMENT] = 0;
 
    st->dirty |= ST_NEW_VERTEX_ARRAYS |
index 602b470..90619c9 100644 (file)
@@ -881,12 +881,14 @@ draw_textured_quad(struct gl_context *ctx, GLint x, GLint y, GLfloat z,
       sampler_views[fpv->drawpix_sampler] = sv[0];
       if (sv[1])
          sampler_views[fpv->pixelmap_sampler] = sv[1];
-      pipe->set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0, num, sampler_views);
+      pipe->set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0, num, 0,
+                              sampler_views);
       st->state.num_sampler_views[PIPE_SHADER_FRAGMENT] =
          MAX2(st->state.num_sampler_views[PIPE_SHADER_FRAGMENT], num);
    } else {
       /* drawing a depth/stencil image */
-      pipe->set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0, num_sampler_view, sv);
+      pipe->set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0, num_sampler_view,
+                              0, sv);
       st->state.num_sampler_views[PIPE_SHADER_FRAGMENT] =
          MAX2(st->state.num_sampler_views[PIPE_SHADER_FRAGMENT], num_sampler_view);
    }
@@ -940,10 +942,9 @@ draw_textured_quad(struct gl_context *ctx, GLint x, GLint y, GLfloat z,
    /* Unbind all because st/mesa won't do it if the current shader doesn't
     * use them.
     */
-   static struct pipe_sampler_view *null[PIPE_MAX_SAMPLERS];
-   pipe->set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0,
+   pipe->set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0, 0,
                            st->state.num_sampler_views[PIPE_SHADER_FRAGMENT],
-                           null);
+                           NULL);
    st->state.num_sampler_views[PIPE_SHADER_FRAGMENT] = 0;
 
    st->dirty |= ST_NEW_VERTEX_ARRAYS |
index 44bc91f..3811f6e 100644 (file)
@@ -189,7 +189,8 @@ try_pbo_readpixels(struct st_context *st, struct st_renderbuffer *strb,
       if (sampler_view == NULL)
          goto fail;
 
-      pipe->set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0, 1, &sampler_view);
+      pipe->set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0, 1, 0,
+                              &sampler_view);
       st->state.num_sampler_views[PIPE_SHADER_FRAGMENT] =
          MAX2(st->state.num_sampler_views[PIPE_SHADER_FRAGMENT], 1);
 
@@ -258,10 +259,9 @@ fail:
    /* Unbind all because st/mesa won't do it if the current shader doesn't
     * use them.
     */
-   static struct pipe_sampler_view *null[PIPE_MAX_SAMPLERS];
-   pipe->set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0,
+   pipe->set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0, 0,
                            st->state.num_sampler_views[PIPE_SHADER_FRAGMENT],
-                           null);
+                           NULL);
    st->state.num_sampler_views[PIPE_SHADER_FRAGMENT] = 0;
    pipe->set_shader_images(pipe, PIPE_SHADER_FRAGMENT, 0, 0, 1, NULL);
 
index f20afba..67c1dc7 100644 (file)
@@ -1312,7 +1312,8 @@ try_pbo_upload_common(struct gl_context *ctx,
       if (sampler_view == NULL)
          goto fail;
 
-      pipe->set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0, 1, &sampler_view);
+      pipe->set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0, 1, 0,
+                              &sampler_view);
       st->state.num_sampler_views[PIPE_SHADER_FRAGMENT] =
          MAX2(st->state.num_sampler_views[PIPE_SHADER_FRAGMENT], 1);
 
@@ -1354,10 +1355,9 @@ fail:
    /* Unbind all because st/mesa won't do it if the current shader doesn't
     * use them.
     */
-   static struct pipe_sampler_view *null[PIPE_MAX_SAMPLERS];
-   pipe->set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0,
+   pipe->set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0, 0,
                            st->state.num_sampler_views[PIPE_SHADER_FRAGMENT],
-                           null);
+                           NULL);
    st->state.num_sampler_views[PIPE_SHADER_FRAGMENT] = 0;
 
    st->dirty |= ST_NEW_VERTEX_ARRAYS |