mesa/st: introduce PIPE_CAP_NO_CLIP_ON_COPY_TEX
authorPierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Wed, 15 Jul 2020 19:23:48 +0000 (21:23 +0200)
committerPierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Wed, 2 Sep 2020 09:53:16 +0000 (11:53 +0200)
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@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6259>

docs/gallium/screen.rst
src/gallium/auxiliary/util/u_screen.c
src/gallium/include/pipe/p_defines.h
src/mesa/main/mtypes.h
src/mesa/main/teximage.c
src/mesa/state_tracker/st_context.c

index 45c82802cc9df2ee966968463ae851c2401e08cd..8ae3de036f75012af57ebf7ae222099d2e1c4533 100644 (file)
@@ -590,6 +590,7 @@ The integer capabilities:
 * ``PIPE_CAP_GLSL_ZERO_INIT``: Choose a default zero initialization some glsl variables. If `1`, then all glsl shader variables and gl_FragColor are initialized to zero. If `2`, then shader out variables are not initialized but function out variables are.
 * ``PIPE_CAP_BLEND_EQUATION_ADVANCED``: Driver supports blend equation advanced without necessarily supporting FBFETCH.
 * ``PIPE_CAP_NIR_ATOMICS_AS_DEREF``: Whether NIR atomics instructions should reference atomics as NIR derefs instead of by indices.
 * ``PIPE_CAP_GLSL_ZERO_INIT``: Choose a default zero initialization some glsl variables. If `1`, then all glsl shader variables and gl_FragColor are initialized to zero. If `2`, then shader out variables are not initialized but function out variables are.
 * ``PIPE_CAP_BLEND_EQUATION_ADVANCED``: Driver supports blend equation advanced without necessarily supporting FBFETCH.
 * ``PIPE_CAP_NIR_ATOMICS_AS_DEREF``: Whether NIR atomics instructions should reference atomics as NIR derefs instead of by indices.
+* ``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:
 
 
 .. _pipe_capf:
 
index 9f174c587019727c389e99fb7ff08ef56da956ec..cb06acfba77f5c5da9eb35350290b4539d5b9809 100644 (file)
@@ -438,6 +438,9 @@ u_pipe_screen_get_param_defaults(struct pipe_screen *pscreen,
    case PIPE_CAP_ALPHA_TO_COVERAGE_DITHER_CONTROL:
       return 0;
 
    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_*");
    }
    default:
       unreachable("bad PIPE_CAP_*");
    }
index 235c8ec06bcb9cbd64faab60eb6d60a0f9ef0340..7eb7c703ffeea60af72fe8327e2d8b884a877f19 100644 (file)
@@ -966,6 +966,7 @@ enum pipe_cap
    PIPE_CAP_GLSL_ZERO_INIT,
    PIPE_CAP_BLEND_EQUATION_ADVANCED,
    PIPE_CAP_NIR_ATOMICS_AS_DEREF,
    PIPE_CAP_GLSL_ZERO_INIT,
    PIPE_CAP_BLEND_EQUATION_ADVANCED,
    PIPE_CAP_NIR_ATOMICS_AS_DEREF,
+   PIPE_CAP_NO_CLIP_ON_COPY_TEX,
 };
 
 /**
 };
 
 /**
index 8924f5d4f85bb2a693dda694846d372bad102998..f9353d9ef957f8d653d0712ae8069f3e1a11cb8f 100644 (file)
@@ -4209,6 +4209,12 @@ struct gl_constants
 
    /** Buffer size used to upload vertices from glBegin/glEnd. */
    unsigned glBeginEndBufferSize;
 
    /** 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;
 };
 
 
 };
 
 
index 7a74ff251068757680439d8c19e4e8d85ef8810b..895b5664e5bab7da9db5e8ccb07fff5f5bd309be 100644 (file)
@@ -4210,7 +4210,8 @@ copy_texture_sub_image(struct gl_context *ctx, GLuint dims,
       xoffset += texImage->Border;
    }
 
       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);
                                   &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);
 
             /* 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);
                                            &width, &height)) {
                struct gl_renderbuffer *srcRb =
                   get_copy_tex_image_source(ctx, texImage->TexFormat);
index 6c8ba9dd73254cae75d24573b58e2e141a293e31..aaaa615e09b987c429f25a00a18dd34800f98d5f 100644 (file)
@@ -762,6 +762,10 @@ st_create_context_priv(struct gl_context *ctx, struct pipe_context *pipe,
     */
    ctx->Point.MaxSize = MAX2(ctx->Const.MaxPointSize,
                              ctx->Const.MaxPointSizeAA);
     */
    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
     */
    /* For vertex shaders, make sure not to emit saturate when SM 3.0
     * is not supported
     */