Mesa (master): st/mesa: optimize DEPTH_STENCIL copies using fragment shader

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Aug 5 19:44:31 UTC 2020


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

Author: Indrajit Kumar Das <indrajit-kumar.das at amd.com>
Date:   Mon Jul 27 19:39:42 2020 +0530

st/mesa: optimize DEPTH_STENCIL copies using fragment shader

Reviewed-by: Marek Olšák <marek.olsak at amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6088>

---

 src/mesa/state_tracker/st_cb_drawpixels.c | 26 ++++++++++++++++++--------
 1 file changed, 18 insertions(+), 8 deletions(-)

diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c
index 366c324800f..2a1ac8f4f02 100644
--- a/src/mesa/state_tracker/st_cb_drawpixels.c
+++ b/src/mesa/state_tracker/st_cb_drawpixels.c
@@ -1717,8 +1717,9 @@ st_CopyPixels(struct gl_context *ctx, GLint srcx, GLint srcy,
    if (blit_copy_pixels(ctx, srcx, srcy, width, height, dstx, dsty, type))
       return;
 
-   if (type == GL_DEPTH_STENCIL) {
-      /* XXX make this more efficient */
+   /* fallback if the driver can't do stencil exports */
+   if (type == GL_DEPTH_STENCIL &&
+      !pipe->screen->get_param(pipe->screen, PIPE_CAP_SHADER_STENCIL_EXPORT)) {
       st_CopyPixels(ctx, srcx, srcy, width, height, dstx, dsty, GL_STENCIL);
       st_CopyPixels(ctx, srcx, srcy, width, height, dstx, dsty, GL_DEPTH);
       return;
@@ -1764,13 +1765,18 @@ st_CopyPixels(struct gl_context *ctx, GLint srcx, GLint srcy,
       rbRead = st_renderbuffer(ctx->ReadBuffer->
                                Attachment[BUFFER_DEPTH].Renderbuffer);
       driver_fp = get_drawpix_z_stencil_program(st, GL_TRUE, GL_FALSE);
-   } else {
-      assert(type == GL_STENCIL);
+   } else if (type == GL_STENCIL) {
       rbRead = st_renderbuffer(ctx->ReadBuffer->
                                Attachment[BUFFER_STENCIL].Renderbuffer);
       driver_fp = get_drawpix_z_stencil_program(st, GL_FALSE, GL_TRUE);
+   } else {
+      assert(type == GL_DEPTH_STENCIL);
+      rbRead = st_renderbuffer(ctx->ReadBuffer->
+                               Attachment[BUFFER_DEPTH].Renderbuffer);
+      driver_fp = get_drawpix_z_stencil_program(st, GL_TRUE, GL_TRUE);
    }
 
+
    /* Choose the format for the temporary texture. */
    srcFormat = rbRead->texture->format;
    srcBind = PIPE_BIND_SAMPLER_VIEW |
@@ -1865,8 +1871,10 @@ st_CopyPixels(struct gl_context *ctx, GLint srcx, GLint srcy,
    }
 
    /* Create a second sampler view to read stencil */
-   if (type == GL_STENCIL) {
+   if (type == GL_STENCIL || type == GL_DEPTH_STENCIL) {
       write_stencil = GL_TRUE;
+      if (type == GL_DEPTH_STENCIL)
+         write_depth = GL_TRUE;
       enum pipe_format stencil_format =
          util_format_stencil_only(pt->format);
       /* we should not be doing pixel map/transfer (see above) */
@@ -1904,10 +1912,12 @@ st_CopyPixels(struct gl_context *ctx, GLint srcx, GLint srcy,
       blit.dst.box.width = readW;
       blit.dst.box.height = readH;
       blit.dst.box.depth = 1;
-      if (type != GL_STENCIL)
-         blit.mask = util_format_get_mask(pt->format) & ~PIPE_MASK_S;
+      if (type == GL_DEPTH)
+          blit.mask = util_format_get_mask(pt->format) & ~PIPE_MASK_S;
+      else if (type == GL_STENCIL)
+          blit.mask = util_format_get_mask(pt->format) & ~PIPE_MASK_Z;
       else
-         blit.mask = util_format_get_mask(pt->format) & ~PIPE_MASK_Z;
+         blit.mask = util_format_get_mask(pt->format);
       blit.filter = PIPE_TEX_FILTER_NEAREST;
 
       pipe->blit(pipe, &blit);



More information about the mesa-commit mailing list