From 8e79cf6ba05539b990a40861ca3a2c1e32fef369 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tapani=20P=C3=A4lli?= Date: Tue, 9 Jun 2015 13:33:39 +0300 Subject: [PATCH] mesa/glsl: new compiler option EmitNoIndirectSampler MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Francisco Jerez Cc: "10.5" and "10.6" (cherry picked from commit e4512e1581cf90f56d13cfa6a809832ef3517283) --- src/glsl/loop_unroll.cpp | 12 ++++++++++++ src/mesa/main/mtypes.h | 1 + 2 files changed, 13 insertions(+) diff --git a/src/glsl/loop_unroll.cpp b/src/glsl/loop_unroll.cpp index 635e1dd99cd..7a00fb8fea8 100644 --- a/src/glsl/loop_unroll.cpp +++ b/src/glsl/loop_unroll.cpp @@ -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. * diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 9918541472a..4f1701ce81c 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -3021,6 +3021,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 */ -- 2.11.0