diff --git a/src/mesa/main/draw_validate.c b/src/mesa/main/draw_validate.c index 0439d0aa8c4..cdf4b0996a9 100644 --- a/src/mesa/main/draw_validate.c +++ b/src/mesa/main/draw_validate.c @@ -160,12 +160,6 @@ _mesa_valid_to_render(struct gl_context *ctx, const char *where) } } - if (ctx->DrawBuffer->_Status != GL_FRAMEBUFFER_COMPLETE_EXT) { - _mesa_error(ctx, GL_INVALID_FRAMEBUFFER_OPERATION_EXT, - "%s(incomplete framebuffer)", where); - return GL_FALSE; - } - if (!check_blend_func_error(ctx)) { return GL_FALSE; } @@ -213,6 +207,18 @@ _mesa_update_valid_to_render_state(struct gl_context *ctx) ctx->ValidPrimMask = 0; ctx->DrawPixValid = false; + /* The default error is GL_INVALID_OPERATION if mode is a valid enum. + * It can be overriden by following code if we should return a different + * error. + */ + ctx->DrawGLError = GL_INVALID_OPERATION; + + if (!ctx->DrawBuffer || + ctx->DrawBuffer->_Status != GL_FRAMEBUFFER_COMPLETE_EXT) { + ctx->DrawGLError = GL_INVALID_FRAMEBUFFER_OPERATION; + return; + } + /* A pipeline object is bound */ if (shader->Name && !shader->Validated && !_mesa_validate_program_pipeline(ctx, shader)) @@ -564,11 +570,11 @@ _mesa_valid_prim_mode(struct gl_context *ctx, GLenum mode, bool uses_vao, /* All primitive type enums are less than 32, so we can use the shift. */ if (mode >= 32 || !((1u << mode) & ctx->ValidPrimMask)) { /* If the primitive type is not in SupportedPrimMask, set GL_INVALID_ENUM, - * else set GL_INVALID_OPERATION. + * else set DrawGLError (e.g. GL_INVALID_OPERATION). */ _mesa_error(ctx, mode >= 32 || !((1u << mode) & ctx->SupportedPrimMask) ? - GL_INVALID_ENUM : GL_INVALID_OPERATION, + GL_INVALID_ENUM : ctx->DrawGLError, "%s(mode=%x)", name, mode); return false; } diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c index 1fb76e52f22..2bfe2e9de6a 100644 --- a/src/mesa/main/fbobject.c +++ b/src/mesa/main/fbobject.c @@ -717,6 +717,8 @@ fbo_incomplete(struct gl_context *ctx, const char *msg, int index) if (MESA_DEBUG_FLAGS & DEBUG_INCOMPLETE_FBO) { _mesa_debug(NULL, "FBO Incomplete: %s [%d]\n", msg, index); } + + _mesa_update_valid_to_render_state(ctx); } diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index d3ef0d4cb83..93f58956a1c 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -5235,6 +5235,8 @@ struct gl_context */ GLbitfield ValidPrimMask; + GLenum16 DrawGLError; /**< GL error to return from draw calls */ + /** * Whether DrawPixels/CopyPixels/Bitmap are valid to render. */