diff options
author | Paul Berry <[email protected]> | 2013-01-11 14:39:32 -0800 |
---|---|---|
committer | Paul Berry <[email protected]> | 2013-01-24 16:30:30 -0800 |
commit | 42a29d89fd85c86387f0d119950e243b6de76d79 (patch) | |
tree | 9eee8f2d609855dc9c6813aac84f5fdcd6786a54 /src/glsl/link_varyings.cpp | |
parent | 7d51ead56e2b97d313c6a0fda22cc930b5c41e9d (diff) |
glsl: Eliminate ambiguity between function ins/outs and shader ins/outs
This patch replaces the three ir_variable_mode enums:
- ir_var_in
- ir_var_out
- ir_var_inout
with the following five:
- ir_var_shader_in
- ir_var_shader_out
- ir_var_function_in
- ir_var_function_out
- ir_var_function_inout
This eliminates a frustrating ambiguity: it used to be impossible to
tell whether an ir_var_{in,out} variable was a shader in/out or a
function in/out without seeing where the variable was declared in the
IR. This complicated some optimization and lowering passes, and would
have become a problem for implementing varying structs.
In the lisp-style serialization of GLSL IR to strings performed by
ir_print_visitor.cpp and ir_reader.cpp, I've retained the names "in",
"out", and "inout" for function parameters, to avoid introducing code
churn to the src/glsl/builtins/ir/ directory.
Note: a couple of comments in the code seemed to indicate that we were
planning for a possible future in which geometry shaders could have
shader-scope inout variables. Our GLSL grammar rejects shader-scope
inout variables, and I've been unable to find any evidence in the GLSL
standards documents (or extensions) that this will ever be allowed, so
I've eliminated these comments.
Reviewed-by: Carl Worth <[email protected]>
Reviewed-by: Jordan Justen <[email protected]>
Reviewed-by: Eric Anholt <[email protected]>
Diffstat (limited to 'src/glsl/link_varyings.cpp')
-rw-r--r-- | src/glsl/link_varyings.cpp | 28 |
1 files changed, 11 insertions, 17 deletions
diff --git a/src/glsl/link_varyings.cpp b/src/glsl/link_varyings.cpp index 5c27f231e72..5a3240b9f71 100644 --- a/src/glsl/link_varyings.cpp +++ b/src/glsl/link_varyings.cpp @@ -54,10 +54,7 @@ cross_validate_outputs_to_inputs(struct gl_shader_program *prog, foreach_list(node, producer->ir) { ir_variable *const var = ((ir_instruction *) node)->as_variable(); - /* FINISHME: For geometry shaders, this should also look for inout - * FINISHME: variables. - */ - if ((var == NULL) || (var->mode != ir_var_out)) + if ((var == NULL) || (var->mode != ir_var_shader_out)) continue; parameters.add_variable(var); @@ -71,10 +68,7 @@ cross_validate_outputs_to_inputs(struct gl_shader_program *prog, foreach_list(node, consumer->ir) { ir_variable *const input = ((ir_instruction *) node)->as_variable(); - /* FINISHME: For geometry shaders, this should also look for inout - * FINISHME: variables. - */ - if ((input == NULL) || (input->mode != ir_var_in)) + if ((input == NULL) || (input->mode != ir_var_shader_in)) continue; ir_variable *const output = parameters.get_variable(input->name); @@ -417,7 +411,7 @@ tfeedback_decl::find_output_var(gl_shader_program *prog, const char *name = this->is_clip_distance_mesa ? "gl_ClipDistanceMESA" : this->var_name; ir_variable *var = producer->symbols->get_variable(name); - if (var && var->mode == ir_var_out) + if (var && var->mode == ir_var_shader_out) return var; /* From GL_EXT_transform_feedback: @@ -854,7 +848,7 @@ is_varying_var(GLenum shaderType, const ir_variable *var) { /* Only fragment shaders will take a varying variable as an input */ if (shaderType == GL_FRAGMENT_SHADER && - var->mode == ir_var_in) { + var->mode == ir_var_shader_in) { switch (var->location) { case FRAG_ATTRIB_WPOS: case FRAG_ATTRIB_FACE: @@ -915,13 +909,13 @@ assign_varying_locations(struct gl_context *ctx, foreach_list(node, producer->ir) { ir_variable *const output_var = ((ir_instruction *) node)->as_variable(); - if ((output_var == NULL) || (output_var->mode != ir_var_out)) + if ((output_var == NULL) || (output_var->mode != ir_var_shader_out)) continue; ir_variable *input_var = consumer ? consumer->symbols->get_variable(output_var->name) : NULL; - if (input_var && input_var->mode != ir_var_in) + if (input_var && input_var->mode != ir_var_shader_in) input_var = NULL; if (input_var) { @@ -965,11 +959,11 @@ assign_varying_locations(struct gl_context *ctx, */ assert(!ctx->Extensions.EXT_transform_feedback); } else { - lower_packed_varyings(mem_ctx, producer_base, slots_used, ir_var_out, - producer); + lower_packed_varyings(mem_ctx, producer_base, slots_used, + ir_var_shader_out, producer); if (consumer) { - lower_packed_varyings(mem_ctx, consumer_base, slots_used, ir_var_in, - consumer); + lower_packed_varyings(mem_ctx, consumer_base, slots_used, + ir_var_shader_in, consumer); } } @@ -979,7 +973,7 @@ assign_varying_locations(struct gl_context *ctx, foreach_list(node, consumer->ir) { ir_variable *const var = ((ir_instruction *) node)->as_variable(); - if ((var == NULL) || (var->mode != ir_var_in)) + if ((var == NULL) || (var->mode != ir_var_shader_in)) continue; if (var->is_unmatched_generic_inout) { |