summaryrefslogtreecommitdiffstats
path: root/src/mesa/main/ff_fragment_shader.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/mesa/main/ff_fragment_shader.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/mesa/main/ff_fragment_shader.cpp')
-rw-r--r--src/mesa/main/ff_fragment_shader.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/mesa/main/ff_fragment_shader.cpp b/src/mesa/main/ff_fragment_shader.cpp
index b0ce8c4..26bf162 100644
--- a/src/mesa/main/ff_fragment_shader.cpp
+++ b/src/mesa/main/ff_fragment_shader.cpp
@@ -517,7 +517,7 @@ get_current_attrib(texenv_fragment_program *p, GLuint attrib)
current = p->shader->symbols->get_variable("gl_CurrentAttribFragMESA");
assert(current);
- current->data.max_array_access = MAX2(current->data.max_array_access, attrib);
+ current->data.max_array_access = MAX2(current->data.max_array_access, (int)attrib);
val = new(p->mem_ctx) ir_dereference_variable(current);
ir_rvalue *index = new(p->mem_ctx) ir_constant(attrib);
return new(p->mem_ctx) ir_dereference_array(val, index);
@@ -561,7 +561,7 @@ get_source(texenv_fragment_program *p,
var = p->shader->symbols->get_variable("gl_TextureEnvColor");
assert(var);
deref = new(p->mem_ctx) ir_dereference_variable(var);
- var->data.max_array_access = MAX2(var->data.max_array_access, unit);
+ var->data.max_array_access = MAX2(var->data.max_array_access, (int)unit);
return new(p->mem_ctx) ir_dereference_array(deref,
new(p->mem_ctx) ir_constant(unit));
@@ -893,7 +893,7 @@ static void load_texture( texenv_fragment_program *p, GLuint unit )
texcoord = new(p->mem_ctx) ir_dereference_variable(tc_array);
ir_rvalue *index = new(p->mem_ctx) ir_constant(unit);
texcoord = new(p->mem_ctx) ir_dereference_array(texcoord, index);
- tc_array->data.max_array_access = MAX2(tc_array->data.max_array_access, unit);
+ tc_array->data.max_array_access = MAX2(tc_array->data.max_array_access, (int)unit);
}
if (!p->state->unit[unit].enabled) {