summaryrefslogtreecommitdiffstats
path: root/src/compiler/glsl/linker.cpp
diff options
context:
space:
mode:
authorDave Airlie <airlied@redhat.com>2016-05-20 10:19:14 +1000
committerDave Airlie <airlied@redhat.com>2016-05-24 11:27:29 +1000
commit8c628ab13e4fa86ee662dcddb0f5a89b2d30e1a4 (patch)
treec7a3ca763ab93784e855bcdef773ea9c75e6bfeb /src/compiler/glsl/linker.cpp
parent2ae493d68647af26c64ae59f0127349d75817b91 (diff)
downloadexternal_mesa3d-8c628ab13e4fa86ee662dcddb0f5a89b2d30e1a4.zip
external_mesa3d-8c628ab13e4fa86ee662dcddb0f5a89b2d30e1a4.tar.gz
external_mesa3d-8c628ab13e4fa86ee662dcddb0f5a89b2d30e1a4.tar.bz2
glsl: make max array trackers ints and use -1 as base. (v2)
This fixes a bug that breaks cull distances. The problem is the max array accessors can't tell the difference between an never accessed unsized array and an accessed at location 0 unsized array. This leads to converting an undeclared unused gl_ClipDistance inside or outside gl_PerVertex to a size 1 array. However we need to the number of active clip distances to work out the starting point for the cull distances, and this offset by one when it's not being used isn't possible to distinguish from the case were only the first element is accessed. I tried to use ->used for this, but that doesn't work when gl_ClipDistance is part of an interface block. So this changes things so that max_array_access is an int and initialised to -1. This also allows unsized arrays to proceed further than that could before, but we really shouldn't mind as they will get eliminated if nothing uses them later. For initialised uniforms we no longer change their array size at runtime, if these are unused they will get eliminated eventually. v2: use ralloc_array (Ilia) Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu> Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'src/compiler/glsl/linker.cpp')
-rw-r--r--src/compiler/glsl/linker.cpp14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/compiler/glsl/linker.cpp b/src/compiler/glsl/linker.cpp
index 5e59ae3..f4d443b 100644
--- a/src/compiler/glsl/linker.cpp
+++ b/src/compiler/glsl/linker.cpp
@@ -216,7 +216,7 @@ public:
* array using an index too large for its actual size assigned at link
* time.
*/
- if (var->data.max_array_access >= this->num_vertices) {
+ if (var->data.max_array_access >= (int)this->num_vertices) {
linker_error(this->prog, "geometry shader accesses element %i of "
"%s, but only %i input vertices\n",
var->data.max_array_access, var->name, this->num_vertices);
@@ -924,7 +924,7 @@ validate_intrastage_arrays(struct gl_shader_program *prog,
if ((var->type->fields.array == existing->type->fields.array) &&
((var->type->length == 0)|| (existing->type->length == 0))) {
if (var->type->length != 0) {
- if (var->type->length <= existing->data.max_array_access) {
+ if ((int)var->type->length <= existing->data.max_array_access) {
linker_error(prog, "%s `%s' declared as type "
"`%s' but outermost dimension has an index"
" of `%i'\n",
@@ -935,7 +935,7 @@ validate_intrastage_arrays(struct gl_shader_program *prog,
existing->type = var->type;
return true;
} else if (existing->type->length != 0) {
- if(existing->type->length <= var->data.max_array_access &&
+ if((int)existing->type->length <= var->data.max_array_access &&
!existing->data.from_ssbo_unsized_array) {
linker_error(prog, "%s `%s' declared as type "
"`%s' but outermost dimension has an index"
@@ -1593,7 +1593,7 @@ private:
*/
static const glsl_type *
resize_interface_members(const glsl_type *type,
- const unsigned *max_ifc_array_access,
+ const int *max_ifc_array_access,
bool is_ssbo)
{
unsigned num_fields = type->length;
@@ -2399,10 +2399,10 @@ update_array_sizes(struct gl_shader_program *prog)
* Subroutine uniforms are not removed.
*/
if (var->is_in_buffer_block() || var->type->contains_atomic() ||
- var->type->contains_subroutine())
+ var->type->contains_subroutine() || var->constant_initializer)
continue;
- unsigned int size = var->data.max_array_access;
+ int size = var->data.max_array_access;
for (unsigned j = 0; j < MESA_SHADER_STAGES; j++) {
if (prog->_LinkedShaders[j] == NULL)
continue;
@@ -2419,7 +2419,7 @@ update_array_sizes(struct gl_shader_program *prog)
}
}
- if (size + 1 != var->type->length) {
+ if (size + 1 != (int)var->type->length) {
/* If this is a built-in uniform (i.e., it's backed by some
* fixed-function state), adjust the number of state slots to
* match the new array size. The number of slots per array entry