diff options
Diffstat (limited to 'src/mesa')
-rw-r--r-- | src/mesa/main/readpix.c | 51 |
1 files changed, 34 insertions, 17 deletions
diff --git a/src/mesa/main/readpix.c b/src/mesa/main/readpix.c index 2326776ecbf..17535706057 100644 --- a/src/mesa/main/readpix.c +++ b/src/mesa/main/readpix.c @@ -44,6 +44,10 @@ _mesa_error_check_format_type(GLcontext *ctx, GLenum format, GLenum type, GLboolean drawing) { const char *readDraw = drawing ? "Draw" : "Read"; + const GLboolean reading = !drawing; + + /* state validation should have already been done */ + ASSERT(ctx->NewState == 0x0); if (ctx->Extensions.EXT_packed_depth_stencil && type == GL_UNSIGNED_INT_24_8_EXT @@ -73,32 +77,45 @@ _mesa_error_check_format_type(GLcontext *ctx, GLenum format, GLenum type, case GL_RGBA: case GL_BGRA: case GL_ABGR_EXT: - if (drawing && !ctx->Visual.rgbMode) { - _mesa_error(ctx, GL_INVALID_OPERATION, + if (drawing) { + if (!ctx->DrawBuffer->Visual.rgbMode) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glDrawPixels(drawing RGB pixels into color index buffer)"); - return GL_TRUE; + return GL_TRUE; + } } - if (!drawing && !_mesa_dest_buffer_exists(ctx, GL_COLOR)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glReadPixels(no color buffer)"); - return GL_TRUE; + else { + /* reading */ + if (!_mesa_source_buffer_exists(ctx, GL_COLOR)) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glReadPixels(no color buffer)"); + return GL_TRUE; + } } break; case GL_COLOR_INDEX: - if (!drawing && ctx->Visual.rgbMode) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glReadPixels(reading color index format from RGB buffer)"); - return GL_TRUE; + if (drawing) { + if (ctx->DrawBuffer->Visual.rgbMode && + (ctx->PixelMaps.ItoR.Size == 0 || + ctx->PixelMaps.ItoG.Size == 0 || + ctx->PixelMaps.ItoB.Size == 0)) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glDrawPixels(drawing color index pixels into RGB buffer)"); + return GL_TRUE; + } } - if (!drawing && !_mesa_dest_buffer_exists(ctx, GL_COLOR)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glReadPixels(no color buffer)"); - return GL_TRUE; + else { + /* reading */ + if (!_mesa_source_buffer_exists(ctx, GL_COLOR)) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glReadPixels(no color buffer)"); + return GL_TRUE; + } } break; case GL_STENCIL_INDEX: if ((drawing && !_mesa_dest_buffer_exists(ctx, format)) || - (!drawing && !_mesa_source_buffer_exists(ctx, format))) { + (reading && !_mesa_source_buffer_exists(ctx, format))) { _mesa_error(ctx, GL_INVALID_OPERATION, "gl%sPixels(no stencil buffer)", readDraw); return GL_TRUE; @@ -118,7 +135,7 @@ _mesa_error_check_format_type(GLcontext *ctx, GLenum format, GLenum type, return GL_TRUE; } if ((drawing && !_mesa_dest_buffer_exists(ctx, format)) || - (!drawing && !_mesa_source_buffer_exists(ctx, format))) { + (reading && !_mesa_source_buffer_exists(ctx, format))) { _mesa_error(ctx, GL_INVALID_OPERATION, "gl%sPixels(no depth or stencil buffer)", readDraw); return GL_TRUE; |