Mesa (master): nv50,nvc0: remove explicit target argument from view creation

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Mar 22 15:29:36 UTC 2021


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

Author: Ilia Mirkin <imirkin at alum.mit.edu>
Date:   Sun Mar 21 13:41:03 2021 -0400

nv50,nvc0: remove explicit target argument from view creation

Before texture views were supported, this was needed in some cases.
However with texture views (added eons ago), there is now a target
attribute in the template. Use it and remove the explicit argument.

Should help prevent bugs with inconsistencies between the stored
template target and the one that's used to create the view.

Signed-off-by: Ilia Mirkin <imirkin at alum.mit.edu>
Reviewed-by: Karol Herbst <kherbst at redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9740>

---

 src/gallium/drivers/nouveau/nv50/nv50_context.h |  3 +--
 src/gallium/drivers/nouveau/nv50/nv50_surface.c |  4 ++--
 src/gallium/drivers/nouveau/nv50/nv50_tex.c     |  9 ++++-----
 src/gallium/drivers/nouveau/nvc0/nvc0_context.h |  3 +--
 src/gallium/drivers/nouveau/nvc0/nvc0_surface.c |  5 +++--
 src/gallium/drivers/nouveau/nvc0/nvc0_tex.c     | 22 ++++++++++------------
 6 files changed, 21 insertions(+), 25 deletions(-)

diff --git a/src/gallium/drivers/nouveau/nv50/nv50_context.h b/src/gallium/drivers/nouveau/nv50/nv50_context.h
index eda5a6fd58d..0be11ba8c30 100644
--- a/src/gallium/drivers/nouveau/nv50/nv50_context.h
+++ b/src/gallium/drivers/nouveau/nv50/nv50_context.h
@@ -268,8 +268,7 @@ struct pipe_sampler_view *
 nv50_create_texture_view(struct pipe_context *,
                          struct pipe_resource *,
                          const struct pipe_sampler_view *,
-                         uint32_t flags,
-                         enum pipe_texture_target);
+                         uint32_t flags);
 struct pipe_sampler_view *
 nv50_create_sampler_view(struct pipe_context *,
                          struct pipe_resource *,
diff --git a/src/gallium/drivers/nouveau/nv50/nv50_surface.c b/src/gallium/drivers/nouveau/nv50/nv50_surface.c
index b524eb9603b..b3259f26038 100644
--- a/src/gallium/drivers/nouveau/nv50/nv50_surface.c
+++ b/src/gallium/drivers/nouveau/nv50/nv50_surface.c
@@ -1178,7 +1178,7 @@ nv50_blit_set_src(struct nv50_blitctx *blit,
       flags |= NV50_TEXVIEW_FILTER_MSAA8;
 
    nv50->textures[2][0] = nv50_create_texture_view(
-      pipe, res, &templ, flags, target);
+      pipe, res, &templ, flags);
    nv50->textures[2][1] = NULL;
 
    nv50->num_textures[0] = nv50->num_textures[1] = 0;
@@ -1187,7 +1187,7 @@ nv50_blit_set_src(struct nv50_blitctx *blit,
    templ.format = nv50_zs_to_s_format(format);
    if (templ.format != res->format) {
       nv50->textures[2][1] = nv50_create_texture_view(
-         pipe, res, &templ, flags, target);
+         pipe, res, &templ, flags);
       nv50->num_textures[2] = 2;
    }
 }
diff --git a/src/gallium/drivers/nouveau/nv50/nv50_tex.c b/src/gallium/drivers/nouveau/nv50/nv50_tex.c
index 3f51c53e967..55d3d8a420c 100644
--- a/src/gallium/drivers/nouveau/nv50/nv50_tex.c
+++ b/src/gallium/drivers/nouveau/nv50/nv50_tex.c
@@ -53,15 +53,14 @@ nv50_create_sampler_view(struct pipe_context *pipe,
    if (templ->target == PIPE_TEXTURE_RECT || templ->target == PIPE_BUFFER)
       flags |= NV50_TEXVIEW_SCALED_COORDS;
 
-   return nv50_create_texture_view(pipe, res, templ, flags, templ->target);
+   return nv50_create_texture_view(pipe, res, templ, flags);
 }
 
 struct pipe_sampler_view *
 nv50_create_texture_view(struct pipe_context *pipe,
                          struct pipe_resource *texture,
                          const struct pipe_sampler_view *templ,
-                         uint32_t flags,
-                         enum pipe_texture_target target)
+                         uint32_t flags)
 {
    const uint32_t class_3d = nouveau_context(pipe)->screen->class_3d;
    const struct util_format_description *desc;
@@ -130,7 +129,7 @@ nv50_create_texture_view(struct pipe_context *pipe,
       tic[2] |= G80_TIC_2_NORMALIZED_COORDS;
 
    if (unlikely(!nouveau_bo_memtype(nv04_resource(texture)->bo))) {
-      if (target == PIPE_BUFFER) {
+      if (templ->target == PIPE_BUFFER) {
          addr += view->pipe.u.buf.offset;
          tic[2] |= G80_TIC_2_LAYOUT_PITCH | G80_TIC_2_TEXTURE_TYPE_ONE_D_BUFFER;
          tic[3] = 0;
@@ -157,7 +156,7 @@ nv50_create_texture_view(struct pipe_context *pipe,
       ((mt->level[0].tile_mode & 0x0f0) << (22 - 4)) |
       ((mt->level[0].tile_mode & 0xf00) << (25 - 8));
 
-   switch (target) {
+   switch (templ->target) {
    case PIPE_TEXTURE_1D:
       tic[2] |= G80_TIC_2_TEXTURE_TYPE_ONE_D;
       break;
diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_context.h b/src/gallium/drivers/nouveau/nvc0/nvc0_context.h
index 92ef2699e0e..724c14c66f5 100644
--- a/src/gallium/drivers/nouveau/nvc0/nvc0_context.h
+++ b/src/gallium/drivers/nouveau/nvc0/nvc0_context.h
@@ -382,8 +382,7 @@ struct pipe_sampler_view *
 nvc0_create_texture_view(struct pipe_context *,
                          struct pipe_resource *,
                          const struct pipe_sampler_view *,
-                         uint32_t flags,
-                         enum pipe_texture_target);
+                         uint32_t flags);
 struct pipe_sampler_view *
 nvc0_create_sampler_view(struct pipe_context *,
                          struct pipe_resource *,
diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_surface.c b/src/gallium/drivers/nouveau/nvc0/nvc0_surface.c
index 27d1fddaf8d..ce3a5582406 100644
--- a/src/gallium/drivers/nouveau/nvc0/nvc0_surface.c
+++ b/src/gallium/drivers/nouveau/nvc0/nvc0_surface.c
@@ -967,6 +967,7 @@ nvc0_blit_set_src(struct nvc0_blitctx *ctx,
 
    target = nv50_blit_reinterpret_pipe_texture_target(res->target);
 
+   templ.target = target;
    templ.format = format;
    templ.u.tex.first_layer = templ.u.tex.last_layer = layer;
    templ.u.tex.first_level = templ.u.tex.last_level = level;
@@ -987,7 +988,7 @@ nvc0_blit_set_src(struct nvc0_blitctx *ctx,
       flags |= NV50_TEXVIEW_FILTER_MSAA8;
 
    nvc0->textures[4][0] = nvc0_create_texture_view(
-      pipe, res, &templ, flags, target);
+      pipe, res, &templ, flags);
    nvc0->textures[4][1] = NULL;
 
    for (s = 0; s <= 3; ++s)
@@ -997,7 +998,7 @@ nvc0_blit_set_src(struct nvc0_blitctx *ctx,
    templ.format = nv50_zs_to_s_format(format);
    if (templ.format != format) {
       nvc0->textures[4][1] = nvc0_create_texture_view(
-         pipe, res, &templ, flags, target);
+         pipe, res, &templ, flags);
       nvc0->num_textures[4] = 2;
    }
 }
diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_tex.c b/src/gallium/drivers/nouveau/nvc0/nvc0_tex.c
index 8cb9776d9cd..c574169fedb 100644
--- a/src/gallium/drivers/nouveau/nvc0/nvc0_tex.c
+++ b/src/gallium/drivers/nouveau/nvc0/nvc0_tex.c
@@ -58,15 +58,14 @@ nvc0_create_sampler_view(struct pipe_context *pipe,
    if (templ->target == PIPE_TEXTURE_RECT || templ->target == PIPE_BUFFER)
       flags |= NV50_TEXVIEW_SCALED_COORDS;
 
-   return nvc0_create_texture_view(pipe, res, templ, flags, templ->target);
+   return nvc0_create_texture_view(pipe, res, templ, flags);
 }
 
 static struct pipe_sampler_view *
 gm107_create_texture_view(struct pipe_context *pipe,
                           struct pipe_resource *texture,
                           const struct pipe_sampler_view *templ,
-                          uint32_t flags,
-                          enum pipe_texture_target target)
+                          uint32_t flags)
 {
    const struct util_format_description *desc;
    const struct nvc0_format *fmt;
@@ -172,7 +171,7 @@ gm107_create_texture_view(struct pipe_context *pipe,
    tic[1]  = address;
    tic[2] |= address >> 32;
 
-   switch (target) {
+   switch (templ->target) {
    case PIPE_TEXTURE_1D:
       tic[4] |= GM107_TIC2_4_TEXTURE_TYPE_ONE_D;
       break;
@@ -253,6 +252,7 @@ gm107_create_texture_view_from_image(struct pipe_context *pipe,
    if (target == PIPE_TEXTURE_CUBE || target == PIPE_TEXTURE_CUBE_ARRAY)
       target = PIPE_TEXTURE_2D_ARRAY;
 
+   templ.target = target;
    templ.format = view->format;
    templ.swizzle_r = PIPE_SWIZZLE_X;
    templ.swizzle_g = PIPE_SWIZZLE_Y;
@@ -270,15 +270,14 @@ gm107_create_texture_view_from_image(struct pipe_context *pipe,
 
    flags = NV50_TEXVIEW_SCALED_COORDS | NV50_TEXVIEW_IMAGE_GM107;
 
-   return nvc0_create_texture_view(pipe, &res->base, &templ, flags, target);
+   return nvc0_create_texture_view(pipe, &res->base, &templ, flags);
 }
 
 static struct pipe_sampler_view *
 gf100_create_texture_view(struct pipe_context *pipe,
                           struct pipe_resource *texture,
                           const struct pipe_sampler_view *templ,
-                          uint32_t flags,
-                          enum pipe_texture_target target)
+                          uint32_t flags)
 {
    const struct util_format_description *desc;
    const struct nvc0_format *fmt;
@@ -380,7 +379,7 @@ gf100_create_texture_view(struct pipe_context *pipe,
    tic[1] = address;
    tic[2] |= address >> 32;
 
-   switch (target) {
+   switch (templ->target) {
    case PIPE_TEXTURE_1D:
       tic[2] |= G80_TIC_2_TEXTURE_TYPE_ONE_D;
       break;
@@ -443,12 +442,11 @@ struct pipe_sampler_view *
 nvc0_create_texture_view(struct pipe_context *pipe,
                          struct pipe_resource *texture,
                          const struct pipe_sampler_view *templ,
-                         uint32_t flags,
-                         enum pipe_texture_target target)
+                         uint32_t flags)
 {
    if (nvc0_context(pipe)->screen->tic.maxwell)
-      return gm107_create_texture_view(pipe, texture, templ, flags, target);
-   return gf100_create_texture_view(pipe, texture, templ, flags, target);
+      return gm107_create_texture_view(pipe, texture, templ, flags);
+   return gf100_create_texture_view(pipe, texture, templ, flags);
 }
 
 bool



More information about the mesa-commit mailing list