summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTimothy Arceri <timothy.arceri@collabora.com>2015-12-30 13:31:24 +1100
committerTimothy Arceri <timothy.arceri@collabora.com>2016-03-05 19:38:34 +1100
commit9f24f42c491221a79641a0d810f9c78393d81e5c (patch)
tree82e74776fa31f1431aadf3b79cbff58067d8682e /src
parent8abed7f185329250adf9f8c90a131797feda83b6 (diff)
downloadexternal_mesa3d-9f24f42c491221a79641a0d810f9c78393d81e5c.zip
external_mesa3d-9f24f42c491221a79641a0d810f9c78393d81e5c.tar.gz
external_mesa3d-9f24f42c491221a79641a0d810f9c78393d81e5c.tar.bz2
glsl: add offset to glsl interface type
In this patch we also copy the offset value from the ast and implement offset linking rules by adding it to the record_compare() function. From Section 4.4.5 (Uniform and Shader Storage Block Layout Qualifiers) of the GLSL 4.50 spec: "Two blocks linked together in the same program with the same block name must have the exact same set of members qualified with offset and their integral-constant-expression values must be the same, or a link-time error results." Reviewed-by: Edward O'Callaghan <eocallaghan@alterapraxis.com>
Diffstat (limited to 'src')
-rw-r--r--src/compiler/glsl/ast_to_hir.cpp4
-rw-r--r--src/compiler/glsl/builtin_variables.cpp1
-rw-r--r--src/compiler/glsl_types.cpp5
-rw-r--r--src/compiler/glsl_types.h8
4 files changed, 18 insertions, 0 deletions
diff --git a/src/compiler/glsl/ast_to_hir.cpp b/src/compiler/glsl/ast_to_hir.cpp
index cd94fa0..60b008c 100644
--- a/src/compiler/glsl/ast_to_hir.cpp
+++ b/src/compiler/glsl/ast_to_hir.cpp
@@ -6498,6 +6498,7 @@ ast_process_struct_or_iface_block_members(exec_list *instructions,
"must be a multiple of the base "
"alignment of %s", field_type->name);
}
+ fields[i].offset = qual_offset;
next_offset = glsl_align(qual_offset + size, align);
} else {
_mesa_glsl_error(&loc, state, "offset can only be used "
@@ -6505,6 +6506,7 @@ ast_process_struct_or_iface_block_members(exec_list *instructions,
}
}
} else {
+ fields[i].offset = -1;
if (align != 0 && size != 0)
next_offset = glsl_align(next_offset + size, align);
}
@@ -6883,6 +6885,8 @@ ast_interface_block::hir(exec_list *instructions,
} else {
fields[i].location =
earlier_per_vertex->fields.structure[j].location;
+ fields[i].offset =
+ earlier_per_vertex->fields.structure[j].offset;
fields[i].interpolation =
earlier_per_vertex->fields.structure[j].interpolation;
fields[i].centroid =
diff --git a/src/compiler/glsl/builtin_variables.cpp b/src/compiler/glsl/builtin_variables.cpp
index d20fc4a..4e2de37 100644
--- a/src/compiler/glsl/builtin_variables.cpp
+++ b/src/compiler/glsl/builtin_variables.cpp
@@ -323,6 +323,7 @@ per_vertex_accumulator::add_field(int slot, const glsl_type *type,
this->fields[this->num_fields].name = name;
this->fields[this->num_fields].matrix_layout = GLSL_MATRIX_LAYOUT_INHERITED;
this->fields[this->num_fields].location = slot;
+ this->fields[this->num_fields].offset = -1;
this->fields[this->num_fields].interpolation = INTERP_QUALIFIER_NONE;
this->fields[this->num_fields].centroid = 0;
this->fields[this->num_fields].sample = 0;
diff --git a/src/compiler/glsl_types.cpp b/src/compiler/glsl_types.cpp
index c549230..2421bd6 100644
--- a/src/compiler/glsl_types.cpp
+++ b/src/compiler/glsl_types.cpp
@@ -120,6 +120,7 @@ glsl_type::glsl_type(const glsl_struct_field *fields, unsigned num_fields,
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].offset = fields[i].offset;
this->fields.structure[i].interpolation = fields[i].interpolation;
this->fields.structure[i].centroid = fields[i].centroid;
this->fields.structure[i].sample = fields[i].sample;
@@ -159,6 +160,7 @@ glsl_type::glsl_type(const glsl_struct_field *fields, unsigned num_fields,
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].offset = fields[i].offset;
this->fields.structure[i].interpolation = fields[i].interpolation;
this->fields.structure[i].centroid = fields[i].centroid;
this->fields.structure[i].sample = fields[i].sample;
@@ -880,6 +882,9 @@ glsl_type::record_compare(const glsl_type *b) const
if (this->fields.structure[i].location
!= b->fields.structure[i].location)
return false;
+ if (this->fields.structure[i].offset
+ != b->fields.structure[i].offset)
+ return false;
if (this->fields.structure[i].interpolation
!= b->fields.structure[i].interpolation)
return false;
diff --git a/src/compiler/glsl_types.h b/src/compiler/glsl_types.h
index 2f612d8..b0e6f3f 100644
--- a/src/compiler/glsl_types.h
+++ b/src/compiler/glsl_types.h
@@ -838,6 +838,14 @@ struct glsl_struct_field {
int location;
/**
+ * For interface blocks, members may have an explicit byte offset
+ * specified; -1 otherwise.
+ *
+ * Ignored for structs.
+ */
+ int offset;
+
+ /**
* For interface blocks, the interpolation mode (as in
* ir_variable::interpolation). 0 otherwise.
*/