mesa: move sampler uniform 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 18:59:10 -05:00 committed by Marge Bot
parent d9c611d671
commit ba10295bf8
3 changed files with 20 additions and 11 deletions

View File

@ -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;

View File

@ -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

View File

@ -29,6 +29,7 @@
#include <math.h>
#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