mesa: Try to fix CopyTex[Sub]Image of stencil textures.
authorKenneth Graunke <kenneth@whitecape.org>
Tue, 26 Apr 2016 09:31:20 +0000 (02:31 -0700)
committerKenneth Graunke <kenneth@whitecape.org>
Wed, 27 Apr 2016 04:32:35 +0000 (21:32 -0700)
ES prohibits this, but GL appears to allow it.  We at least need this
much, or else we'll crash as there's no source to read from.

This fixed crashes in the ES tests before I realized I needed to
prohibit stencil instead.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Chris Forbes <chrisf@ijw.co.nz>
src/mesa/main/teximage.c

index 76b6584d3bf2b8cefa94527b4399ac9a01300032..6b0744beeef572e4ca32ec585bf5f2e0b7751b45 100644 (file)
@@ -3434,8 +3434,9 @@ get_copy_tex_image_source(struct gl_context *ctx, mesa_format texFormat)
    if (_mesa_get_format_bits(texFormat, GL_DEPTH_BITS) > 0) {
       /* reading from depth/stencil buffer */
       return ctx->ReadBuffer->Attachment[BUFFER_DEPTH].Renderbuffer;
-   }
-   else {
+   } else if (_mesa_get_format_bits(texFormat, GL_STENCIL_BITS) > 0) {
+      return ctx->ReadBuffer->Attachment[BUFFER_STENCIL].Renderbuffer;
+   } else {
       /* copying from color buffer */
       return ctx->ReadBuffer->_ColorReadBuffer;
    }