From 24b3be093870a9a77325ac33c8fce97fae143e8e Mon Sep 17 00:00:00 2001 From: Timothy Arceri Date: Wed, 22 Jun 2016 12:41:27 +1000 Subject: [PATCH] glsl/mesa: stop duplicating tes layout values MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit We already store this in gl_shader and gl_program here we remove it from gl_shader_program and just use the values from gl_shader. This will allow us to keep the shader cache restore code as simple as it can be while making it somewhat clearer where these values originate from. V2: remove unnecessary NULL check Reviewed-by: Marek Olšák Reviewed-by: Iago Toral --- src/compiler/glsl/linker.cpp | 4 ---- src/mesa/main/api_validate.c | 11 ++++++----- src/mesa/main/mtypes.h | 7 ------- src/mesa/main/shaderapi.c | 34 ++++++++++++++++++++++------------ 4 files changed, 28 insertions(+), 28 deletions(-) diff --git a/src/compiler/glsl/linker.cpp b/src/compiler/glsl/linker.cpp index 15481ffc75e..bf70f29039f 100644 --- a/src/compiler/glsl/linker.cpp +++ b/src/compiler/glsl/linker.cpp @@ -1886,19 +1886,15 @@ link_tes_in_layout_qualifiers(struct gl_shader_program *prog, "primitive modes.\n"); return; } - prog->TessEval.PrimitiveMode = linked_shader->TessEval.PrimitiveMode; if (linked_shader->TessEval.Spacing == 0) linked_shader->TessEval.Spacing = GL_EQUAL; - prog->TessEval.Spacing = linked_shader->TessEval.Spacing; if (linked_shader->TessEval.VertexOrder == 0) linked_shader->TessEval.VertexOrder = GL_CCW; - prog->TessEval.VertexOrder = linked_shader->TessEval.VertexOrder; if (linked_shader->TessEval.PointMode == -1) linked_shader->TessEval.PointMode = GL_FALSE; - prog->TessEval.PointMode = linked_shader->TessEval.PointMode; } diff --git a/src/mesa/main/api_validate.c b/src/mesa/main/api_validate.c index 4ef86b89ea5..ab34d99834c 100644 --- a/src/mesa/main/api_validate.c +++ b/src/mesa/main/api_validate.c @@ -206,9 +206,10 @@ _mesa_valid_prim_mode(struct gl_context *ctx, GLenum mode, const char *name) GLenum mode_before_gs = mode; if (tes) { - if (tes->TessEval.PointMode) + struct gl_shader *tes_sh = tes->_LinkedShaders[MESA_SHADER_TESS_EVAL]; + if (tes_sh->TessEval.PointMode) mode_before_gs = GL_POINTS; - else if (tes->TessEval.PrimitiveMode == GL_ISOLINES) + else if (tes_sh->TessEval.PrimitiveMode == GL_ISOLINES) mode_before_gs = GL_LINES; else /* the GL_QUADS mode generates triangles too */ @@ -321,10 +322,10 @@ _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 = ctx->_Shader->CurrentProgram[MESA_SHADER_TESS_EVAL]; - - if (tes->TessEval.PointMode) + struct gl_shader *tes_sh = tes->_LinkedShaders[MESA_SHADER_TESS_EVAL]; + if (tes_sh->TessEval.PointMode) pass = ctx->TransformFeedback.Mode == GL_POINTS; - else if (tes->TessEval.PrimitiveMode == GL_ISOLINES) + else if (tes_sh->TessEval.PrimitiveMode == GL_ISOLINES) pass = ctx->TransformFeedback.Mode == GL_LINES; else pass = ctx->TransformFeedback.Mode == GL_TRIANGLES; diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index e5ae5e6259a..99fa779a807 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -2726,13 +2726,6 @@ struct gl_shader_program * Tessellation Evaluation shader state from layout qualifiers. */ struct { - /** GL_TRIANGLES, GL_QUADS or GL_ISOLINES */ - GLenum PrimitiveMode; - /** GL_EQUAL, GL_FRACTIONAL_ODD or GL_FRACTIONAL_EVEN */ - GLenum Spacing; - /** GL_CW or GL_CCW */ - GLenum VertexOrder; - bool PointMode; /** * True if gl_ClipDistance is written to. Copied into * gl_tess_eval_program by _mesa_copy_linked_program_data(). diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c index 00caa1b4459..b65c0dc6c37 100644 --- a/src/mesa/main/shaderapi.c +++ b/src/mesa/main/shaderapi.c @@ -831,26 +831,34 @@ get_programiv(struct gl_context *ctx, GLuint program, GLenum pname, case GL_TESS_GEN_MODE: if (!has_tess) break; - if (check_tes_query(ctx, shProg)) - *params = shProg->TessEval.PrimitiveMode; + if (check_tes_query(ctx, shProg)) { + *params = shProg->_LinkedShaders[MESA_SHADER_TESS_EVAL]-> + TessEval.PrimitiveMode; + } return; case GL_TESS_GEN_SPACING: if (!has_tess) break; - if (check_tes_query(ctx, shProg)) - *params = shProg->TessEval.Spacing; + if (check_tes_query(ctx, shProg)) { + *params = shProg->_LinkedShaders[MESA_SHADER_TESS_EVAL]-> + TessEval.Spacing; + } return; case GL_TESS_GEN_VERTEX_ORDER: if (!has_tess) break; - if (check_tes_query(ctx, shProg)) - *params = shProg->TessEval.VertexOrder; + if (check_tes_query(ctx, shProg)) { + *params = shProg->_LinkedShaders[MESA_SHADER_TESS_EVAL]-> + TessEval.VertexOrder; + } return; case GL_TESS_GEN_POINT_MODE: if (!has_tess) break; - if (check_tes_query(ctx, shProg)) - *params = shProg->TessEval.PointMode; + if (check_tes_query(ctx, shProg)) { + *params = shProg->_LinkedShaders[MESA_SHADER_TESS_EVAL]-> + TessEval.PointMode; + } return; default: break; @@ -2157,10 +2165,12 @@ _mesa_copy_linked_program_data(gl_shader_stage type, case MESA_SHADER_TESS_EVAL: { struct gl_tess_eval_program *dst_tep = (struct gl_tess_eval_program *) dst; - dst_tep->PrimitiveMode = src->TessEval.PrimitiveMode; - dst_tep->Spacing = src->TessEval.Spacing; - dst_tep->VertexOrder = src->TessEval.VertexOrder; - dst_tep->PointMode = src->TessEval.PointMode; + struct gl_shader *tes_sh = src->_LinkedShaders[MESA_SHADER_TESS_EVAL]; + + dst_tep->PrimitiveMode = tes_sh->TessEval.PrimitiveMode; + dst_tep->Spacing = tes_sh->TessEval.Spacing; + dst_tep->VertexOrder = tes_sh->TessEval.VertexOrder; + dst_tep->PointMode = tes_sh->TessEval.PointMode; dst->ClipDistanceArraySize = src->TessEval.ClipDistanceArraySize; dst->CullDistanceArraySize = src->TessEval.CullDistanceArraySize; break; -- 2.30.2