Bug 1399501 - Don't allow glsl[130,400) unless we have gpu_shader5. - r=kvark
☠☠ backed out by 12e986367fe9 ☠ ☠
authorJeff Gilbert <jgilbert@mozilla.com>
Wed, 04 Apr 2018 17:11:42 -0700
changeset 442673 b4c2cdd8d03bafba7ad2854968ba07df070dc440
parent 442672 ef78b85760ee45897b6add17b0860cd096168d3b
child 442674 b7e7638dbfd10f04f0eea8f9d886266abe791378
push id34917
push useraiakab@mozilla.com
push dateWed, 24 Oct 2018 04:16:01 +0000
treeherdermozilla-central@079c7a062b23 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskvark
bugs1399501
milestone65.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1399501 - Don't allow glsl[130,400) unless we have gpu_shader5. - r=kvark MozReview-Commit-ID: EUk2uc64Tok Differential Revision: https://phabricator.services.mozilla.com/D9288
dom/canvas/WebGLContext.cpp
dom/canvas/WebGLShaderValidator.cpp
dom/canvas/test/webgl-conf/generated-mochitest.ini
dom/canvas/test/webgl-conf/mochitest-errata.ini
gfx/gl/GLContext.cpp
gfx/gl/GLContext.h
gfx/gl/GLContextFeatures.cpp
--- a/dom/canvas/WebGLContext.cpp
+++ b/dom/canvas/WebGLContext.cpp
@@ -596,18 +596,26 @@ WebGLContext::CreateAndInitGL(bool force
     // --
 
     typedef decltype(gl::GLContextProviderEGL::CreateOffscreen) fnCreateOffscreenT;
     const auto fnCreate = [&](fnCreateOffscreenT* const pfnCreateOffscreen,
                               const char* const info)
     {
         const gfx::IntSize dummySize(1, 1);
         nsCString failureId;
-        const RefPtr<GLContext> gl = pfnCreateOffscreen(dummySize, surfaceCaps, flags,
-                                                        &failureId);
+        RefPtr<GLContext> gl = pfnCreateOffscreen(dummySize, surfaceCaps, flags,
+                                                  &failureId);
+        if (gl && gl->IsCoreProfile() &&
+            !(flags & gl::CreateContextFlags::REQUIRE_COMPAT_PROFILE) &&
+            !gl->IsSupported(gl::GLFeature::gpu_shader5))
+        {
+            // See comment on "constant-index-expression" in WebGLShaderValidator.cpp.
+            const auto compatFlags = flags | gl::CreateContextFlags::REQUIRE_COMPAT_PROFILE;
+            gl = pfnCreateOffscreen(dummySize, surfaceCaps, compatFlags, &failureId);
+        }
         if (!gl) {
             out_failReasons->push_back(WebGLContext::FailureReason(failureId, info));
         }
         return gl;
     };
 
     const auto newGL = [&]() -> RefPtr<gl::GLContext> {
         if (tryNativeGL) {
--- a/dom/canvas/WebGLShaderValidator.cpp
+++ b/dom/canvas/WebGLShaderValidator.cpp
@@ -1,15 +1,16 @@
 /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "WebGLShaderValidator.h"
 
+#include <algorithm>
 #include "gfxPrefs.h"
 #include "GLContext.h"
 #include "mozilla/gfx/Logging.h"
 #include "mozilla/Preferences.h"
 #include "MurmurHash3.h"
 #include "nsPrintfCString.h"
 #include <string>
 #include <vector>
@@ -96,22 +97,32 @@ ChooseValidatorCompileOptions(const ShBu
     return options;
 }
 
 } // namespace webgl
 
 ////////////////////////////////////////
 
 static ShShaderOutput
-ShaderOutput(gl::GLContext* gl)
+ShaderOutput(gl::GLContext* const gl)
 {
     if (gl->IsGLES()) {
         return SH_ESSL_OUTPUT;
     } else {
         uint32_t version = gl->ShadingLanguageVersion();
+
+        // Version 130 starts to require integral constant expressions for loop indices,
+        // instead of "constant-index-expression".
+        // Both version 400 and gpu_shader5 remove this restrictions.
+        // gpu_shader5 went core in 400, so we can just check for the GLFeature.
+        // If we're compiling for webglsl1, even for webgl2, we need gpu_shader5, or GLSL_COMPAT.
+        if (!gl->IsSupported(gl::GLFeature::gpu_shader5)) {
+            version = std::min<uint32_t>(version, 120);
+        }
+
         switch (version) {
         case 100: return SH_GLSL_COMPATIBILITY_OUTPUT;
         case 120: return SH_GLSL_COMPATIBILITY_OUTPUT;
         case 130: return SH_GLSL_130_OUTPUT;
         case 140: return SH_GLSL_140_OUTPUT;
         case 150: return SH_GLSL_150_CORE_OUTPUT;
         case 330: return SH_GLSL_330_CORE_OUTPUT;
         case 400: return SH_GLSL_400_CORE_OUTPUT;
--- a/dom/canvas/test/webgl-conf/generated-mochitest.ini
+++ b/dom/canvas/test/webgl-conf/generated-mochitest.ini
@@ -11111,17 +11111,16 @@ subsuite = webgl1-ext
 subsuite = webgl1-ext
 skip-if = (os == 'android')
 [generated/test_conformance__glsl__bugs__qualcomm-loop-with-continue-crash.html]
 subsuite = webgl1-ext
 [generated/test_conformance__glsl__bugs__sampler-array-struct-function-arg.html]
 subsuite = webgl1-ext
 [generated/test_conformance__glsl__bugs__sampler-array-using-loop-index.html]
 subsuite = webgl1-ext
-fail-if = (os == 'linux')
 [generated/test_conformance__glsl__bugs__sampler-struct-function-arg.html]
 subsuite = webgl1-ext
 skip-if = (os == 'linux') || (os == 'android')
 [generated/test_conformance__glsl__bugs__sequence-operator-evaluation-order.html]
 subsuite = webgl1-ext
 skip-if = (os == 'android')
 [generated/test_conformance__glsl__bugs__sketchfab-lighting-shader-crash.html]
 subsuite = webgl1-ext
@@ -11587,16 +11586,17 @@ subsuite = webgl1-ext
 [generated/test_conformance__glsl__misc__shader-with-while-loop.html]
 subsuite = webgl1-ext
 [generated/test_conformance__glsl__misc__shader-without-precision.frag.html]
 subsuite = webgl1-ext
 [generated/test_conformance__glsl__misc__shaders-with-constant-expression-loop-conditions.html]
 subsuite = webgl1-ext
 [generated/test_conformance__glsl__misc__shaders-with-invariance.html]
 subsuite = webgl1-ext
+fail-if = (os == 'linux')
 [generated/test_conformance__glsl__misc__shaders-with-mis-matching-uniforms.html]
 subsuite = webgl1-ext
 [generated/test_conformance__glsl__misc__shaders-with-mis-matching-varyings.html]
 subsuite = webgl1-ext
 [generated/test_conformance__glsl__misc__shaders-with-missing-varyings.html]
 subsuite = webgl1-ext
 [generated/test_conformance__glsl__misc__shaders-with-name-conflicts.html]
 subsuite = webgl1-ext
--- a/dom/canvas/test/webgl-conf/mochitest-errata.ini
+++ b/dom/canvas/test/webgl-conf/mochitest-errata.ini
@@ -188,19 +188,17 @@ skip-if = (os == 'linux') || (os == 'mac
 [generated/test_conformance__glsl__constructors__glsl-construct-ivec4.html]
 # Assume crashes like ivec3
 skip-if = (os == 'linux') || (os == 'mac')
 
 [generated/test_conformance__glsl__constructors__glsl-construct-mat2.html]
 # Crashes on Linux ASAN
 skip-if = ((os == 'linux') && asan)
 
-[generated/test_conformance__glsl__bugs__sampler-array-using-loop-index.html]
-# Testfail on Linux after removing SH_UNROLL_FOR_LOOP_WITH_SAMPLER_ARRAY_INDEX.
-# Only happen on tryserver
+[generated/test_conformance__glsl__misc__shaders-with-invariance.html]
 fail-if = (os == 'linux')
 
 [generated/test_conformance__misc__type-conversion-test.html]
 fail-if = (os == 'linux')
 # Resets device on Android 2.3.
 # Crashes on desktop Linux.
 skip-if = (os == 'android') || (os == 'linux')
 
--- a/gfx/gl/GLContext.cpp
+++ b/gfx/gl/GLContext.cpp
@@ -92,16 +92,17 @@ static const char* const sExtensionNames
     "GL_ARB_compatibility",
     "GL_ARB_copy_buffer",
     "GL_ARB_depth_texture",
     "GL_ARB_draw_buffers",
     "GL_ARB_draw_instanced",
     "GL_ARB_framebuffer_object",
     "GL_ARB_framebuffer_sRGB",
     "GL_ARB_geometry_shader4",
+    "GL_ARB_gpu_shader5",
     "GL_ARB_half_float_pixel",
     "GL_ARB_instanced_arrays",
     "GL_ARB_internalformat_query",
     "GL_ARB_invalidate_subdata",
     "GL_ARB_map_buffer_range",
     "GL_ARB_occlusion_query2",
     "GL_ARB_pixel_buffer_object",
     "GL_ARB_robust_buffer_access_behavior",
@@ -134,16 +135,17 @@ static const char* const sExtensionNames
     "GL_EXT_draw_instanced",
     "GL_EXT_draw_range_elements",
     "GL_EXT_frag_depth",
     "GL_EXT_framebuffer_blit",
     "GL_EXT_framebuffer_multisample",
     "GL_EXT_framebuffer_object",
     "GL_EXT_framebuffer_sRGB",
     "GL_EXT_gpu_shader4",
+    "GL_EXT_gpu_shader5",
     "GL_EXT_multisampled_render_to_texture",
     "GL_EXT_occlusion_query_boolean",
     "GL_EXT_packed_depth_stencil",
     "GL_EXT_read_format_bgra",
     "GL_EXT_robustness",
     "GL_EXT_sRGB",
     "GL_EXT_sRGB_write_control",
     "GL_EXT_shader_texture_lod",
@@ -167,16 +169,17 @@ static const char* const sExtensionNames
     "GL_KHR_robust_buffer_access_behavior",
     "GL_KHR_robustness",
     "GL_KHR_texture_compression_astc_hdr",
     "GL_KHR_texture_compression_astc_ldr",
     "GL_NV_draw_instanced",
     "GL_NV_fence",
     "GL_NV_framebuffer_blit",
     "GL_NV_geometry_program4",
+    "GL_NV_gpu_shader5",
     "GL_NV_half_float",
     "GL_NV_instanced_arrays",
     "GL_NV_primitive_restart",
     "GL_NV_texture_barrier",
     "GL_NV_transform_feedback",
     "GL_NV_transform_feedback2",
     "GL_OES_EGL_image",
     "GL_OES_EGL_image_external",
--- a/gfx/gl/GLContext.h
+++ b/gfx/gl/GLContext.h
@@ -98,16 +98,17 @@ enum class GLFeature {
     framebuffer_multisample,
     framebuffer_object,
     framebuffer_object_EXT_OES,
     get_integer_indexed,
     get_integer64_indexed,
     get_query_object_i64v,
     get_query_object_iv,
     gpu_shader4,
+    gpu_shader5,
     instanced_arrays,
     instanced_non_arrays,
     internalformat_query,
     invalidate_framebuffer,
     map_buffer_range,
     occlusion_query,
     occlusion_query_boolean,
     occlusion_query2,
@@ -393,16 +394,17 @@ public:
         ARB_compatibility,
         ARB_copy_buffer,
         ARB_depth_texture,
         ARB_draw_buffers,
         ARB_draw_instanced,
         ARB_framebuffer_object,
         ARB_framebuffer_sRGB,
         ARB_geometry_shader4,
+        ARB_gpu_shader5,
         ARB_half_float_pixel,
         ARB_instanced_arrays,
         ARB_internalformat_query,
         ARB_invalidate_subdata,
         ARB_map_buffer_range,
         ARB_occlusion_query2,
         ARB_pixel_buffer_object,
         ARB_robust_buffer_access_behavior,
@@ -435,16 +437,17 @@ public:
         EXT_draw_instanced,
         EXT_draw_range_elements,
         EXT_frag_depth,
         EXT_framebuffer_blit,
         EXT_framebuffer_multisample,
         EXT_framebuffer_object,
         EXT_framebuffer_sRGB,
         EXT_gpu_shader4,
+        EXT_gpu_shader5,
         EXT_multisampled_render_to_texture,
         EXT_occlusion_query_boolean,
         EXT_packed_depth_stencil,
         EXT_read_format_bgra,
         EXT_robustness,
         EXT_sRGB,
         EXT_sRGB_write_control,
         EXT_shader_texture_lod,
@@ -468,16 +471,17 @@ public:
         KHR_robust_buffer_access_behavior,
         KHR_robustness,
         KHR_texture_compression_astc_hdr,
         KHR_texture_compression_astc_ldr,
         NV_draw_instanced,
         NV_fence,
         NV_framebuffer_blit,
         NV_geometry_program4,
+        NV_gpu_shader5,
         NV_half_float,
         NV_instanced_arrays,
         NV_primitive_restart,
         NV_texture_barrier,
         NV_transform_feedback,
         NV_transform_feedback2,
         OES_EGL_image,
         OES_EGL_image_external,
--- a/gfx/gl/GLContextFeatures.cpp
+++ b/gfx/gl/GLContextFeatures.cpp
@@ -317,16 +317,28 @@ static const FeatureInfo sFeatureInfoArr
         GLESVersion::ES3,
         GLContext::Extension_None,
         {
             GLContext::EXT_gpu_shader4,
             GLContext::Extensions_End
         }
     },
     {
+        "gpu_shader5",
+        GLVersion::GL4,
+        GLESVersion::NONE,
+        GLContext::Extension_None,
+        {
+            GLContext::ARB_gpu_shader5,
+            GLContext::EXT_gpu_shader5,
+            GLContext::NV_gpu_shader5,
+            GLContext::Extensions_End
+        }
+    },
+    {
         "instanced_arrays",
         GLVersion::GL3_3,
         GLESVersion::ES3,
         GLContext::Extension_None,
         {
             GLContext::ARB_instanced_arrays,
             GLContext::NV_instanced_arrays,
             GLContext::ANGLE_instanced_arrays,