Mesa (staging/20.1): mesa/st: introduce PIPE_CAP_NO_CLIP_ON_COPY_TEX

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Sep 2 13:58:49 UTC 2020


Module: Mesa
Branch: staging/20.1
Commit: 76e6b936b07df8296715218c87070b2d942f4965
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=76e6b936b07df8296715218c87070b2d942f4965

Author: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer at amd.com>
Date:   Wed Jul 15 21:23:48 2020 +0200

mesa/st: introduce PIPE_CAP_NO_CLIP_ON_COPY_TEX

If supported this means that src_x/src_y/width/height parameters of
CopyTex functions will not be clipped using the read framebuffer's dimensions.

Cc: mesa-stable
Reviewed-by: Marek Olšák <marek.olsak at amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6259>
(cherry picked from commit d94bec5c49d926069f97a4b12fb2532611a9080c)

---

 .pick_status.json                     | 2 +-
 src/gallium/auxiliary/util/u_screen.c | 3 +++
 src/gallium/docs/source/screen.rst    | 1 +
 src/gallium/include/pipe/p_defines.h  | 1 +
 src/mesa/main/mtypes.h                | 6 ++++++
 src/mesa/main/teximage.c              | 6 ++++--
 src/mesa/state_tracker/st_context.c   | 4 ++++
 7 files changed, 20 insertions(+), 3 deletions(-)

diff --git a/.pick_status.json b/.pick_status.json
index c44c803c138..a06038eaac5 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -49,7 +49,7 @@
         "description": "mesa/st: introduce PIPE_CAP_NO_CLIP_ON_COPY_TEX",
         "nominated": true,
         "nomination_type": 0,
-        "resolution": 0,
+        "resolution": 1,
         "master_sha": null,
         "because_sha": null
     },
diff --git a/src/gallium/auxiliary/util/u_screen.c b/src/gallium/auxiliary/util/u_screen.c
index ae024f0e650..ed6e31b3811 100644
--- a/src/gallium/auxiliary/util/u_screen.c
+++ b/src/gallium/auxiliary/util/u_screen.c
@@ -433,6 +433,9 @@ u_pipe_screen_get_param_defaults(struct pipe_screen *pscreen,
    case PIPE_CAP_ALPHA_TO_COVERAGE_DITHER_CONTROL:
       return 0;
 
+   case PIPE_CAP_NO_CLIP_ON_COPY_TEX:
+      return 0;
+
    default:
       unreachable("bad PIPE_CAP_*");
    }
diff --git a/src/gallium/docs/source/screen.rst b/src/gallium/docs/source/screen.rst
index bf8d8c75d96..1c4a345c9e5 100644
--- a/src/gallium/docs/source/screen.rst
+++ b/src/gallium/docs/source/screen.rst
@@ -581,6 +581,7 @@ The integer capabilities:
 * ``PIPE_CAP_SYSTEM_SVM``: True if all application memory can be shared with the GPU without explicit mapping.
 * ``PIPE_CAP_VIEWPORT_MASK``: Whether ``TGSI_SEMANTIC_VIEWPORT_MASK`` and ``TGSI_PROPERTY_LAYER_VIEWPORT_RELATIVE`` are supported (see GL_NV_viewport_array2).
 * ``PIPE_CAP_MAP_UNSYNCHRONIZED_THREAD_SAFE``: Whether mapping a buffer as unsynchronized from any thread is safe.
+* ``PIPE_CAP_NO_CLIP_ON_COPY_TEX``: Driver doesn't want x/y/width/height clipped based on src size when doing a copy texture operation (eg: may want out-of-bounds reads that produce 0 instead of leaving the texture content undefined)
 
 .. _pipe_capf:
 
diff --git a/src/gallium/include/pipe/p_defines.h b/src/gallium/include/pipe/p_defines.h
index dd0c7331b69..9ab7fe63da7 100644
--- a/src/gallium/include/pipe/p_defines.h
+++ b/src/gallium/include/pipe/p_defines.h
@@ -947,6 +947,7 @@ enum pipe_cap
    PIPE_CAP_VIEWPORT_MASK,
    PIPE_CAP_ALPHA_TO_COVERAGE_DITHER_CONTROL,
    PIPE_CAP_MAP_UNSYNCHRONIZED_THREAD_SAFE,
+   PIPE_CAP_NO_CLIP_ON_COPY_TEX,
 };
 
 /**
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 4f1e8e52ab0..2f8fbd0458a 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -4175,6 +4175,12 @@ struct gl_constants
 
    /** Buffer size used to upload vertices from glBegin/glEnd. */
    unsigned glBeginEndBufferSize;
+
+   /** Whether the driver doesn't want x/y/width/height clipped based on src size
+    *  when doing a copy texture operation (eg: may want out-of-bounds reads that
+    *  produce 0 instead of leaving the texture content undefined).
+    */
+   bool NoClippingOnCopyTex;
 };
 
 
diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
index 19bad75b20e..3ae71e64d29 100644
--- a/src/mesa/main/teximage.c
+++ b/src/mesa/main/teximage.c
@@ -4210,7 +4210,8 @@ copy_texture_sub_image(struct gl_context *ctx, GLuint dims,
       xoffset += texImage->Border;
    }
 
-   if (_mesa_clip_copytexsubimage(ctx, &xoffset, &yoffset, &x, &y,
+   if (ctx->Const.NoClippingOnCopyTex ||
+       _mesa_clip_copytexsubimage(ctx, &xoffset, &yoffset, &x, &y,
                                   &width, &height)) {
       struct gl_renderbuffer *srcRb =
          get_copy_tex_image_source(ctx, texImage->TexFormat);
@@ -4416,7 +4417,8 @@ copyteximage(struct gl_context *ctx, GLuint dims, struct gl_texture_object *texO
             /* Allocate texture memory (no pixel data yet) */
             ctx->Driver.AllocTextureImageBuffer(ctx, texImage);
 
-            if (_mesa_clip_copytexsubimage(ctx, &dstX, &dstY, &srcX, &srcY,
+            if (ctx->Const.NoClippingOnCopyTex ||
+                _mesa_clip_copytexsubimage(ctx, &dstX, &dstY, &srcX, &srcY,
                                            &width, &height)) {
                struct gl_renderbuffer *srcRb =
                   get_copy_tex_image_source(ctx, texImage->TexFormat);
diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c
index 4f7fd242741..d164233d862 100644
--- a/src/mesa/state_tracker/st_context.c
+++ b/src/mesa/state_tracker/st_context.c
@@ -765,6 +765,10 @@ st_create_context_priv(struct gl_context *ctx, struct pipe_context *pipe,
     */
    ctx->Point.MaxSize = MAX2(ctx->Const.MaxPointSize,
                              ctx->Const.MaxPointSizeAA);
+
+   ctx->Const.NoClippingOnCopyTex = screen->get_param(screen,
+                                                      PIPE_CAP_NO_CLIP_ON_COPY_TEX);
+
    /* For vertex shaders, make sure not to emit saturate when SM 3.0
     * is not supported
     */



More information about the mesa-commit mailing list