diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp index 0859d9e00a3..275d7803648 100644 --- a/src/glsl/ast_to_hir.cpp +++ b/src/glsl/ast_to_hir.cpp @@ -4491,6 +4491,7 @@ ast_process_structure_or_interface_block(exec_list *instructions, } fields[i].type = field_type; fields[i].name = decl->identifier; + fields[i].location = -1; if (qual->flags.q.row_major || qual->flags.q.column_major) { if (!qual->flags.q.uniform) { diff --git a/src/glsl/builtin_types.cpp b/src/glsl/builtin_types.cpp index 722eda2da1e..1a5e5a19001 100644 --- a/src/glsl/builtin_types.cpp +++ b/src/glsl/builtin_types.cpp @@ -53,64 +53,64 @@ &glsl_type::_struct_##NAME##_type; static const struct glsl_struct_field gl_DepthRangeParameters_fields[] = { - { glsl_type::float_type, "near", false }, - { glsl_type::float_type, "far", false }, - { glsl_type::float_type, "diff", false }, + { glsl_type::float_type, "near", false, -1 }, + { glsl_type::float_type, "far", false, -1 }, + { glsl_type::float_type, "diff", false, -1 }, }; static const struct glsl_struct_field gl_PointParameters_fields[] = { - { glsl_type::float_type, "size", false }, - { glsl_type::float_type, "sizeMin", false }, - { glsl_type::float_type, "sizeMax", false }, - { glsl_type::float_type, "fadeThresholdSize", false }, - { glsl_type::float_type, "distanceConstantAttenuation", false }, - { glsl_type::float_type, "distanceLinearAttenuation", false }, - { glsl_type::float_type, "distanceQuadraticAttenuation", false }, + { glsl_type::float_type, "size", false, -1 }, + { glsl_type::float_type, "sizeMin", false, -1 }, + { glsl_type::float_type, "sizeMax", false, -1 }, + { glsl_type::float_type, "fadeThresholdSize", false, -1 }, + { glsl_type::float_type, "distanceConstantAttenuation", false, -1 }, + { glsl_type::float_type, "distanceLinearAttenuation", false, -1 }, + { glsl_type::float_type, "distanceQuadraticAttenuation", false, -1 }, }; static const struct glsl_struct_field gl_MaterialParameters_fields[] = { - { glsl_type::vec4_type, "emission", false }, - { glsl_type::vec4_type, "ambient", false }, - { glsl_type::vec4_type, "diffuse", false }, - { glsl_type::vec4_type, "specular", false }, - { glsl_type::float_type, "shininess", false }, + { glsl_type::vec4_type, "emission", false, -1 }, + { glsl_type::vec4_type, "ambient", false, -1 }, + { glsl_type::vec4_type, "diffuse", false, -1 }, + { glsl_type::vec4_type, "specular", false, -1 }, + { glsl_type::float_type, "shininess", false, -1 }, }; static const struct glsl_struct_field gl_LightSourceParameters_fields[] = { - { glsl_type::vec4_type, "ambient", false }, - { glsl_type::vec4_type, "diffuse", false }, - { glsl_type::vec4_type, "specular", false }, - { glsl_type::vec4_type, "position", false }, - { glsl_type::vec4_type, "halfVector", false }, - { glsl_type::vec3_type, "spotDirection", false }, - { glsl_type::float_type, "spotExponent", false }, - { glsl_type::float_type, "spotCutoff", false }, - { glsl_type::float_type, "spotCosCutoff", false }, - { glsl_type::float_type, "constantAttenuation", false }, - { glsl_type::float_type, "linearAttenuation", false }, - { glsl_type::float_type, "quadraticAttenuation", false }, + { glsl_type::vec4_type, "ambient", false, -1 }, + { glsl_type::vec4_type, "diffuse", false, -1 }, + { glsl_type::vec4_type, "specular", false, -1 }, + { glsl_type::vec4_type, "position", false, -1 }, + { glsl_type::vec4_type, "halfVector", false, -1 }, + { glsl_type::vec3_type, "spotDirection", false, -1 }, + { glsl_type::float_type, "spotExponent", false, -1 }, + { glsl_type::float_type, "spotCutoff", false, -1 }, + { glsl_type::float_type, "spotCosCutoff", false, -1 }, + { glsl_type::float_type, "constantAttenuation", false, -1 }, + { glsl_type::float_type, "linearAttenuation", false, -1 }, + { glsl_type::float_type, "quadraticAttenuation", false, -1 }, }; static const struct glsl_struct_field gl_LightModelParameters_fields[] = { - { glsl_type::vec4_type, "ambient", false }, + { glsl_type::vec4_type, "ambient", false, -1 }, }; static const struct glsl_struct_field gl_LightModelProducts_fields[] = { - { glsl_type::vec4_type, "sceneColor", false }, + { glsl_type::vec4_type, "sceneColor", false, -1 }, }; static const struct glsl_struct_field gl_LightProducts_fields[] = { - { glsl_type::vec4_type, "ambient", false }, - { glsl_type::vec4_type, "diffuse", false }, - { glsl_type::vec4_type, "specular", false }, + { glsl_type::vec4_type, "ambient", false, -1 }, + { glsl_type::vec4_type, "diffuse", false, -1 }, + { glsl_type::vec4_type, "specular", false, -1 }, }; static const struct glsl_struct_field gl_FogParameters_fields[] = { - { glsl_type::vec4_type, "color", false }, - { glsl_type::float_type, "density", false }, - { glsl_type::float_type, "start", false }, - { glsl_type::float_type, "end", false }, - { glsl_type::float_type, "scale", false }, + { glsl_type::vec4_type, "color", false, -1 }, + { glsl_type::float_type, "density", false, -1 }, + { glsl_type::float_type, "start", false, -1 }, + { glsl_type::float_type, "end", false, -1 }, + { glsl_type::float_type, "scale", false, -1 }, }; #include "builtin_type_macros.h" diff --git a/src/glsl/glsl_types.cpp b/src/glsl/glsl_types.cpp index 3c396dd8970..4782d159df2 100644 --- a/src/glsl/glsl_types.cpp +++ b/src/glsl/glsl_types.cpp @@ -100,6 +100,7 @@ glsl_type::glsl_type(const glsl_struct_field *fields, unsigned num_fields, this->fields.structure[i].type = fields[i].type; this->fields.structure[i].name = ralloc_strdup(this->fields.structure, fields[i].name); + this->fields.structure[i].location = fields[i].location; this->fields.structure[i].row_major = fields[i].row_major; } } @@ -124,6 +125,7 @@ glsl_type::glsl_type(const glsl_struct_field *fields, unsigned num_fields, this->fields.structure[i].type = fields[i].type; this->fields.structure[i].name = ralloc_strdup(this->fields.structure, fields[i].name); + this->fields.structure[i].location = fields[i].location; this->fields.structure[i].row_major = fields[i].row_major; } } diff --git a/src/glsl/glsl_types.h b/src/glsl/glsl_types.h index 9f61eee7878..61c86358ad0 100644 --- a/src/glsl/glsl_types.h +++ b/src/glsl/glsl_types.h @@ -581,6 +581,15 @@ struct glsl_struct_field { const struct glsl_type *type; const char *name; bool row_major; + + /** + * For interface blocks, gl_varying_slot corresponding to the input/output + * if this is a built-in input/output (i.e. a member of the built-in + * gl_PerVertex interface block); -1 otherwise. + * + * Ignored for structs. + */ + int location; }; static inline unsigned int diff --git a/src/glsl/lower_named_interface_blocks.cpp b/src/glsl/lower_named_interface_blocks.cpp index 7019185a2f3..5ad5683f63d 100644 --- a/src/glsl/lower_named_interface_blocks.cpp +++ b/src/glsl/lower_named_interface_blocks.cpp @@ -150,6 +150,7 @@ flatten_named_interface_blocks_declarations::run(exec_list *instructions) var_name, (ir_variable_mode) var->mode); } + new_var->location = iface_t->fields.structure[i].location; new_var->interface_type = iface_t; hash_table_insert(interface_namespace, new_var,