summaryrefslogtreecommitdiffstats
path: root/src/mesa/main/api_validate.c
diff options
context:
space:
mode:
authorTimothy Arceri <[email protected]>2016-10-31 22:39:17 +1100
committerTimothy Arceri <[email protected]>2017-01-23 14:48:04 +1100
commitc505d6d852220f4aaaee161465dd2c579647e672 (patch)
treed77bf00e32a00b310fa09399974f5a51f99be073 /src/mesa/main/api_validate.c
parent31daeb5bf14334bc0d39f28c9102cd15d834abfc (diff)
mesa: use gl_program for CurrentProgram rather than gl_shader_program
This makes much more sense and should be more performant in some critical paths such as SSO validation which is called at draw time. Previously the CurrentProgram array could have contained multiple pointers to the same struct which was confusing and we would often need to fish out the information we were really after from the gl_program anyway. Also it was error prone to depend on the _LinkedShader array for programs in current use because a failed linking attempt will lose the infomation about the current program in use which is still valid. V2: fix validate_io() to compare linked_stages rather than the consumer and producer to decide if we are looking at inward facing shader interfaces which don't need validation. Acked-by: Edward O'Callaghan <[email protected]> To avoid build regressions the following 2 patches were squashed in to this commit: mesa/meta: rewrite _mesa_shader_program_use() and _mesa_program_use() These are rewritten to do what the function name suggests, that is _mesa_shader_program_use() sets the use of all stage and _mesa_program_use() sets the use of a single stage. Reviewed-by: Lionel Landwerlin <[email protected]> Acked-by: Edward O'Callaghan <[email protected]> mesa: update active relinked program This likely fixes a subroutine bug were _mesa_shader_program_init_subroutine_defaults() would never have been called for the relinked program as we previously just set _NEW_PROGRAM as dirty and never called the _mesa_use* functions when linking. Acked-by: Edward O'Callaghan <[email protected]>
Diffstat (limited to 'src/mesa/main/api_validate.c')
-rw-r--r--src/mesa/main/api_validate.c57
1 files changed, 22 insertions, 35 deletions
diff --git a/src/mesa/main/api_validate.c b/src/mesa/main/api_validate.c
index 5f051dbec6f..6c95701ea0e 100644
--- a/src/mesa/main/api_validate.c
+++ b/src/mesa/main/api_validate.c
@@ -191,12 +191,10 @@ _mesa_valid_to_render(struct gl_context *ctx, const char *where)
#ifdef DEBUG
if (ctx->_Shader->Flags & GLSL_LOG) {
- struct gl_shader_program **shProg = ctx->_Shader->CurrentProgram;
- gl_shader_stage i;
+ struct gl_program **prog = ctx->_Shader->CurrentProgram;
- for (i = 0; i < MESA_SHADER_STAGES; i++) {
- if (shProg[i] == NULL || shProg[i]->_LinkedShaders[i] == NULL ||
- shProg[i]->_LinkedShaders[i]->Program->_Used)
+ for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) {
+ if (prog[i] == NULL || prog[i]->_Used)
continue;
/* This is the first time this shader is being used.
@@ -208,12 +206,12 @@ _mesa_valid_to_render(struct gl_context *ctx, const char *where)
* program isn't also bound to the fragment shader target we don't
* want to log its fragment data.
*/
- _mesa_append_uniforms_to_file(shProg[i]->_LinkedShaders[i]->Program);
+ _mesa_append_uniforms_to_file(prog[i]);
}
- for (i = 0; i < MESA_SHADER_STAGES; i++) {
- if (shProg[i] != NULL && shProg[i]->_LinkedShaders[i] != NULL)
- shProg[i]->_LinkedShaders[i]->Program->_Used = GL_TRUE;
+ for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) {
+ if (prog[i] != NULL)
+ prog[i]->_Used = GL_TRUE;
}
}
#endif
@@ -394,17 +392,15 @@ _mesa_valid_prim_mode(struct gl_context *ctx, GLenum mode, const char *name)
if (ctx->_Shader->CurrentProgram[MESA_SHADER_GEOMETRY]) {
const GLenum geom_mode =
ctx->_Shader->CurrentProgram[MESA_SHADER_GEOMETRY]->
- _LinkedShaders[MESA_SHADER_GEOMETRY]->info.Geom.InputType;
- struct gl_shader_program *tes =
+ info.gs.input_primitive;
+ struct gl_program *tes =
ctx->_Shader->CurrentProgram[MESA_SHADER_TESS_EVAL];
GLenum mode_before_gs = mode;
if (tes) {
- struct gl_linked_shader *tes_sh =
- tes->_LinkedShaders[MESA_SHADER_TESS_EVAL];
- if (tes_sh->info.TessEval.PointMode)
+ if (tes->info.tess.point_mode)
mode_before_gs = GL_POINTS;
- else if (tes_sh->info.TessEval.PrimitiveMode == GL_ISOLINES)
+ else if (tes->info.tess.primitive_mode == GL_ISOLINES)
mode_before_gs = GL_LINES;
else
/* the GL_QUADS mode generates triangles too */
@@ -501,8 +497,7 @@ _mesa_valid_prim_mode(struct gl_context *ctx, GLenum mode, const char *name)
if(ctx->_Shader->CurrentProgram[MESA_SHADER_GEOMETRY]) {
switch (ctx->_Shader->CurrentProgram[MESA_SHADER_GEOMETRY]->
- _LinkedShaders[MESA_SHADER_GEOMETRY]->
- info.Geom.OutputType) {
+ info.gs.output_primitive) {
case GL_POINTS:
pass = ctx->TransformFeedback.Mode == GL_POINTS;
break;
@@ -517,13 +512,11 @@ _mesa_valid_prim_mode(struct gl_context *ctx, GLenum mode, const char *name)
}
}
else if (ctx->_Shader->CurrentProgram[MESA_SHADER_TESS_EVAL]) {
- struct gl_shader_program *tes =
+ struct gl_program *tes =
ctx->_Shader->CurrentProgram[MESA_SHADER_TESS_EVAL];
- struct gl_linked_shader *tes_sh =
- tes->_LinkedShaders[MESA_SHADER_TESS_EVAL];
- if (tes_sh->info.TessEval.PointMode)
+ if (tes->info.tess.point_mode)
pass = ctx->TransformFeedback.Mode == GL_POINTS;
- else if (tes_sh->info.TessEval.PrimitiveMode == GL_ISOLINES)
+ else if (tes->info.tess.primitive_mode == GL_ISOLINES)
pass = ctx->TransformFeedback.Mode == GL_LINES;
else
pass = ctx->TransformFeedback.Mode == GL_TRIANGLES;
@@ -1296,8 +1289,6 @@ _mesa_validate_MultiDrawElementsIndirectCount(struct gl_context *ctx,
static bool
check_valid_to_compute(struct gl_context *ctx, const char *function)
{
- struct gl_shader_program *prog;
-
if (!_mesa_has_compute_shaders(ctx)) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"unsupported function (%s) called",
@@ -1310,8 +1301,7 @@ check_valid_to_compute(struct gl_context *ctx, const char *function)
* "An INVALID_OPERATION error is generated if there is no active program
* for the compute shader stage."
*/
- prog = ctx->_Shader->CurrentProgram[MESA_SHADER_COMPUTE];
- if (prog == NULL || prog->_LinkedShaders[MESA_SHADER_COMPUTE] == NULL) {
+ if (ctx->_Shader->CurrentProgram[MESA_SHADER_COMPUTE] == NULL) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"%s(no active compute shader)",
function);
@@ -1325,7 +1315,6 @@ GLboolean
_mesa_validate_DispatchCompute(struct gl_context *ctx,
const GLuint *num_groups)
{
- struct gl_shader_program *prog;
int i;
FLUSH_CURRENT(ctx, 0);
@@ -1363,8 +1352,8 @@ _mesa_validate_DispatchCompute(struct gl_context *ctx,
* "An INVALID_OPERATION error is generated by DispatchCompute if the active
* program for the compute shader stage has a variable work group size."
*/
- prog = ctx->_Shader->CurrentProgram[MESA_SHADER_COMPUTE];
- if (prog->Comp.LocalSizeVariable) {
+ struct gl_program *prog = ctx->_Shader->CurrentProgram[MESA_SHADER_COMPUTE];
+ if (prog->info.cs.local_size_variable) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"glDispatchCompute(variable work group size forbidden)");
return GL_FALSE;
@@ -1378,7 +1367,6 @@ _mesa_validate_DispatchComputeGroupSizeARB(struct gl_context *ctx,
const GLuint *num_groups,
const GLuint *group_size)
{
- struct gl_shader_program *prog;
GLuint total_invocations = 1;
int i;
@@ -1393,8 +1381,8 @@ _mesa_validate_DispatchComputeGroupSizeARB(struct gl_context *ctx,
* DispatchComputeGroupSizeARB if the active program for the compute
* shader stage has a fixed work group size."
*/
- prog = ctx->_Shader->CurrentProgram[MESA_SHADER_COMPUTE];
- if (!prog->Comp.LocalSizeVariable) {
+ struct gl_program *prog = ctx->_Shader->CurrentProgram[MESA_SHADER_COMPUTE];
+ if (!prog->info.cs.local_size_variable) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"glDispatchComputeGroupSizeARB(fixed work group size "
"forbidden)");
@@ -1462,7 +1450,6 @@ valid_dispatch_indirect(struct gl_context *ctx,
GLsizei size, const char *name)
{
const uint64_t end = (uint64_t) indirect + size;
- struct gl_shader_program *prog;
if (!check_valid_to_compute(ctx, name))
return GL_FALSE;
@@ -1513,8 +1500,8 @@ valid_dispatch_indirect(struct gl_context *ctx,
* "An INVALID_OPERATION error is generated if the active program for the
* compute shader stage has a variable work group size."
*/
- prog = ctx->_Shader->CurrentProgram[MESA_SHADER_COMPUTE];
- if (prog->Comp.LocalSizeVariable) {
+ struct gl_program *prog = ctx->_Shader->CurrentProgram[MESA_SHADER_COMPUTE];
+ if (prog->info.cs.local_size_variable) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"%s(variable work group size forbidden)", name);
return GL_FALSE;