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 <nicolai.haehnle@amd.com>
This commit is contained in:
@@ -64,7 +64,7 @@ interstage_member_mismatch(struct gl_shader_program *prog,
|
|||||||
* interpolation qualifiers of variables of the same name do not
|
* interpolation qualifiers of variables of the same name do not
|
||||||
* match."
|
* match."
|
||||||
*/
|
*/
|
||||||
if (prog->IsES || prog->Version < 440)
|
if (prog->IsES || prog->data->Version < 440)
|
||||||
if (c->fields.structure[i].interpolation !=
|
if (c->fields.structure[i].interpolation !=
|
||||||
p->fields.structure[i].interpolation)
|
p->fields.structure[i].interpolation)
|
||||||
return true;
|
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
|
* The table in Section 9.2.1 Linked Shaders of the GLSL ES 3.2 spec
|
||||||
* says that sample need not match for varyings.
|
* 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 !=
|
if (c->fields.structure[i].centroid !=
|
||||||
p->fields.structure[i].centroid)
|
p->fields.structure[i].centroid)
|
||||||
return true;
|
return true;
|
||||||
@@ -114,7 +114,7 @@ intrastage_match(ir_variable *a,
|
|||||||
*/
|
*/
|
||||||
if ((a->data.how_declared != ir_var_declared_implicitly ||
|
if ((a->data.how_declared != ir_var_declared_implicitly ||
|
||||||
b->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(),
|
interstage_member_mismatch(prog, a->get_interface_type(),
|
||||||
b->get_interface_type())))
|
b->get_interface_type())))
|
||||||
return false;
|
return false;
|
||||||
|
@@ -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.
|
* OpenGLES 3.0 drivers, so we relax the checking in all cases.
|
||||||
*/
|
*/
|
||||||
if (false /* always skip the centroid check */ &&
|
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) {
|
input->data.centroid != output->data.centroid) {
|
||||||
linker_error(prog,
|
linker_error(prog,
|
||||||
"%s shader output `%s' %s centroid qualifier, "
|
"%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."
|
* and fragment shaders must match."
|
||||||
*/
|
*/
|
||||||
if (input->data.invariant != output->data.invariant &&
|
if (input->data.invariant != output->data.invariant &&
|
||||||
prog->Version < (prog->IsES ? 300 : 430)) {
|
prog->data->Version < (prog->IsES ? 300 : 430)) {
|
||||||
linker_error(prog,
|
linker_error(prog,
|
||||||
"%s shader output `%s' %s invariant qualifier, "
|
"%s shader output `%s' %s invariant qualifier, "
|
||||||
"but %s shader input %s invariant qualifier\n",
|
"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 &&
|
if (input->data.interpolation != output->data.interpolation &&
|
||||||
prog->Version < 440) {
|
prog->data->Version < 440) {
|
||||||
linker_error(prog,
|
linker_error(prog,
|
||||||
"%s shader output `%s' specifies %s "
|
"%s shader output `%s' specifies %s "
|
||||||
"interpolation qualifier, "
|
"interpolation qualifier, "
|
||||||
@@ -2234,7 +2234,7 @@ assign_varying_locations(struct gl_context *ctx,
|
|||||||
|
|
||||||
if (var && var->data.mode == ir_var_shader_in &&
|
if (var && var->data.mode == ir_var_shader_in &&
|
||||||
var->data.is_unmatched_generic_inout) {
|
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:
|
/* On page 25 (page 31 of the PDF) of the GLSL 1.20 spec:
|
||||||
*
|
*
|
||||||
* Only those varying variables used (i.e. read) in
|
* Only those varying variables used (i.e. read) in
|
||||||
|
@@ -553,7 +553,7 @@ analyze_clip_cull_usage(struct gl_shader_program *prog,
|
|||||||
*clip_distance_array_size = 0;
|
*clip_distance_array_size = 0;
|
||||||
*cull_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
|
/* From section 7.1 (Vertex Shader Special Variables) of the
|
||||||
* GLSL 1.30 spec:
|
* 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
|
* All GLSL ES Versions are similar to GLSL 1.40--failing to write to
|
||||||
* gl_Position is not an error.
|
* 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_assignment_visitor find("gl_Position");
|
||||||
find.run(shader->ir);
|
find.run(shader->ir);
|
||||||
if (!find.variable_found()) {
|
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
|
* In GLSL ES 3.00 and ES 3.20, precision qualifier for each block
|
||||||
* member should match.
|
* 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) {
|
existing->data.precision != var->data.precision) {
|
||||||
linker_error(prog, "declarations for %s `%s` have "
|
linker_error(prog, "declarations for %s `%s` have "
|
||||||
"mismatching precision qualifiers\n",
|
"mismatching precision qualifiers\n",
|
||||||
@@ -1831,7 +1832,8 @@ link_fs_inout_layout_qualifiers(struct gl_shader_program *prog,
|
|||||||
linked_shader->info.BlendSupport = 0;
|
linked_shader->info.BlendSupport = 0;
|
||||||
|
|
||||||
if (linked_shader->Stage != MESA_SHADER_FRAGMENT ||
|
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;
|
return;
|
||||||
|
|
||||||
for (unsigned i = 0; i < num_shaders; i++) {
|
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+
|
/* No in/out qualifiers defined for anything but GLSL 1.50+
|
||||||
* geometry shaders so far.
|
* 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;
|
return;
|
||||||
|
|
||||||
/* From the GLSL 1.50 spec, page 46:
|
/* 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 ||
|
} 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 "
|
linker_error(prog, "overlapping location is assigned "
|
||||||
"to %s `%s' %d %d %d\n", string, var->name,
|
"to %s `%s' %d %d %d\n", string, var->name,
|
||||||
used_locations, use_mask, attr);
|
used_locations, use_mask, attr);
|
||||||
@@ -4355,10 +4358,12 @@ validate_sampler_array_indexing(struct gl_context *ctx,
|
|||||||
"expressions is forbidden in GLSL %s %u";
|
"expressions is forbidden in GLSL %s %u";
|
||||||
/* Backend has indicated that it has no dynamic indexing support. */
|
/* Backend has indicated that it has no dynamic indexing support. */
|
||||||
if (no_dynamic_indexing) {
|
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;
|
return false;
|
||||||
} else {
|
} 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;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
prog->Version = max_version;
|
prog->data->Version = max_version;
|
||||||
prog->IsES = prog->Shaders[0]->IsES;
|
prog->IsES = prog->Shaders[0]->IsES;
|
||||||
|
|
||||||
/* Some shaders have to be linked with some other shaders present.
|
/* 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
|
* with loop induction variable. This check emits a warning or error
|
||||||
* depending if backend can handle dynamic indexing.
|
* depending if backend can handle dynamic indexing.
|
||||||
*/
|
*/
|
||||||
if ((!prog->IsES && prog->Version < 130) ||
|
if ((!prog->IsES && prog->data->Version < 130) ||
|
||||||
(prog->IsES && prog->Version < 300)) {
|
(prog->IsES && prog->data->Version < 300)) {
|
||||||
if (!validate_sampler_array_indexing(ctx, prog))
|
if (!validate_sampler_array_indexing(ctx, prog))
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
@@ -2653,6 +2653,8 @@ struct gl_shader_program_data
|
|||||||
GLboolean Validated;
|
GLboolean Validated;
|
||||||
GLchar *InfoLog;
|
GLchar *InfoLog;
|
||||||
|
|
||||||
|
unsigned Version; /**< GLSL version used for linking */
|
||||||
|
|
||||||
/* Mask of stages this program was linked against */
|
/* Mask of stages this program was linked against */
|
||||||
unsigned linked_stages;
|
unsigned linked_stages;
|
||||||
};
|
};
|
||||||
@@ -2827,7 +2829,6 @@ struct gl_shader_program
|
|||||||
GLboolean _Used; /**< Ever used for drawing? */
|
GLboolean _Used; /**< Ever used for drawing? */
|
||||||
GLboolean SamplersValidated; /**< Samplers validated against texture units? */
|
GLboolean SamplersValidated; /**< Samplers validated against texture units? */
|
||||||
|
|
||||||
unsigned Version; /**< GLSL version used for linking */
|
|
||||||
bool IsES; /**< True if this program uses GLSL ES */
|
bool IsES; /**< True if this program uses GLSL ES */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -1098,7 +1098,7 @@ _mesa_link_program(struct gl_context *ctx, struct gl_shader_program *shProg)
|
|||||||
if (file) {
|
if (file) {
|
||||||
fprintf(file, "[require]\nGLSL%s >= %u.%02u\n",
|
fprintf(file, "[require]\nGLSL%s >= %u.%02u\n",
|
||||||
shProg->IsES ? " ES" : "",
|
shProg->IsES ? " ES" : "",
|
||||||
shProg->Version / 100, shProg->Version % 100);
|
shProg->data->Version / 100, shProg->data->Version % 100);
|
||||||
if (shProg->SeparateShader)
|
if (shProg->SeparateShader)
|
||||||
fprintf(file, "GL_ARB_separate_shader_objects\nSSO ENABLED\n");
|
fprintf(file, "GL_ARB_separate_shader_objects\nSSO ENABLED\n");
|
||||||
fprintf(file, "\n");
|
fprintf(file, "\n");
|
||||||
|
@@ -113,7 +113,7 @@ update_textures(struct st_context *st,
|
|||||||
GLuint unit;
|
GLuint unit;
|
||||||
struct gl_shader_program *shader =
|
struct gl_shader_program *shader =
|
||||||
st->ctx->_Shader->CurrentProgram[mesa_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);
|
enum pipe_shader_type shader_stage = st_shader_stage_to_ptarget(mesa_shader);
|
||||||
|
|
||||||
if (samplers_used == 0x0 && old_max == 0)
|
if (samplers_used == 0x0 && old_max == 0)
|
||||||
|
Reference in New Issue
Block a user