From 40341c5118ceeba522dcf9643c38843df2a4c1b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Sat, 30 Jan 2021 19:18:06 -0500 Subject: [PATCH] mesa: move GL_FILL_RECTANGLE validation from draws to state changes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is a step towards removing _mesa_valid_to_render. Reviewed-by: Zoltán Böszörményi Reviewed-by: Pierre-Eric Pelloux-Prayer Part-of: --- src/mesa/main/draw_validate.c | 22 +++++++++------------- src/mesa/main/polygon.c | 7 ++++++- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/src/mesa/main/draw_validate.c b/src/mesa/main/draw_validate.c index 4436c793ab1..7f73d49d343 100644 --- a/src/mesa/main/draw_validate.c +++ b/src/mesa/main/draw_validate.c @@ -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 diff --git a/src/mesa/main/polygon.c b/src/mesa/main/polygon.c index 3bb416d360c..bbba607ebe4 100644 --- a/src/mesa/main/polygon.c +++ b/src/mesa/main/polygon.c @@ -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); }