mesa/glsl: new compiler option EmitNoIndirectSampler
authorTapani Pälli <tapani.palli@intel.com>
Tue, 9 Jun 2015 10:33:39 +0000 (13:33 +0300)
committerTapani Pälli <tapani.palli@intel.com>
Tue, 30 Jun 2015 08:12:43 +0000 (11:12 +0300)
Patch provides new compiler option for backend to force unroll loops
that have non-constant expression indexing on sampler arrays.

This makes sure that we can never end up with a shader that uses loop
induction variable as sampler array index but does not unroll because
of having too much instructions. This would not work without dynamic
indexing support.

v2: change option name as EmitNoIndirectSampler

Signed-off-by: Tapani Pälli <tapani.palli@intel.com>
Reviewed-by: Francisco Jerez <currojerez@riseup.net>
Cc: "10.5" and "10.6" <mesa-stable@lists.freedesktop.org>
src/glsl/loop_unroll.cpp
src/mesa/main/mtypes.h

index 635e1dd99cd5058be97d1023047b5e009611da7d..7a00fb8fea87400e1bd3d73fa83081031565fc3c 100644 (file)
@@ -100,6 +100,18 @@ public:
 
    virtual ir_visitor_status visit_enter(ir_dereference_array *ir)
    {
+      /* Force unroll in case of dynamic indexing with sampler arrays
+       * when EmitNoIndirectSampler is set.
+       */
+      if (options->EmitNoIndirectSampler) {
+         if ((ir->array->type->is_array() &&
+              ir->array->type->contains_sampler()) &&
+             !ir->array_index->constant_expression_value()) {
+            unsupported_variable_indexing = true;
+            return visit_continue;
+         }
+      }
+
       /* Check for arrays variably-indexed by a loop induction variable.
        * Unrolling the loop may convert that access into constant-indexing.
        *
index 983b9dc307b87c075a0679fe10b7545764b5f1d6..7b55677de309ce37df6ac3746fc2e450952ee834 100644 (file)
@@ -2881,6 +2881,7 @@ struct gl_shader_compiler_options
    GLboolean EmitNoIndirectOutput;  /**< No indirect addressing of outputs */
    GLboolean EmitNoIndirectTemp;    /**< No indirect addressing of temps */
    GLboolean EmitNoIndirectUniform; /**< No indirect addressing of constants */
+   GLboolean EmitNoIndirectSampler; /**< No indirect addressing of samplers */
    /*@}*/
 
    GLuint MaxIfDepth;               /**< Maximum nested IF blocks */