From a22e7196615590aa2f384d5631f57fdfb3530f4b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Sat, 30 Jan 2021 19:16:06 -0500 Subject: [PATCH] mesa: move ARB program and integer FBO validation from draws to state changes MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 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/arbprogram.c | 3 ++ src/mesa/main/draw_validate.c | 52 ++++++++++++++--------------------- src/mesa/main/enable.c | 2 ++ 3 files changed, 26 insertions(+), 31 deletions(-) diff --git a/src/mesa/main/arbprogram.c b/src/mesa/main/arbprogram.c index 359718256ef..9635bfca1fb 100644 --- a/src/mesa/main/arbprogram.c +++ b/src/mesa/main/arbprogram.c @@ -31,6 +31,7 @@ #include "main/glheader.h" #include "main/context.h" +#include "main/draw_validate.h" #include "main/hash.h" #include "main/macros.h" @@ -148,6 +149,7 @@ _mesa_BindProgramARB(GLenum target, GLuint id) } _mesa_update_vertex_processing_mode(ctx); + _mesa_update_valid_to_render_state(ctx); /* Never null pointers */ assert(ctx->VertexProgram.Current); @@ -411,6 +413,7 @@ set_program_string(struct gl_program *prog, GLenum target, GLenum format, GLsize } _mesa_update_vertex_processing_mode(ctx); + _mesa_update_valid_to_render_state(ctx); if (ctx->_Shader->Flags & GLSL_DUMP) { const char *shader_type = diff --git a/src/mesa/main/draw_validate.c b/src/mesa/main/draw_validate.c index cdf4b0996a9..4436c793ab1 100644 --- a/src/mesa/main/draw_validate.c +++ b/src/mesa/main/draw_validate.c @@ -129,37 +129,6 @@ _mesa_valid_to_render(struct gl_context *ctx, const char *where) if (ctx->NewState) _mesa_update_state(ctx); - if (ctx->API == API_OPENGL_COMPAT) { - /* Any shader stages that are not supplied by the GLSL shader and have - * assembly shaders enabled must now be validated. - */ - if (!ctx->_Shader->CurrentProgram[MESA_SHADER_VERTEX] && - ctx->VertexProgram.Enabled && - !_mesa_arb_vertex_program_enabled(ctx)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "%s(vertex program not valid)", where); - return GL_FALSE; - } - - if (!ctx->_Shader->CurrentProgram[MESA_SHADER_FRAGMENT]) { - if (ctx->FragmentProgram.Enabled && - !_mesa_arb_fragment_program_enabled(ctx)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "%s(fragment program not valid)", where); - return GL_FALSE; - } - - /* If drawing to integer-valued color buffers, there must be an - * active fragment shader (GL_EXT_texture_integer). - */ - if (ctx->DrawBuffer && ctx->DrawBuffer->_IntegerBuffers) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "%s(integer format but no fragment shader)", where); - return GL_FALSE; - } - } - } - if (!check_blend_func_error(ctx)) { return GL_FALSE; } @@ -230,6 +199,20 @@ _mesa_update_valid_to_render_state(struct gl_context *ctx) !_mesa_sampler_uniforms_are_valid(shader->ActiveProgram, NULL, 0)) return; + if (ctx->API == API_OPENGL_COMPAT) { + if (!shader->CurrentProgram[MESA_SHADER_FRAGMENT]) { + if (ctx->FragmentProgram.Enabled && + !_mesa_arb_fragment_program_enabled(ctx)) + return; + + /* If drawing to integer-valued color buffers, there must be an + * active fragment shader (GL_EXT_texture_integer). + */ + if (ctx->DrawBuffer->_IntegerBuffers) + return; + } + } + /* DrawPixels/CopyPixels/Bitmap is valid after this point. */ ctx->DrawPixValid = true; @@ -300,7 +283,14 @@ _mesa_update_valid_to_render_state(struct gl_context *ctx) break; case API_OPENGLES: + break; + case API_OPENGL_COMPAT: + /* Check invalid ARB vertex programs. */ + if (!shader->CurrentProgram[MESA_SHADER_VERTEX] && + ctx->VertexProgram.Enabled && + !_mesa_arb_vertex_program_enabled(ctx)) + return; break; default: diff --git a/src/mesa/main/enable.c b/src/mesa/main/enable.c index 04831dd5125..2d4800ac4c1 100644 --- a/src/mesa/main/enable.c +++ b/src/mesa/main/enable.c @@ -1093,6 +1093,7 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state) FLUSH_VERTICES(ctx, _NEW_PROGRAM, GL_ENABLE_BIT); ctx->VertexProgram.Enabled = state; _mesa_update_vertex_processing_mode(ctx); + _mesa_update_valid_to_render_state(ctx); break; case GL_VERTEX_PROGRAM_POINT_SIZE_ARB: /* This was added with ARB_vertex_program, but it is also used with @@ -1148,6 +1149,7 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state) return; FLUSH_VERTICES(ctx, _NEW_PROGRAM, GL_ENABLE_BIT); ctx->FragmentProgram.Enabled = state; + _mesa_update_valid_to_render_state(ctx); break; /* GL_EXT_depth_bounds_test */ -- 2.34.1