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