Mesa (main): st/mesa: set take_ownership = true in set_sampler_views

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Aug 20 15:52:33 UTC 2021


Module: Mesa
Branch: main
Commit: feda6e9c5d101c9a5654a026090e2f8a11980e91
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=feda6e9c5d101c9a5654a026090e2f8a11980e91

Author: Marek Olšák <marek.olsak at amd.com>
Date:   Sun Jun  6 02:28:14 2021 -0400

st/mesa: set take_ownership = true in set_sampler_views

update_textures_local is removed because the only thing it did was
unreferencing sampler views, which is being removed.

Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz at gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12334>

---

 src/mesa/state_tracker/st_atom_texture.c  | 36 ++++++++++---------------------
 src/mesa/state_tracker/st_cb_bitmap.c     |  5 +----
 src/mesa/state_tracker/st_cb_drawpixels.c |  5 +----
 3 files changed, 13 insertions(+), 33 deletions(-)

diff --git a/src/mesa/state_tracker/st_atom_texture.c b/src/mesa/state_tracker/st_atom_texture.c
index c6082c06a6f..1787596ee14 100644
--- a/src/mesa/state_tracker/st_atom_texture.c
+++ b/src/mesa/state_tracker/st_atom_texture.c
@@ -257,10 +257,11 @@ st_get_sampler_views(struct st_context *st,
 }
 
 static void
-update_textures(struct st_context *st, enum  pipe_shader_type shader_stage,
-                const struct gl_program *prog,
-                struct pipe_sampler_view **sampler_views)
+update_textures(struct st_context *st,
+                enum pipe_shader_type shader_stage,
+                const struct gl_program *prog)
 {
+   struct pipe_sampler_view *sampler_views[PIPE_MAX_SAMPLERS];
    struct pipe_context *pipe = st->pipe;
    unsigned num_textures =
       st_get_sampler_views(st, shader_stage, prog, sampler_views);
@@ -270,32 +271,17 @@ update_textures(struct st_context *st, enum  pipe_shader_type shader_stage,
                             old_num_textures - num_textures : 0;
 
    pipe->set_sampler_views(pipe, shader_stage, 0, num_textures, num_unbind,
-                           false, sampler_views);
+                           true, sampler_views);
    st->state.num_sampler_views[shader_stage] = num_textures;
 }
 
-/* Same as update_textures, but don't store the views in st_context. */
-static void
-update_textures_local(struct st_context *st,
-                      enum pipe_shader_type shader_stage,
-                      const struct gl_program *prog)
-{
-   struct pipe_sampler_view *local_views[PIPE_MAX_SAMPLERS];
-
-   update_textures(st, shader_stage, prog, local_views);
-
-   unsigned num = st->state.num_sampler_views[shader_stage];
-   for (unsigned i = 0; i < num; i++)
-      pipe_sampler_view_reference(&local_views[i], NULL);
-}
-
 void
 st_update_vertex_textures(struct st_context *st)
 {
    const struct gl_context *ctx = st->ctx;
 
    if (ctx->Const.Program[MESA_SHADER_VERTEX].MaxTextureImageUnits > 0) {
-      update_textures_local(st, PIPE_SHADER_VERTEX,
+      update_textures(st, PIPE_SHADER_VERTEX,
                             ctx->VertexProgram._Current);
    }
 }
@@ -306,7 +292,7 @@ st_update_fragment_textures(struct st_context *st)
 {
    const struct gl_context *ctx = st->ctx;
 
-   update_textures_local(st, PIPE_SHADER_FRAGMENT,
+   update_textures(st, PIPE_SHADER_FRAGMENT,
                          ctx->FragmentProgram._Current);
 }
 
@@ -317,7 +303,7 @@ st_update_geometry_textures(struct st_context *st)
    const struct gl_context *ctx = st->ctx;
 
    if (ctx->GeometryProgram._Current) {
-      update_textures_local(st, PIPE_SHADER_GEOMETRY,
+      update_textures(st, PIPE_SHADER_GEOMETRY,
                             ctx->GeometryProgram._Current);
    }
 }
@@ -329,7 +315,7 @@ st_update_tessctrl_textures(struct st_context *st)
    const struct gl_context *ctx = st->ctx;
 
    if (ctx->TessCtrlProgram._Current) {
-      update_textures_local(st, PIPE_SHADER_TESS_CTRL,
+      update_textures(st, PIPE_SHADER_TESS_CTRL,
                             ctx->TessCtrlProgram._Current);
    }
 }
@@ -341,7 +327,7 @@ st_update_tesseval_textures(struct st_context *st)
    const struct gl_context *ctx = st->ctx;
 
    if (ctx->TessEvalProgram._Current) {
-      update_textures_local(st, PIPE_SHADER_TESS_EVAL,
+      update_textures(st, PIPE_SHADER_TESS_EVAL,
                             ctx->TessEvalProgram._Current);
    }
 }
@@ -353,7 +339,7 @@ st_update_compute_textures(struct st_context *st)
    const struct gl_context *ctx = st->ctx;
 
    if (ctx->ComputeProgram._Current) {
-      update_textures_local(st, PIPE_SHADER_COMPUTE,
+      update_textures(st, PIPE_SHADER_COMPUTE,
                             ctx->ComputeProgram._Current);
    }
 }
diff --git a/src/mesa/state_tracker/st_cb_bitmap.c b/src/mesa/state_tracker/st_cb_bitmap.c
index d1942ca3707..0164ca7d9b6 100644
--- a/src/mesa/state_tracker/st_cb_bitmap.c
+++ b/src/mesa/state_tracker/st_cb_bitmap.c
@@ -249,11 +249,8 @@ setup_render_state(struct gl_context *ctx,
       num_views = MAX2(fpv->bitmap_sampler + 1, num_views);
       sampler_views[fpv->bitmap_sampler] = sv;
       pipe->set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0, num_views, 0,
-                              false, sampler_views);
+                              true, sampler_views);
       st->state.num_sampler_views[PIPE_SHADER_FRAGMENT] = num_views;
-
-      for (unsigned i = 0; i < num_views; i++)
-         pipe_sampler_view_reference(&sampler_views[i], NULL);
    }
 
    /* viewport state: viewport matching window dims */
diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c
index 3a7e240f387..c64381aafe7 100644
--- a/src/mesa/state_tracker/st_cb_drawpixels.c
+++ b/src/mesa/state_tracker/st_cb_drawpixels.c
@@ -885,11 +885,8 @@ draw_textured_quad(struct gl_context *ctx, GLint x, GLint y, GLfloat z,
       if (sv[1])
          sampler_views[fpv->pixelmap_sampler] = sv[1];
       pipe->set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0, num_views, 0,
-                              false, sampler_views);
+                              true, sampler_views);
       st->state.num_sampler_views[PIPE_SHADER_FRAGMENT] = num_views;
-
-      for (unsigned i = 0; i < num_views; i++)
-         pipe_sampler_view_reference(&sampler_views[i], NULL);
    } else {
       /* drawing a depth/stencil image */
       pipe->set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0, num_sampler_view,



More information about the mesa-commit mailing list