From ba10295bf87ae7c5ba9c37aa102123a9e23fe22e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Sat, 30 Jan 2021 18:59:10 -0500 Subject: [PATCH] mesa: move sampler uniform 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 | 17 ++++++----------- src/mesa/main/draw_validate.h | 8 ++++++++ src/mesa/main/uniform_query.cpp | 6 ++++++ 3 files changed, 20 insertions(+), 11 deletions(-) diff --git a/src/mesa/main/draw_validate.c b/src/mesa/main/draw_validate.c index 0ea1265f3d7..46846346210 100644 --- a/src/mesa/main/draw_validate.c +++ b/src/mesa/main/draw_validate.c @@ -160,17 +160,6 @@ _mesa_valid_to_render(struct gl_context *ctx, const char *where) } } - /* If a program is active and SSO not in use, check if validation of - * samplers succeeded for the active program. */ - if (ctx->_Shader->ActiveProgram && ctx->_Shader != ctx->Pipeline.Current) { - char errMsg[100]; - if (!_mesa_sampler_uniforms_are_valid(ctx->_Shader->ActiveProgram, - errMsg, 100)) { - _mesa_error(ctx, GL_INVALID_OPERATION, "%s", errMsg); - return GL_FALSE; - } - } - if (ctx->DrawBuffer->_Status != GL_FRAMEBUFFER_COMPLETE_EXT) { _mesa_error(ctx, GL_INVALID_FRAMEBUFFER_OPERATION_EXT, "%s(incomplete framebuffer)", where); @@ -256,6 +245,12 @@ _mesa_update_valid_to_render_state(struct gl_context *ctx) !_mesa_validate_program_pipeline(ctx, shader)) return; + /* If a program is active and SSO not in use, check if validation of + * samplers succeeded for the active program. */ + if (shader->ActiveProgram && shader != ctx->Pipeline.Current && + !_mesa_sampler_uniforms_are_valid(shader->ActiveProgram, NULL, 0)) + return; + /* DrawPixels/CopyPixels/Bitmap is valid after this point. */ ctx->DrawPixValid = true; diff --git a/src/mesa/main/draw_validate.h b/src/mesa/main/draw_validate.h index a10dbf6f68a..1962edad239 100644 --- a/src/mesa/main/draw_validate.h +++ b/src/mesa/main/draw_validate.h @@ -29,6 +29,10 @@ #include "mtypes.h" +#ifdef __cplusplus +extern "C" { +#endif + struct gl_buffer_object; struct gl_context; struct gl_transform_feedback_object; @@ -144,4 +148,8 @@ _mesa_is_valid_prim_mode(const struct gl_context *ctx, GLenum mode) return mode < 32 && (1u << mode) & ctx->SupportedPrimMask; } +#ifdef __cplusplus +} +#endif + #endif diff --git a/src/mesa/main/uniform_query.cpp b/src/mesa/main/uniform_query.cpp index 9d368ce27bb..c3833dcf988 100644 --- a/src/mesa/main/uniform_query.cpp +++ b/src/mesa/main/uniform_query.cpp @@ -29,6 +29,7 @@ #include #include "main/context.h" +#include "main/draw_validate.h" #include "main/shaderapi.h" #include "main/shaderobj.h" #include "main/uniforms.h" @@ -1255,6 +1256,7 @@ _mesa_uniform(GLint location, GLsizei count, const GLvoid *values, * FLUSH_VERTICES above. */ bool flushed = false; + bool any_changed = false; shProg->SamplersValidated = GL_TRUE; @@ -1303,8 +1305,12 @@ _mesa_uniform(GLint location, GLsizei count, const GLvoid *values, _mesa_update_shader_textures_used(shProg, prog); if (ctx->Driver.SamplerUniformChange) ctx->Driver.SamplerUniformChange(ctx, prog->Target, prog); + any_changed = true; } } + + if (any_changed) + _mesa_update_valid_to_render_state(ctx); } /* If the uniform is an image, update the mapping from image