From 40313e5a6d44480936b3199e6695bf303eb4f4a9 Mon Sep 17 00:00:00 2001 From: Vladimir Vukicevic Date: Thu, 24 Jul 2014 11:58:43 -0400 Subject: [PATCH] b=965848; implement EXT_shader_texture_lod for WebGL; r=jgilbert, r=bz --- dom/bindings/Bindings.conf | 5 + dom/canvas/WebGLContextExtensions.cpp | 6 + dom/canvas/WebGLContextGL.cpp | 3 + dom/canvas/WebGLExtensionShaderTextureLod.cpp | 21 ++ dom/canvas/WebGLExtensions.h | 10 + dom/canvas/WebGLTypes.h | 1 + dom/canvas/moz.build | 1 + .../conformance/extensions/00_test_list.txt | 1 + .../extensions/ext-shader-texture-lod.html | 280 ++++++++++++++++++ .../mochitest-conformance-files.ini | 1 + dom/webidl/WebGLRenderingContext.webidl | 5 + gfx/gl/GLContext.cpp | 1 + gfx/gl/GLContext.h | 1 + 13 files changed, 336 insertions(+) create mode 100644 dom/canvas/WebGLExtensionShaderTextureLod.cpp create mode 100644 dom/canvas/test/webgl-conformance/conformance/extensions/ext-shader-texture-lod.html diff --git a/dom/bindings/Bindings.conf b/dom/bindings/Bindings.conf index 7f88cabb3e56..4946696fbfca 100644 --- a/dom/bindings/Bindings.conf +++ b/dom/bindings/Bindings.conf @@ -1461,6 +1461,11 @@ DOMInterfaces = { 'headerFile': 'WebGLExtensions.h' }, +'WebGLExtensionShaderTextureLod': { + 'nativeType': 'mozilla::WebGLExtensionShaderTextureLod', + 'headerFile': 'WebGLExtensions.h' +}, + 'WebGLExtensionTextureFilterAnisotropic': { 'nativeType': 'mozilla::WebGLExtensionTextureFilterAnisotropic', 'headerFile': 'WebGLExtensions.h' diff --git a/dom/canvas/WebGLContextExtensions.cpp b/dom/canvas/WebGLContextExtensions.cpp index 1c1986d42704..8d1839cf7a1b 100644 --- a/dom/canvas/WebGLContextExtensions.cpp +++ b/dom/canvas/WebGLContextExtensions.cpp @@ -35,6 +35,7 @@ WebGLContext::GetExtensionString(WebGLExtensionID ext) WEBGL_EXTENSION_IDENTIFIER(EXT_color_buffer_half_float) WEBGL_EXTENSION_IDENTIFIER(EXT_frag_depth) WEBGL_EXTENSION_IDENTIFIER(EXT_sRGB) + WEBGL_EXTENSION_IDENTIFIER(EXT_shader_texture_lod) WEBGL_EXTENSION_IDENTIFIER(EXT_texture_filter_anisotropic) WEBGL_EXTENSION_IDENTIFIER(OES_element_index_uint) WEBGL_EXTENSION_IDENTIFIER(OES_standard_derivatives) @@ -155,6 +156,8 @@ bool WebGLContext::IsExtensionSupported(WebGLExtensionID ext) const return WebGLExtensionDrawBuffers::IsSupported(this); case WebGLExtensionID::EXT_frag_depth: return WebGLExtensionFragDepth::IsSupported(this); + case WebGLExtensionID::EXT_shader_texture_lod: + return gl->IsExtensionSupported(GLContext::EXT_shader_texture_lod); default: // For warnings-as-errors. break; @@ -334,6 +337,9 @@ WebGLContext::EnableExtension(WebGLExtensionID ext) case WebGLExtensionID::EXT_blend_minmax: obj = new WebGLExtensionBlendMinMax(this); break; + case WebGLExtensionID::EXT_shader_texture_lod: + obj = new WebGLExtensionShaderTextureLod(this); + break; default: MOZ_ASSERT(false, "should not get there."); } diff --git a/dom/canvas/WebGLContextGL.cpp b/dom/canvas/WebGLContextGL.cpp index 9afc5a53a8df..788885ed3e33 100644 --- a/dom/canvas/WebGLContextGL.cpp +++ b/dom/canvas/WebGLContextGL.cpp @@ -3041,6 +3041,9 @@ WebGLContext::CompileShader(WebGLShader *shader) if (IsExtensionEnabled(WebGLExtensionID::WEBGL_draw_buffers)) resources.EXT_draw_buffers = 1; + if (IsExtensionEnabled(WebGLExtensionID::EXT_shader_texture_lod)) + resources.EXT_shader_texture_lod = 1; + // Tell ANGLE to allow highp in frag shaders. (unless disabled) // If underlying GLES doesn't have highp in frag shaders, it should complain anyways. resources.FragmentPrecisionHigh = mDisableFragHighP ? 0 : 1; diff --git a/dom/canvas/WebGLExtensionShaderTextureLod.cpp b/dom/canvas/WebGLExtensionShaderTextureLod.cpp new file mode 100644 index 000000000000..2dcef6168a07 --- /dev/null +++ b/dom/canvas/WebGLExtensionShaderTextureLod.cpp @@ -0,0 +1,21 @@ +/* -*- 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 "WebGLContext.h" +#include "WebGLExtensions.h" +#include "mozilla/dom/WebGLRenderingContextBinding.h" + +using namespace mozilla; + +WebGLExtensionShaderTextureLod::WebGLExtensionShaderTextureLod(WebGLContext* context) + : WebGLExtensionBase(context) +{ +} + +WebGLExtensionShaderTextureLod::~WebGLExtensionShaderTextureLod() +{ +} + +IMPL_WEBGL_EXTENSION_GOOP(WebGLExtensionShaderTextureLod) diff --git a/dom/canvas/WebGLExtensions.h b/dom/canvas/WebGLExtensions.h index b8e58259df08..af2d81a4d488 100644 --- a/dom/canvas/WebGLExtensions.h +++ b/dom/canvas/WebGLExtensions.h @@ -178,6 +178,16 @@ public: DECL_WEBGL_EXTENSION_GOOP }; +class WebGLExtensionShaderTextureLod + : public WebGLExtensionBase +{ +public: + WebGLExtensionShaderTextureLod(WebGLContext*); + virtual ~WebGLExtensionShaderTextureLod(); + + DECL_WEBGL_EXTENSION_GOOP +}; + class WebGLExtensionTextureFilterAnisotropic : public WebGLExtensionBase { diff --git a/dom/canvas/WebGLTypes.h b/dom/canvas/WebGLTypes.h index e4bf6a0ae034..5acc0356a7f0 100644 --- a/dom/canvas/WebGLTypes.h +++ b/dom/canvas/WebGLTypes.h @@ -150,6 +150,7 @@ MOZ_BEGIN_ENUM_CLASS(WebGLExtensionID, uint8_t) EXT_color_buffer_half_float, EXT_frag_depth, EXT_sRGB, + EXT_shader_texture_lod, EXT_texture_filter_anisotropic, OES_element_index_uint, OES_standard_derivatives, diff --git a/dom/canvas/moz.build b/dom/canvas/moz.build index c2528cde2b3a..065fa6d7031c 100644 --- a/dom/canvas/moz.build +++ b/dom/canvas/moz.build @@ -73,6 +73,7 @@ if CONFIG['MOZ_WEBGL']: 'WebGLExtensionFragDepth.cpp', 'WebGLExtensionInstancedArrays.cpp', 'WebGLExtensionLoseContext.cpp', + 'WebGLExtensionShaderTextureLod.cpp', 'WebGLExtensionSRGB.cpp', 'WebGLExtensionStandardDerivatives.cpp', 'WebGLExtensionTextureFilterAnisotropic.cpp', diff --git a/dom/canvas/test/webgl-conformance/conformance/extensions/00_test_list.txt b/dom/canvas/test/webgl-conformance/conformance/extensions/00_test_list.txt index a1b753dbcd9e..0b2d6ee2888b 100644 --- a/dom/canvas/test/webgl-conformance/conformance/extensions/00_test_list.txt +++ b/dom/canvas/test/webgl-conformance/conformance/extensions/00_test_list.txt @@ -8,3 +8,4 @@ webgl-compressed-texture-etc1.html webgl-compressed-texture-s3tc.html --min-version 1.0.2 webgl-depth-texture.html ext-sRGB.html +ext-shader-texture-lod.html diff --git a/dom/canvas/test/webgl-conformance/conformance/extensions/ext-shader-texture-lod.html b/dom/canvas/test/webgl-conformance/conformance/extensions/ext-shader-texture-lod.html new file mode 100644 index 000000000000..e53e35270314 --- /dev/null +++ b/dom/canvas/test/webgl-conformance/conformance/extensions/ext-shader-texture-lod.html @@ -0,0 +1,280 @@ + + + + + +WebGL EXT_shader_texture_lod Conformance Tests + + + + + + + +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + diff --git a/dom/canvas/test/webgl-conformance/mochitest-conformance-files.ini b/dom/canvas/test/webgl-conformance/mochitest-conformance-files.ini index cc1c6d7d1603..060a41b24d40 100644 --- a/dom/canvas/test/webgl-conformance/mochitest-conformance-files.ini +++ b/dom/canvas/test/webgl-conformance/mochitest-conformance-files.ini @@ -39,6 +39,7 @@ support-files = conformance/extensions/00_test_list.txt conformance/extensions/ext-sRGB.html conformance/extensions/ext-texture-filter-anisotropic.html + conformance/extensions/ext-shader-texture-lod.html conformance/extensions/oes-standard-derivatives.html conformance/extensions/oes-texture-float.html conformance/extensions/oes-vertex-array-object.html diff --git a/dom/webidl/WebGLRenderingContext.webidl b/dom/webidl/WebGLRenderingContext.webidl index e826931528af..b5806ae45026 100644 --- a/dom/webidl/WebGLRenderingContext.webidl +++ b/dom/webidl/WebGLRenderingContext.webidl @@ -916,6 +916,11 @@ interface WebGLExtensionTextureFloatLinear { }; +[NoInterfaceObject] +interface WebGLExtensionShaderTextureLod +{ +}; + [NoInterfaceObject] interface WebGLExtensionTextureHalfFloat { diff --git a/gfx/gl/GLContext.cpp b/gfx/gl/GLContext.cpp index b7e4e8d888c6..936ec42f1731 100644 --- a/gfx/gl/GLContext.cpp +++ b/gfx/gl/GLContext.cpp @@ -142,6 +142,7 @@ static const char *sExtensionNames[] = { "GL_EXT_frag_depth", "GL_OES_compressed_ETC1_RGB8_texture", "GL_EXT_draw_range_elements", + "GL_EXT_shader_texture_lod", nullptr }; diff --git a/gfx/gl/GLContext.h b/gfx/gl/GLContext.h index 144b73716827..132e557047d7 100644 --- a/gfx/gl/GLContext.h +++ b/gfx/gl/GLContext.h @@ -412,6 +412,7 @@ public: EXT_frag_depth, OES_compressed_ETC1_RGB8_texture, EXT_draw_range_elements, + EXT_shader_texture_lod, Extensions_Max, Extensions_End };