mesa: move GL_FILL_RECTANGLE validation from draws to state changes

This is a step towards removing _mesa_valid_to_render.

Reviewed-by: Zoltán Böszörményi <zboszor@gmail.com>
Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8798>
This commit is contained in:
Marek Olšák 2021-01-30 19:18:06 -05:00 committed by Marge Bot
parent a22e719661
commit 40341c5118
2 changed files with 15 additions and 14 deletions

View File

@ -133,19 +133,6 @@ _mesa_valid_to_render(struct gl_context *ctx, const char *where)
return GL_FALSE;
}
/* From the GL_NV_fill_rectangle spec:
*
* "An INVALID_OPERATION error is generated by Begin or any Draw command if
* only one of the front and back polygon mode is FILL_RECTANGLE_NV."
*/
if ((ctx->Polygon.FrontMode == GL_FILL_RECTANGLE_NV) !=
(ctx->Polygon.BackMode == GL_FILL_RECTANGLE_NV)) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"GL_FILL_RECTANGLE_NV must be used as both front/back "
"polygon mode or neither");
return GL_FALSE;
}
return GL_TRUE;
}
@ -297,6 +284,15 @@ _mesa_update_valid_to_render_state(struct gl_context *ctx)
unreachable("Invalid API value in _mesa_update_valid_to_render_state");
}
/* From the GL_NV_fill_rectangle spec:
*
* "An INVALID_OPERATION error is generated by Begin or any Draw command if
* only one of the front and back polygon mode is FILL_RECTANGLE_NV."
*/
if ((ctx->Polygon.FrontMode == GL_FILL_RECTANGLE_NV) !=
(ctx->Polygon.BackMode == GL_FILL_RECTANGLE_NV))
return;
/* From GL_INTEL_conservative_rasterization spec:
*
* The conservative rasterization option applies only to polygons with

View File

@ -160,6 +160,10 @@ _mesa_FrontFace(GLenum mode)
static ALWAYS_INLINE void
polygon_mode(struct gl_context *ctx, GLenum face, GLenum mode, bool no_error)
{
bool old_mode_has_fill_rectangle =
ctx->Polygon.FrontMode == GL_FILL_RECTANGLE_NV ||
ctx->Polygon.BackMode == GL_FILL_RECTANGLE_NV;
if (MESA_VERBOSE & VERBOSE_API)
_mesa_debug(ctx, "glPolygonMode %s %s\n",
_mesa_enum_to_string(face),
@ -224,7 +228,8 @@ polygon_mode(struct gl_context *ctx, GLenum face, GLenum mode, bool no_error)
if (ctx->Driver.PolygonMode)
ctx->Driver.PolygonMode(ctx, face, mode);
if (ctx->Extensions.INTEL_conservative_rasterization)
if (ctx->Extensions.INTEL_conservative_rasterization ||
(mode == GL_FILL_RECTANGLE_NV || old_mode_has_fill_rectangle))
_mesa_update_valid_to_render_state(ctx);
}