Mesa (master): mesa/st: choose S/D format depending on gl_format passed for readpixels

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Sat Nov 28 03:46:46 UTC 2020


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

Author: Tapani Pälli <tapani.palli at intel.com>
Date:   Fri Nov 20 11:31:16 2020 +0200

mesa/st: choose S/D format depending on gl_format passed for readpixels

This makes sure we create correct type of a sampler view for reading.

Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/3775
Signed-off-by: Tapani Pälli <tapani.palli at intel.com>
Reviewed-by: Marek Olšák <marek.olsak at amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7707>

---

 src/mesa/state_tracker/st_cb_readpixels.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/src/mesa/state_tracker/st_cb_readpixels.c b/src/mesa/state_tracker/st_cb_readpixels.c
index 642ea0df032..5a3be69a4fe 100644
--- a/src/mesa/state_tracker/st_cb_readpixels.c
+++ b/src/mesa/state_tracker/st_cb_readpixels.c
@@ -97,6 +97,7 @@ static bool
 try_pbo_readpixels(struct st_context *st, struct st_renderbuffer *strb,
                    bool invert_y,
                    GLint x, GLint y, GLsizei width, GLsizei height,
+                   GLenum gl_format,
                    enum pipe_format src_format, enum pipe_format dst_format,
                    const struct gl_pixelstore_attrib *pack, void *pixels)
 {
@@ -111,6 +112,12 @@ try_pbo_readpixels(struct st_context *st, struct st_renderbuffer *strb,
    enum pipe_texture_target view_target;
    bool success = false;
 
+   /* Make sure we have stencil format in case of GL_STENCIL_INDEX to
+    * create correct type of a sampler view.
+    */
+   if (gl_format == GL_STENCIL_INDEX)
+      src_format = util_format_stencil_only(src_format);
+
    if (texture->nr_samples > 1)
       return false;
 
@@ -474,7 +481,7 @@ st_ReadPixels(struct gl_context *ctx, GLint x, GLint y,
       if (try_pbo_readpixels(st, strb,
                              st_fb_orientation(ctx->ReadBuffer) == Y_0_TOP,
                              x, y, width, height,
-                             src_format, dst_format,
+                             format, src_format, dst_format,
                              pack, pixels))
          return;
    }



More information about the mesa-commit mailing list