Bug 1288638 - Unconditionally SH_UNROLL_FOR_LOOP_WITH_SAMPLER_ARRAY_INDEX. - r=mtseng
authorJeff Gilbert <jgilbert@mozilla.com>
Mon, 25 Jul 2016 17:28:06 -0700
changeset 331702 f8ada839cad0cad17040174331ff92afd96ec0e1
parent 331701 2f9e3bde4fd004e32126c7c3c0e68f77589f6b88
child 331703 6a5a741a239198467672ca13b77a7a3f674f5cad
push id9858
push userjlund@mozilla.com
push dateMon, 01 Aug 2016 14:37:10 +0000
treeherdermozilla-aurora@203106ef6cb6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmtseng
bugs1288638
milestone50.0a1
Bug 1288638 - Unconditionally SH_UNROLL_FOR_LOOP_WITH_SAMPLER_ARRAY_INDEX. - r=mtseng MozReview-Commit-ID: CPgJTTV8vAA
dom/canvas/WebGLShaderValidator.cpp
--- a/dom/canvas/WebGLShaderValidator.cpp
+++ b/dom/canvas/WebGLShaderValidator.cpp
@@ -38,16 +38,22 @@ ChooseValidatorCompileOptions(const ShBu
                   SH_OBJECT_CODE |
                   SH_LIMIT_CALL_STACK_DEPTH |
                   SH_INIT_GL_POSITION;
 
     if (resources.MaxExpressionComplexity > 0) {
         options |= SH_LIMIT_EXPRESSION_COMPLEXITY;
     }
 
+    // Sampler arrays indexed with non-constant expressions are forbidden in
+    // GLSL 1.30 and later.
+    // ESSL 3 requires constant-integral-expressions for this as well.
+    // Just do it universally.
+    options |= SH_UNROLL_FOR_LOOP_WITH_SAMPLER_ARRAY_INDEX;
+
     if (gfxPrefs::WebGLAllANGLEOptions()) {
         return options |
                SH_VALIDATE_LOOP_INDEXING |
                SH_UNROLL_FOR_LOOP_WITH_INTEGER_INDEX |
                SH_UNROLL_FOR_LOOP_WITH_SAMPLER_ARRAY_INDEX |
                SH_EMULATE_BUILT_IN_FUNCTIONS |
                SH_CLAMP_INDIRECT_ARRAY_BOUNDS |
                SH_UNFOLD_SHORT_CIRCUIT |
@@ -73,21 +79,16 @@ ChooseValidatorCompileOptions(const ShBu
             options |= SH_EMULATE_BUILT_IN_FUNCTIONS;
         }
 
         // Work around bug 735560
         if (gl->Vendor() == gl::GLVendor::Intel) {
             options |= SH_EMULATE_BUILT_IN_FUNCTIONS;
         }
 
-        // Work around bug 636926
-        if (gl->Vendor() == gl::GLVendor::NVIDIA) {
-            options |= SH_UNROLL_FOR_LOOP_WITH_SAMPLER_ARRAY_INDEX;
-        }
-
         // Work around that Mac drivers handle struct scopes incorrectly.
         options |= SH_REGENERATE_STRUCT_NAMES;
     }
 #endif
 
     return options;
 }