diff options
author | Timothy Arceri <[email protected]> | 2016-11-09 14:56:08 +1100 |
---|---|---|
committer | Timothy Arceri <[email protected]> | 2016-12-02 13:54:47 +1100 |
commit | ab8c01386ac1c832f3143f57091ed5cf9725c151 (patch) | |
tree | 00ed2981f5dbe62cedb7c1fc7b51a59966036bca | |
parent | 534917495dca07bb63dbec49450c706fce36f176 (diff) |
st/mesa/glsl: move Version to gl_shader_program_data
This is mostly just used during linking however the st uses it
when updating textures.
In order to store gl_program in the CurrentProgram array
rather than gl_shader_program we need to move this field to
the shared gl_shader_program_data struct.
Reviewed-by: Nicolai Hähnle <[email protected]>
-rw-r--r-- | src/compiler/glsl/link_interface_blocks.cpp | 6 | ||||
-rw-r--r-- | src/compiler/glsl/link_varyings.cpp | 8 | ||||
-rw-r--r-- | src/compiler/glsl/linker.cpp | 27 | ||||
-rw-r--r-- | src/mesa/main/mtypes.h | 3 | ||||
-rw-r--r-- | src/mesa/main/shaderapi.c | 2 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_atom_texture.c | 2 |
6 files changed, 27 insertions, 21 deletions
diff --git a/src/compiler/glsl/link_interface_blocks.cpp b/src/compiler/glsl/link_interface_blocks.cpp index 4e91abc274d..7037c7776de 100644 --- a/src/compiler/glsl/link_interface_blocks.cpp +++ b/src/compiler/glsl/link_interface_blocks.cpp @@ -64,7 +64,7 @@ interstage_member_mismatch(struct gl_shader_program *prog, * interpolation qualifiers of variables of the same name do not * match." */ - if (prog->IsES || prog->Version < 440) + if (prog->IsES || prog->data->Version < 440) if (c->fields.structure[i].interpolation != p->fields.structure[i].interpolation) return true; @@ -83,7 +83,7 @@ interstage_member_mismatch(struct gl_shader_program *prog, * The table in Section 9.2.1 Linked Shaders of the GLSL ES 3.2 spec * says that sample need not match for varyings. */ - if (!prog->IsES || prog->Version < 310) + if (!prog->IsES || prog->data->Version < 310) if (c->fields.structure[i].centroid != p->fields.structure[i].centroid) return true; @@ -114,7 +114,7 @@ intrastage_match(ir_variable *a, */ if ((a->data.how_declared != ir_var_declared_implicitly || b->data.how_declared != ir_var_declared_implicitly) && - (!prog->IsES || prog->Version != 310 || + (!prog->IsES || prog->data->Version != 310 || interstage_member_mismatch(prog, a->get_interface_type(), b->get_interface_type()))) return false; diff --git a/src/compiler/glsl/link_varyings.cpp b/src/compiler/glsl/link_varyings.cpp index 308d9c5b9e6..866570c8238 100644 --- a/src/compiler/glsl/link_varyings.cpp +++ b/src/compiler/glsl/link_varyings.cpp @@ -271,7 +271,7 @@ cross_validate_types_and_qualifiers(struct gl_shader_program *prog, * OpenGLES 3.0 drivers, so we relax the checking in all cases. */ if (false /* always skip the centroid check */ && - prog->Version < (prog->IsES ? 310 : 430) && + prog->data->Version < (prog->IsES ? 310 : 430) && input->data.centroid != output->data.centroid) { linker_error(prog, "%s shader output `%s' %s centroid qualifier, " @@ -326,7 +326,7 @@ cross_validate_types_and_qualifiers(struct gl_shader_program *prog, * and fragment shaders must match." */ if (input->data.invariant != output->data.invariant && - prog->Version < (prog->IsES ? 300 : 430)) { + prog->data->Version < (prog->IsES ? 300 : 430)) { linker_error(prog, "%s shader output `%s' %s invariant qualifier, " "but %s shader input %s invariant qualifier\n", @@ -348,7 +348,7 @@ cross_validate_types_and_qualifiers(struct gl_shader_program *prog, * */ if (input->data.interpolation != output->data.interpolation && - prog->Version < 440) { + prog->data->Version < 440) { linker_error(prog, "%s shader output `%s' specifies %s " "interpolation qualifier, " @@ -2234,7 +2234,7 @@ assign_varying_locations(struct gl_context *ctx, if (var && var->data.mode == ir_var_shader_in && var->data.is_unmatched_generic_inout) { - if (!prog->IsES && prog->Version <= 120) { + if (!prog->IsES && prog->data->Version <= 120) { /* On page 25 (page 31 of the PDF) of the GLSL 1.20 spec: * * Only those varying variables used (i.e. read) in diff --git a/src/compiler/glsl/linker.cpp b/src/compiler/glsl/linker.cpp index 764938bdb6e..1aff5c7ffda 100644 --- a/src/compiler/glsl/linker.cpp +++ b/src/compiler/glsl/linker.cpp @@ -553,7 +553,7 @@ analyze_clip_cull_usage(struct gl_shader_program *prog, *clip_distance_array_size = 0; *cull_distance_array_size = 0; - if (prog->Version >= (prog->IsES ? 300 : 130)) { + if (prog->data->Version >= (prog->IsES ? 300 : 130)) { /* From section 7.1 (Vertex Shader Special Variables) of the * GLSL 1.30 spec: * @@ -672,7 +672,7 @@ validate_vertex_shader_executable(struct gl_shader_program *prog, * All GLSL ES Versions are similar to GLSL 1.40--failing to write to * gl_Position is not an error. */ - if (prog->Version < (prog->IsES ? 300 : 140)) { + if (prog->data->Version < (prog->IsES ? 300 : 140)) { find_assignment_visitor find("gl_Position"); find.run(shader->ir); if (!find.variable_found()) { @@ -1089,7 +1089,8 @@ cross_validate_globals(struct gl_shader_program *prog, * In GLSL ES 3.00 and ES 3.20, precision qualifier for each block * member should match. */ - if (prog->IsES && (prog->Version != 310 || !var->get_interface_type()) && + if (prog->IsES && (prog->data->Version != 310 || + !var->get_interface_type()) && existing->data.precision != var->data.precision) { linker_error(prog, "declarations for %s `%s` have " "mismatching precision qualifiers\n", @@ -1831,7 +1832,8 @@ link_fs_inout_layout_qualifiers(struct gl_shader_program *prog, linked_shader->info.BlendSupport = 0; if (linked_shader->Stage != MESA_SHADER_FRAGMENT || - (prog->Version < 150 && !prog->ARB_fragment_coord_conventions_enable)) + (prog->data->Version < 150 && + !prog->ARB_fragment_coord_conventions_enable)) return; for (unsigned i = 0; i < num_shaders; i++) { @@ -1910,7 +1912,8 @@ link_gs_inout_layout_qualifiers(struct gl_shader_program *prog, /* No in/out qualifiers defined for anything but GLSL 1.50+ * geometry shaders so far. */ - if (linked_shader->Stage != MESA_SHADER_GEOMETRY || prog->Version < 150) + if (linked_shader->Stage != MESA_SHADER_GEOMETRY || + prog->data->Version < 150) return; /* From the GLSL 1.50 spec, page 46: @@ -2806,7 +2809,7 @@ assign_attribute_or_color_locations(void *mem_ctx, } } } else if (target_index == MESA_SHADER_FRAGMENT || - (prog->IsES && prog->Version >= 300)) { + (prog->IsES && prog->data->Version >= 300)) { linker_error(prog, "overlapping location is assigned " "to %s `%s' %d %d %d\n", string, var->name, used_locations, use_mask, attr); @@ -4355,10 +4358,12 @@ validate_sampler_array_indexing(struct gl_context *ctx, "expressions is forbidden in GLSL %s %u"; /* Backend has indicated that it has no dynamic indexing support. */ if (no_dynamic_indexing) { - linker_error(prog, msg, prog->IsES ? "ES" : "", prog->Version); + linker_error(prog, msg, prog->IsES ? "ES" : "", + prog->data->Version); return false; } else { - linker_warning(prog, msg, prog->IsES ? "ES" : "", prog->Version); + linker_warning(prog, msg, prog->IsES ? "ES" : "", + prog->data->Version); } } } @@ -4790,7 +4795,7 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog) goto done; } - prog->Version = max_version; + prog->data->Version = max_version; prog->IsES = prog->Shaders[0]->IsES; /* Some shaders have to be linked with some other shaders present. @@ -5021,8 +5026,8 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog) * with loop induction variable. This check emits a warning or error * depending if backend can handle dynamic indexing. */ - if ((!prog->IsES && prog->Version < 130) || - (prog->IsES && prog->Version < 300)) { + if ((!prog->IsES && prog->data->Version < 130) || + (prog->IsES && prog->data->Version < 300)) { if (!validate_sampler_array_indexing(ctx, prog)) goto done; } diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 250877dd6b6..459725b029c 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -2653,6 +2653,8 @@ struct gl_shader_program_data GLboolean Validated; GLchar *InfoLog; + unsigned Version; /**< GLSL version used for linking */ + /* Mask of stages this program was linked against */ unsigned linked_stages; }; @@ -2827,7 +2829,6 @@ struct gl_shader_program GLboolean _Used; /**< Ever used for drawing? */ GLboolean SamplersValidated; /**< Samplers validated against texture units? */ - unsigned Version; /**< GLSL version used for linking */ bool IsES; /**< True if this program uses GLSL ES */ /** diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c index 83ee0d4ca7d..92bbc743051 100644 --- a/src/mesa/main/shaderapi.c +++ b/src/mesa/main/shaderapi.c @@ -1098,7 +1098,7 @@ _mesa_link_program(struct gl_context *ctx, struct gl_shader_program *shProg) if (file) { fprintf(file, "[require]\nGLSL%s >= %u.%02u\n", shProg->IsES ? " ES" : "", - shProg->Version / 100, shProg->Version % 100); + shProg->data->Version / 100, shProg->data->Version % 100); if (shProg->SeparateShader) fprintf(file, "GL_ARB_separate_shader_objects\nSSO ENABLED\n"); fprintf(file, "\n"); diff --git a/src/mesa/state_tracker/st_atom_texture.c b/src/mesa/state_tracker/st_atom_texture.c index a1b1b889554..5fe042b37ab 100644 --- a/src/mesa/state_tracker/st_atom_texture.c +++ b/src/mesa/state_tracker/st_atom_texture.c @@ -113,7 +113,7 @@ update_textures(struct st_context *st, GLuint unit; struct gl_shader_program *shader = st->ctx->_Shader->CurrentProgram[mesa_shader]; - unsigned glsl_version = shader ? shader->Version : 0; + unsigned glsl_version = shader ? shader->data->Version : 0; enum pipe_shader_type shader_stage = st_shader_stage_to_ptarget(mesa_shader); if (samplers_used == 0x0 && old_max == 0) |