mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-06 09:28:07 +02:00
mesa: fix some incorrect error checks in _mesa_error_check_format_type()
Plus, simplify the code a bit.
This commit is contained in:
parent
3335b847bf
commit
2dec62405f
1 changed files with 34 additions and 17 deletions
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue