glsl: Keep track of location for interface block fields.
This patch adds a "location" element to struct glsl_struct_field, so that we can keep track of the gl_varying_slot associated with each built-in geometry shader input. In lower_named_interface_blocks, we use this value to populate the "location" field in the ir_variable that stores each geometry shader input. Reviewed-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
This commit is contained in:
parent
e166a58c43
commit
378ff1dbac
|
@ -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) {
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue