OSDN Git Service

mesa: Add a new function for getting the nonconst sampler array index
authorChris Forbes <chrisf@ijw.co.nz>
Sun, 3 Aug 2014 07:55:55 +0000 (19:55 +1200)
committerChris Forbes <chrisf@ijw.co.nz>
Tue, 12 Aug 2014 07:18:55 +0000 (19:18 +1200)
If the array index is not a constant expression, the existing support
will assume a zero offset (giving us the sampler index of the base of
the array).

For dynamically uniform indexing of sampler arrays, we need both that
and the indexing expression.

Signed-off-by: Chris Forbes <chrisf@ijw.co.nz>
Reviewed-by: Matt Turner <mattst88@gmail.com>
Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
src/mesa/program/sampler.cpp
src/mesa/program/sampler.h

index e6532be..29a5408 100644 (file)
@@ -134,3 +134,14 @@ _mesa_get_sampler_uniform_value(class ir_dereference *sampler,
    return shader_program->UniformStorage[location].sampler[shader].index +
           getname.offset;
 }
+
+
+extern "C" class ir_rvalue *
+_mesa_get_sampler_array_nonconst_index(class ir_dereference *sampler)
+{
+   ir_dereference_array *deref_arr = sampler->as_dereference_array();
+   if (!deref_arr || deref_arr->array_index->as_constant())
+      return NULL;
+
+   return deref_arr->array_index;
+}
index 22467e9..8b7c3b6 100644 (file)
@@ -27,3 +27,6 @@ int
 _mesa_get_sampler_uniform_value(class ir_dereference *sampler,
                                struct gl_shader_program *shader_program,
                                const struct gl_program *prog);
+
+class ir_rvalue *
+_mesa_get_sampler_array_nonconst_index(class ir_dereference *sampler);