summaryrefslogtreecommitdiff
path: root/src/glsl/builtin_variables.cpp
diff options
context:
space:
mode:
authorPaul Berry <stereotype441@gmail.com>2013-09-29 08:17:12 -0700
committerPaul Berry <stereotype441@gmail.com>2013-10-10 14:27:00 -0700
commit5a234d92af2467f6a224e2aee966257656e5af80 (patch)
treeec1f0c5deff23668b31608e87087eefccb9d5105 /src/glsl/builtin_variables.cpp
parentfb41f2c531b1243e6eebfe7b02ac04b0fe66c24e (diff)
glsl: Construct gl_PerVertex interfaces for GS and VS outputs.
Although these interfaces can't be accessed directly by GLSL (since they don't have an instance name), they will be necessary in order to allow redeclarations of gl_PerVertex. Reviewed-by: Jordan Justen <jordan.l.justen@intel.com> Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Diffstat (limited to 'src/glsl/builtin_variables.cpp')
-rw-r--r--src/glsl/builtin_variables.cpp26
1 files changed, 19 insertions, 7 deletions
diff --git a/src/glsl/builtin_variables.cpp b/src/glsl/builtin_variables.cpp
index 60ad03b6b4c..ae0a03f0d47 100644
--- a/src/glsl/builtin_variables.cpp
+++ b/src/glsl/builtin_variables.cpp
@@ -404,7 +404,8 @@ private:
const glsl_type * const mat3_t;
const glsl_type * const mat4_t;
- per_vertex_accumulator per_vertex;
+ per_vertex_accumulator per_vertex_in;
+ per_vertex_accumulator per_vertex_out;
};
@@ -804,10 +805,10 @@ builtin_variable_generator::add_varying(int slot, const glsl_type *type,
{
switch (state->target) {
case geometry_shader:
- this->per_vertex.add_field(slot, type, name);
+ this->per_vertex_in.add_field(slot, type, name);
/* FALLTHROUGH */
case vertex_shader:
- add_output(slot, type, name);
+ this->per_vertex_out.add_field(slot, type, name);
break;
case fragment_shader:
add_input(slot, type, name);
@@ -853,11 +854,22 @@ builtin_variable_generator::generate_varyings()
}
if (state->target == geometry_shader) {
- const glsl_type *per_vertex_type =
- this->per_vertex.construct_interface_instance();
- ir_variable *var = add_variable("gl_in", array(per_vertex_type, 0),
+ const glsl_type *per_vertex_in_type =
+ this->per_vertex_in.construct_interface_instance();
+ ir_variable *var = add_variable("gl_in", array(per_vertex_in_type, 0),
ir_var_shader_in, -1);
- var->init_interface_type(per_vertex_type);
+ var->init_interface_type(per_vertex_in_type);
+ }
+ if (state->target == vertex_shader || state->target == geometry_shader) {
+ const glsl_type *per_vertex_out_type =
+ this->per_vertex_out.construct_interface_instance();
+ const glsl_struct_field *fields = per_vertex_out_type->fields.structure;
+ for (unsigned i = 0; i < per_vertex_out_type->length; i++) {
+ ir_variable *var =
+ add_variable(fields[i].name, fields[i].type, ir_var_shader_out,
+ fields[i].location);
+ var->init_interface_type(per_vertex_out_type);
+ }
}
}