diff options
author | Iago Toral Quiroga <[email protected]> | 2017-10-20 09:18:33 +0200 |
---|---|---|
committer | Iago Toral Quiroga <[email protected]> | 2017-10-26 08:40:14 +0200 |
commit | e2abb75b0e4c2e38120316c4f3cc4cde44497330 (patch) | |
tree | 01d982e355508693098a8c0aeaf3edaa14638b76 /src/compiler/glsl/link_varyings.cpp | |
parent | bdaf0589785138f91cd485fd698274a33b7d33d5 (diff) |
glsl/linker: validate explicit locations for SSO programs
v2:
- we only need to validate inputs to the first stage and outputs
from the last stage, everything else has already been validated
during cross_validate_outputs_to_inputs (Timothy).
- Use MAX_VARYING instead of MAX_VARYINGS_INCL_PATCH (Illia)
Reviewed-by: Timothy Arceri <[email protected]>
Reviewed-by: Ilia Mirkin <[email protected]>
Diffstat (limited to 'src/compiler/glsl/link_varyings.cpp')
-rw-r--r-- | src/compiler/glsl/link_varyings.cpp | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/src/compiler/glsl/link_varyings.cpp b/src/compiler/glsl/link_varyings.cpp index 02a48f7199f..e80736fb383 100644 --- a/src/compiler/glsl/link_varyings.cpp +++ b/src/compiler/glsl/link_varyings.cpp @@ -600,6 +600,61 @@ validate_explicit_variable_location(struct gl_context *ctx, } /** + * Validate explicit locations for the inputs to the first stage and the + * outputs of the last stage in an SSO program (everything in between is + * validated in cross_validate_outputs_to_inputs). + */ +void +validate_sso_explicit_locations(struct gl_context *ctx, + struct gl_shader_program *prog, + gl_shader_stage first_stage, + gl_shader_stage last_stage) +{ + assert(prog->SeparateShader); + + /* VS inputs and FS outputs are validated in + * assign_attribute_or_color_locations() + */ + bool validate_first_stage = first_stage != MESA_SHADER_VERTEX; + bool validate_last_stage = last_stage != MESA_SHADER_FRAGMENT; + if (!validate_first_stage && !validate_last_stage) + return; + + struct explicit_location_info explicit_locations[MAX_VARYING][4]; + + gl_shader_stage stages[2] = { first_stage, last_stage }; + bool validate_stage[2] = { validate_first_stage, validate_last_stage }; + ir_variable_mode var_direction[2] = { ir_var_shader_in, ir_var_shader_out }; + + for (unsigned i = 0; i < 2; i++) { + if (!validate_stage[i]) + continue; + + gl_shader_stage stage = stages[i]; + + gl_linked_shader *sh = prog->_LinkedShaders[stage]; + assert(sh); + + memset(explicit_locations, 0, sizeof(explicit_locations)); + + foreach_in_list(ir_instruction, node, sh->ir) { + ir_variable *const var = node->as_variable(); + + if (var == NULL || + !var->data.explicit_location || + var->data.location < VARYING_SLOT_VAR0 || + var->data.mode != var_direction[i]) + continue; + + if (!validate_explicit_variable_location( + ctx, explicit_locations, var, prog, sh)) { + return; + } + } + } +} + +/** * Validate that outputs from one stage match inputs of another */ void |