Bug 1288638 - Unconditionally SH_UNROLL_FOR_LOOP_WITH_SAMPLER_ARRAY_INDEX. - r=mtseng draft
authorJeff Gilbert <jgilbert@mozilla.com>
Mon, 25 Jul 2016 17:28:06 -0700
changeset 392682 c2516f2847e7d9e2d5f03a00ec8ca10648373049
parent 391182 93ed13dc40a67ff4f7d901287d854d55ebd46eb0
child 526384 9bf1cf4f4f926010b6769b4d79c79383b7ad2ea4
push id24087
push userbmo:jgilbert@mozilla.com
push dateTue, 26 Jul 2016 02:06:36 +0000
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;
 }