summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwolfbeast <mcwerewolf@wolfbeast.com>2020-01-16 01:40:30 +0100
committerwolfbeast <mcwerewolf@wolfbeast.com>2020-01-16 01:40:30 +0100
commit7007ec9e42bf443566846296aa70aba47ee9feb3 (patch)
treead5cae07003480fdf2de3ffbd80af5f8644ab39d
parent058105eec0564943dd872a7ae43cd8a5b94f0abf (diff)
downloaduxp-7007ec9e42bf443566846296aa70aba47ee9feb3.tar.gz
Issue #1354 - Don't allow glsl[130,400] unless we have gpu_shader5
- Teach GLContext about gpu_shader5 - Downgrade shader language version if gpu_shader5 support isn't found.
-rw-r--r--dom/canvas/WebGLShaderValidator.cpp11
-rw-r--r--gfx/gl/GLContext.cpp3
-rw-r--r--gfx/gl/GLContext.h4
-rw-r--r--gfx/gl/GLContextFeatures.cpp12
4 files changed, 30 insertions, 0 deletions
diff --git a/dom/canvas/WebGLShaderValidator.cpp b/dom/canvas/WebGLShaderValidator.cpp
index fda31e2129..d574d9a659 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"
@@ -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/gl/GLContext.cpp b/gfx/gl/GLContext.cpp
index 33315413f2..1515b8627e 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 c82efcedaf..6e3e22207f 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 0714d96415..d4f37803f2 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,