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@intel.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7707>
This commit is contained in:
Tapani Pälli
2020-11-20 11:31:16 +02:00
committed by Marge Bot
parent 4e62372611
commit 62a4a77875

View File

@@ -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;
}