From 62a4a7787568b49b67ff17d9feb00a2c698e29a0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tapani=20P=C3=A4lli?= Date: Fri, 20 Nov 2020 11:31:16 +0200 Subject: [PATCH] mesa/st: choose S/D format depending on gl_format passed for readpixels MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Marek Olšák Part-of: --- 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 642ea0d..5a3be69 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; } -- 2.7.4