diff options
author | Marek Olšák <[email protected]> | 2017-06-10 17:22:09 +0200 |
---|---|---|
committer | Marek Olšák <[email protected]> | 2017-06-22 01:51:02 +0200 |
commit | 670c4dd3957efe0022a3ac36074fd89a5873d953 (patch) | |
tree | 13668237b0a6a149a43204f608ce817c8614f9dd /src | |
parent | 0b70d6ec568a2c5d7b2ff814e6e26b6d1379c829 (diff) |
mesa: don't flag _NEW_PROGRAM_CONSTANTS for non-GLSL programs for st/mesa
This has the benefit that we get to set up constants for exactly
the shader stage that needs it.
Reviewed-by: Nicolai Hähnle <[email protected]>
Reviewed-by: Brian Paul <[email protected]>
Reviewed-by: Timothy Arceri <[email protected]>
Diffstat (limited to 'src')
-rw-r--r-- | src/mesa/main/arbprogram.c | 30 | ||||
-rw-r--r-- | src/mesa/main/mtypes.h | 3 | ||||
-rw-r--r-- | src/mesa/main/state.c | 14 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_context.c | 10 |
4 files changed, 49 insertions, 8 deletions
diff --git a/src/mesa/main/arbprogram.c b/src/mesa/main/arbprogram.c index f3a0a54c016..625dc667f80 100644 --- a/src/mesa/main/arbprogram.c +++ b/src/mesa/main/arbprogram.c @@ -41,6 +41,23 @@ #include "program/program.h" #include "program/prog_print.h" +static void +flush_vertices_for_program_constants(struct gl_context *ctx, GLenum target) +{ + uint64_t new_driver_state; + + if (target == GL_FRAGMENT_PROGRAM_ARB) { + new_driver_state = + ctx->DriverFlags.NewShaderConstants[MESA_SHADER_FRAGMENT]; + } else { + new_driver_state = + ctx->DriverFlags.NewShaderConstants[MESA_SHADER_VERTEX]; + } + + FLUSH_VERTICES(ctx, new_driver_state ? 0 : _NEW_PROGRAM_CONSTANTS); + ctx->NewDriverState |= new_driver_state; +} + /** * Bind a program (make it current) * \note Called from the GL API dispatcher by both glBindProgramNV @@ -105,7 +122,8 @@ _mesa_BindProgramARB(GLenum target, GLuint id) } /* signal new program (and its new constants) */ - FLUSH_VERTICES(ctx, _NEW_PROGRAM | _NEW_PROGRAM_CONSTANTS); + FLUSH_VERTICES(ctx, _NEW_PROGRAM); + flush_vertices_for_program_constants(ctx, target); /* bind newProg */ if (target == GL_VERTEX_PROGRAM_ARB) { @@ -434,7 +452,7 @@ _mesa_ProgramEnvParameter4fARB(GLenum target, GLuint index, GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, _NEW_PROGRAM_CONSTANTS); + flush_vertices_for_program_constants(ctx, target); if (get_env_param_pointer(ctx, "glProgramEnvParameter", target, index, ¶m)) { @@ -456,7 +474,7 @@ _mesa_ProgramEnvParameter4fvARB(GLenum target, GLuint index, GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, _NEW_PROGRAM_CONSTANTS); + flush_vertices_for_program_constants(ctx, target); if (get_env_param_pointer(ctx, "glProgramEnvParameter4fv", target, index, ¶m)) { @@ -472,7 +490,7 @@ _mesa_ProgramEnvParameters4fvEXT(GLenum target, GLuint index, GLsizei count, GET_CURRENT_CONTEXT(ctx); GLfloat * dest; - FLUSH_VERTICES(ctx, _NEW_PROGRAM_CONSTANTS); + flush_vertices_for_program_constants(ctx, target); if (count <= 0) { _mesa_error(ctx, GL_INVALID_VALUE, "glProgramEnvParameters4fv(count)"); @@ -539,7 +557,7 @@ _mesa_ProgramLocalParameter4fARB(GLenum target, GLuint index, GET_CURRENT_CONTEXT(ctx); GLfloat *param; - FLUSH_VERTICES(ctx, _NEW_PROGRAM_CONSTANTS); + flush_vertices_for_program_constants(ctx, target); if (get_local_param_pointer(ctx, "glProgramLocalParameterARB", target, index, ¶m)) { @@ -565,7 +583,7 @@ _mesa_ProgramLocalParameters4fvEXT(GLenum target, GLuint index, GLsizei count, GET_CURRENT_CONTEXT(ctx); GLfloat *dest; - FLUSH_VERTICES(ctx, _NEW_PROGRAM_CONSTANTS); + flush_vertices_for_program_constants(ctx, target); if (count <= 0) { _mesa_error(ctx, GL_INVALID_VALUE, "glProgramLocalParameters4fv(count)"); diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index bc99da97f3e..0cb002469b2 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -4531,6 +4531,9 @@ struct gl_driver_flags /** gl_context::ViewportArray */ uint64_t NewViewport; + + /** Shader constants (uniforms, program parameters, state constants) */ + uint64_t NewShaderConstants[MESA_SHADER_STAGES]; }; struct gl_uniform_buffer_binding diff --git a/src/mesa/main/state.c b/src/mesa/main/state.c index 2b4d8d46ea0..7aec98e5784 100644 --- a/src/mesa/main/state.c +++ b/src/mesa/main/state.c @@ -230,7 +230,12 @@ update_program_constants(struct gl_context *ctx) const struct gl_program_parameter_list *params = ctx->FragmentProgram._Current->Parameters; if (params && params->StateFlags & ctx->NewState) { - new_state |= _NEW_PROGRAM_CONSTANTS; + if (ctx->DriverFlags.NewShaderConstants[MESA_SHADER_FRAGMENT]) { + ctx->NewDriverState |= + ctx->DriverFlags.NewShaderConstants[MESA_SHADER_FRAGMENT]; + } else { + new_state |= _NEW_PROGRAM_CONSTANTS; + } } } @@ -242,7 +247,12 @@ update_program_constants(struct gl_context *ctx) const struct gl_program_parameter_list *params = ctx->VertexProgram._Current->Parameters; if (params && params->StateFlags & ctx->NewState) { - new_state |= _NEW_PROGRAM_CONSTANTS; + if (ctx->DriverFlags.NewShaderConstants[MESA_SHADER_VERTEX]) { + ctx->NewDriverState |= + ctx->DriverFlags.NewShaderConstants[MESA_SHADER_VERTEX]; + } else { + new_state |= _NEW_PROGRAM_CONSTANTS; + } } } diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c index 41039a0453c..f74f3912343 100644 --- a/src/mesa/state_tracker/st_context.c +++ b/src/mesa/state_tracker/st_context.c @@ -486,10 +486,20 @@ static void st_init_driver_flags(struct st_context *st) f->NewRasterizerDiscard = ST_NEW_RASTERIZER; f->NewUniformBuffer = ST_NEW_UNIFORM_BUFFER; f->NewDefaultTessLevels = ST_NEW_TESS_STATE; + + /* Shader resources */ f->NewTextureBuffer = ST_NEW_SAMPLER_VIEWS; f->NewAtomicBuffer = ST_NEW_ATOMIC_BUFFER; f->NewShaderStorageBuffer = ST_NEW_STORAGE_BUFFER; f->NewImageUnits = ST_NEW_IMAGE_UNITS; + + f->NewShaderConstants[MESA_SHADER_VERTEX] = ST_NEW_VS_CONSTANTS; + f->NewShaderConstants[MESA_SHADER_TESS_CTRL] = ST_NEW_TCS_CONSTANTS; + f->NewShaderConstants[MESA_SHADER_TESS_EVAL] = ST_NEW_TES_CONSTANTS; + f->NewShaderConstants[MESA_SHADER_GEOMETRY] = ST_NEW_GS_CONSTANTS; + f->NewShaderConstants[MESA_SHADER_FRAGMENT] = ST_NEW_FS_CONSTANTS; + f->NewShaderConstants[MESA_SHADER_COMPUTE] = ST_NEW_CS_CONSTANTS; + f->NewWindowRectangles = ST_NEW_WINDOW_RECTANGLES; f->NewFramebufferSRGB = ST_NEW_FB_STATE; f->NewScissorRect = ST_NEW_SCISSOR; |