summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--dom/canvas/WebGLShaderValidator.cpp47
-rwxr-xr-xgfx/angle/src/compiler/translator/TranslatorGLSL.cpp20
-rwxr-xr-xgfx/angle/src/libANGLE/renderer/gl/renderergl_utils.cpp15
-rw-r--r--gfx/gl/GLContext.cpp3
-rw-r--r--gfx/gl/GLContext.h4
-rw-r--r--gfx/gl/GLContextFeatures.cpp12
6 files changed, 60 insertions, 41 deletions
diff --git a/dom/canvas/WebGLShaderValidator.cpp b/dom/canvas/WebGLShaderValidator.cpp
index fda31e212..bf2df82f7 100644
--- a/dom/canvas/WebGLShaderValidator.cpp
+++ b/dom/canvas/WebGLShaderValidator.cpp
@@ -5,6 +5,7 @@
#include "WebGLShaderValidator.h"
+#include <algorithm>
#include "angle/ShaderLang.h"
#include "gfxPrefs.h"
#include "GLContext.h"
@@ -32,14 +33,14 @@ static int
ChooseValidatorCompileOptions(const ShBuiltInResources& resources,
const mozilla::gl::GLContext* gl)
{
- int options = SH_VARIABLES |
- SH_ENFORCE_PACKING_RESTRICTIONS |
+ int options = SH_VARIABLES |
+ SH_ENFORCE_PACKING_RESTRICTIONS |
SH_INIT_VARYINGS_WITHOUT_STATIC_USE |
- SH_OBJECT_CODE |
- SH_INIT_GL_POSITION;
-
- if (resources.MaxExpressionComplexity > 0) {
- options |= SH_LIMIT_EXPRESSION_COMPLEXITY;
+ SH_OBJECT_CODE |
+ 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.
@@ -50,17 +51,17 @@ ChooseValidatorCompileOptions(const ShBuiltInResources& resources,
// Needed for driver bug detection
options |= SH_EMULATE_BUILT_IN_FUNCTIONS;
- 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_CLAMP_INDIRECT_ARRAY_BOUNDS |
- SH_UNFOLD_SHORT_CIRCUIT |
- SH_SCALARIZE_VEC_AND_MAT_CONSTRUCTOR_ARGS |
- SH_INIT_OUTPUT_VARIABLES |
- SH_REGENERATE_STRUCT_NAMES;
- }
+ 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_CLAMP_INDIRECT_ARRAY_BOUNDS |
+ SH_UNFOLD_SHORT_CIRCUIT |
+ SH_SCALARIZE_VEC_AND_MAT_CONSTRUCTOR_ARGS |
+ SH_INIT_OUTPUT_VARIABLES |
+ SH_REGENERATE_STRUCT_NAMES;
+ }
#ifndef XP_MACOSX
// We want to do this everywhere, but to do this on Mac, we need
@@ -112,6 +113,16 @@ ShaderOutput(gl::GLContext* gl)
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;
diff --git a/gfx/angle/src/compiler/translator/TranslatorGLSL.cpp b/gfx/angle/src/compiler/translator/TranslatorGLSL.cpp
index 0ee96f590..0d72e2bbb 100755
--- a/gfx/angle/src/compiler/translator/TranslatorGLSL.cpp
+++ b/gfx/angle/src/compiler/translator/TranslatorGLSL.cpp
@@ -240,20 +240,14 @@ void TranslatorGLSL::writeExtensionBehavior(TIntermNode *root)
}
// Need to enable gpu_shader5 to have index constant sampler array indexing
- if (getOutputType() != SH_ESSL_OUTPUT && getOutputType() < SH_GLSL_400_CORE_OUTPUT)
+ if (getOutputType() != SH_ESSL_OUTPUT && getOutputType() < SH_GLSL_400_CORE_OUTPUT &&
+ getShaderVersion() == 100)
{
- sink << "#extension GL_ARB_gpu_shader5 : ";
-
- // Don't use "require" on WebGL 1 to avoid breaking WebGL on drivers that silently
- // support index constant sampler array indexing, but don't have the extension.
- if (getShaderVersion() >= 300)
- {
- sink << "require\n";
- }
- else
- {
- sink << "enable\n";
- }
+ // Don't use "require" to avoid breaking WebGL 1 on drivers that silently
+ // support index constant sampler array indexing, but don't have the extension or
+ // on drivers that don't have the extension at all as it would break WebGL 1 for
+ // some users.
+ sink << "#extension GL_ARB_gpu_shader5 : enable\n";
}
TExtensionGLSL extensionGLSL(getOutputType());
diff --git a/gfx/angle/src/libANGLE/renderer/gl/renderergl_utils.cpp b/gfx/angle/src/libANGLE/renderer/gl/renderergl_utils.cpp
index 87fd24a61..d65e00454 100755
--- a/gfx/angle/src/libANGLE/renderer/gl/renderergl_utils.cpp
+++ b/gfx/angle/src/libANGLE/renderer/gl/renderergl_utils.cpp
@@ -543,16 +543,11 @@ void GenerateCaps(const FunctionsGL *functions, gl::Caps *caps, gl::TextureCapsM
LimitVersion(maxSupportedESVersion, gl::Version(2, 0));
}
- // Check if index constant sampler array indexing is supported
- if (!functions->isAtLeastGL(gl::Version(4, 0)) &&
- !functions->isAtLeastGLES(gl::Version(2, 0)) &&
- !functions->hasExtension("GL_ARB_gpu_shader5"))
- {
- // This should also be required for ES2 but there are some driver support index constant
- // sampler array indexing without meeting the requirements above. Don't limit their ES
- // version as it would break WebGL for some users.
- LimitVersion(maxSupportedESVersion, gl::Version(2, 0));
- }
+ // Non-constant sampler array indexing is required for OpenGL ES 2 and OpenGL ES after 3.2.
+ // However having it available on OpenGL ES 2 is a specification bug, and using this
+ // indexing in WebGL is undefined. Requiring this feature would break WebGL 1 for some users
+ // so we don't check for it. (it is present with ESSL 100, ESSL >= 320, GLSL >= 400 and
+ // GL_ARB_gpu_shader5)
// Check if sampler objects are supported
if (!functions->isAtLeastGL(gl::Version(3, 3)) &&
diff --git a/gfx/gl/GLContext.cpp b/gfx/gl/GLContext.cpp
index 33315413f..1515b8627 100644
--- a/gfx/gl/GLContext.cpp
+++ b/gfx/gl/GLContext.cpp
@@ -95,6 +95,7 @@ static const char* const sExtensionNames[] = {
"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",
@@ -134,6 +135,7 @@ static const char* const sExtensionNames[] = {
"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",
@@ -160,6 +162,7 @@ static const char* const sExtensionNames[] = {
"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",
diff --git a/gfx/gl/GLContext.h b/gfx/gl/GLContext.h
index c82efceda..6e3e22207 100644
--- a/gfx/gl/GLContext.h
+++ b/gfx/gl/GLContext.h
@@ -102,6 +102,7 @@ enum class GLFeature {
get_query_object_iv,
get_string_indexed,
gpu_shader4,
+ gpu_shader5,
instanced_arrays,
instanced_non_arrays,
internalformat_query,
@@ -421,6 +422,7 @@ public:
ARB_framebuffer_object,
ARB_framebuffer_sRGB,
ARB_geometry_shader4,
+ ARB_gpu_shader5,
ARB_half_float_pixel,
ARB_instanced_arrays,
ARB_internalformat_query,
@@ -460,6 +462,7 @@ public:
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,
@@ -486,6 +489,7 @@ public:
NV_fence,
NV_framebuffer_blit,
NV_geometry_program4,
+ NV_gpu_shader5,
NV_half_float,
NV_instanced_arrays,
NV_primitive_restart,
diff --git a/gfx/gl/GLContextFeatures.cpp b/gfx/gl/GLContextFeatures.cpp
index 0714d9641..d4f37803f 100644
--- a/gfx/gl/GLContextFeatures.cpp
+++ b/gfx/gl/GLContextFeatures.cpp
@@ -332,6 +332,18 @@ static const FeatureInfo sFeatureInfoArr[] = {
}
},
{
+ "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,