X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fmesa%2Fmain%2Freadpix.c;h=9a4f15f7279645e9bcf3cf6706c659bdd27dbdd9;hb=d9e591391d490c83ce301aa568a2e0afe4cc3c0a;hp=e2ce264cf0bd828184867ca62a904fa9727b3cdb;hpb=d72bf5e79dfb820309ef28b1f7fe39864d884886;p=mesa.git diff --git a/src/mesa/main/readpix.c b/src/mesa/main/readpix.c index e2ce264cf0b..9a4f15f7279 100644 --- a/src/mesa/main/readpix.c +++ b/src/mesa/main/readpix.c @@ -26,9 +26,12 @@ #include "imports.h" #include "bufferobj.h" #include "context.h" +#include "enums.h" #include "readpix.h" #include "framebuffer.h" +#include "formats.h" #include "image.h" +#include "mtypes.h" #include "state.h" @@ -171,6 +174,13 @@ _mesa_ReadPixels( GLint x, GLint y, GLsizei width, GLsizei height, FLUSH_CURRENT(ctx, 0); + if (MESA_VERBOSE & VERBOSE_API) + _mesa_debug(ctx, "glReadPixels(%d, %d, %s, %s, %p)\n", + width, height, + _mesa_lookup_enum_by_nr(format), + _mesa_lookup_enum_by_nr(type), + pixels); + if (width < 0 || height < 0) { _mesa_error( ctx, GL_INVALID_VALUE, "glReadPixels(width=%d height=%d)", width, height ); @@ -185,6 +195,20 @@ _mesa_ReadPixels( GLint x, GLint y, GLsizei width, GLsizei height, return; } + /* Check that the destination format and source buffer are both + * integer-valued or both non-integer-valued. + */ + if (ctx->Extensions.EXT_texture_integer && _mesa_is_color_format(format)) { + const struct gl_renderbuffer *rb = ctx->ReadBuffer->_ColorReadBuffer; + const GLboolean srcInteger = _mesa_is_format_integer_color(rb->Format); + const GLboolean dstInteger = _mesa_is_integer_format(format); + if (dstInteger != srcInteger) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glReadPixels(integer / non-integer format mismatch"); + return; + } + } + if (ctx->ReadBuffer->_Status != GL_FRAMEBUFFER_COMPLETE_EXT) { _mesa_error(ctx, GL_INVALID_FRAMEBUFFER_OPERATION_EXT, "glReadPixels(incomplete framebuffer)" );