diff --git a/dom/canvas/WebGLContextExtensions.cpp b/dom/canvas/WebGLContextExtensions.cpp index 9e89c3c5e81e..3b6c4f5fa5ec 100644 --- a/dom/canvas/WebGLContextExtensions.cpp +++ b/dom/canvas/WebGLContextExtensions.cpp @@ -32,6 +32,7 @@ WebGLContext::GetExtensionString(WebGLExtensionID ext) WEBGL_EXTENSION_IDENTIFIER(ANGLE_instanced_arrays) WEBGL_EXTENSION_IDENTIFIER(EXT_blend_minmax) + WEBGL_EXTENSION_IDENTIFIER(EXT_color_buffer_float) WEBGL_EXTENSION_IDENTIFIER(EXT_color_buffer_half_float) WEBGL_EXTENSION_IDENTIFIER(EXT_frag_depth) WEBGL_EXTENSION_IDENTIFIER(EXT_shader_texture_lod) @@ -151,7 +152,18 @@ WebGLContext::IsExtensionSupported(WebGLExtensionID ext) const break; } - if (!IsWebGL2()) { + if (IsWebGL2()) { + // WebGL2-only extensions + switch (ext) { + // EXT_ + case WebGLExtensionID::EXT_color_buffer_float: + return WebGLExtensionEXTColorBufferFloat::IsSupported(this); + + default: + // For warnings-as-errors. + break; + } + } else { // WebGL1-only extensions switch (ext) { // ANGLE_ @@ -331,6 +343,9 @@ WebGLContext::EnableExtension(WebGLExtensionID ext) case WebGLExtensionID::EXT_blend_minmax: obj = new WebGLExtensionBlendMinMax(this); break; + case WebGLExtensionID::EXT_color_buffer_float: + obj = new WebGLExtensionEXTColorBufferFloat(this); + break; case WebGLExtensionID::EXT_color_buffer_half_float: obj = new WebGLExtensionColorBufferHalfFloat(this); break; diff --git a/dom/canvas/WebGLExtensionEXTColorBufferFloat.cpp b/dom/canvas/WebGLExtensionEXTColorBufferFloat.cpp new file mode 100644 index 000000000000..8061f6fc16e8 --- /dev/null +++ b/dom/canvas/WebGLExtensionEXTColorBufferFloat.cpp @@ -0,0 +1,51 @@ +/* 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 "WebGLExtensions.h" + +#include "GLContext.h" +#include "mozilla/dom/WebGL2RenderingContextBinding.h" +#include "WebGLContext.h" +#include "WebGLFormats.h" + +namespace mozilla { + +WebGLExtensionEXTColorBufferFloat::WebGLExtensionEXTColorBufferFloat(WebGLContext* webgl) + : WebGLExtensionBase(webgl) +{ + MOZ_ASSERT(IsSupported(webgl), "Don't construct extension if unsupported."); + + auto& fua = webgl->mFormatUsage; + + auto fnUpdateUsage = [&fua](GLenum sizedFormat, webgl::EffectiveFormat effFormat) { + auto usage = fua->EditUsage(effFormat); + usage->isRenderable = true; + fua->AllowRBFormat(sizedFormat, usage); + }; + +#define FOO(x) fnUpdateUsage(LOCAL_GL_ ## x, webgl::EffectiveFormat::x) + + FOO(R16F); + FOO(RG16F); + FOO(RGBA16F); + + FOO(R32F); + FOO(RG32F); + FOO(RGBA32F); + + FOO(R11F_G11F_B10F); + +#undef FOO +} + +/*static*/ bool +WebGLExtensionEXTColorBufferFloat::IsSupported(const WebGLContext* webgl) +{ + const gl::GLContext* gl = webgl->GL(); + return gl->IsSupported(gl::GLFeature::EXT_color_buffer_float); +} + +IMPL_WEBGL_EXTENSION_GOOP(WebGLExtensionEXTColorBufferFloat, EXT_color_buffer_float) + +} // namespace mozilla diff --git a/dom/canvas/WebGLExtensions.h b/dom/canvas/WebGLExtensions.h index 39436025d359..221a92a5f526 100644 --- a/dom/canvas/WebGLExtensions.h +++ b/dom/canvas/WebGLExtensions.h @@ -153,6 +153,18 @@ public: DECL_WEBGL_EXTENSION_GOOP }; +class WebGLExtensionEXTColorBufferFloat + : public WebGLExtensionBase +{ +public: + explicit WebGLExtensionEXTColorBufferFloat(WebGLContext*); + virtual ~WebGLExtensionEXTColorBufferFloat() { } + + static bool IsSupported(const WebGLContext*); + + DECL_WEBGL_EXTENSION_GOOP +}; + class WebGLExtensionFragDepth : public WebGLExtensionBase { diff --git a/dom/canvas/WebGLProgram.cpp b/dom/canvas/WebGLProgram.cpp index d4f1115dbaf6..f7bb0e771fae 100644 --- a/dom/canvas/WebGLProgram.cpp +++ b/dom/canvas/WebGLProgram.cpp @@ -10,6 +10,7 @@ #include "mozilla/dom/WebGL2RenderingContextBinding.h" #include "mozilla/dom/WebGLRenderingContextBinding.h" #include "mozilla/RefPtr.h" +#include "nsPrintfCString.h" #include "WebGLActiveInfo.h" #include "WebGLContext.h" #include "WebGLShader.h" diff --git a/dom/canvas/WebGLTypes.h b/dom/canvas/WebGLTypes.h index 30abb9104041..fb7119d4b786 100644 --- a/dom/canvas/WebGLTypes.h +++ b/dom/canvas/WebGLTypes.h @@ -139,6 +139,7 @@ enum class WebGLTexDimensions : uint8_t { enum class WebGLExtensionID : uint8_t { ANGLE_instanced_arrays, EXT_blend_minmax, + EXT_color_buffer_float, EXT_color_buffer_half_float, EXT_frag_depth, EXT_sRGB, diff --git a/dom/canvas/moz.build b/dom/canvas/moz.build index 5251c95cbe56..30dee922169d 100644 --- a/dom/canvas/moz.build +++ b/dom/canvas/moz.build @@ -112,6 +112,7 @@ UNIFIED_SOURCES += [ 'WebGLExtensionDisjointTimerQuery.cpp', 'WebGLExtensionDrawBuffers.cpp', 'WebGLExtensionElementIndexUint.cpp', + 'WebGLExtensionEXTColorBufferFloat.cpp', 'WebGLExtensionFragDepth.cpp', 'WebGLExtensionInstancedArrays.cpp', 'WebGLExtensionLoseContext.cpp', diff --git a/gfx/gl/GLContext.h b/gfx/gl/GLContext.h index 284b9b1b034d..ea1c2968793c 100644 --- a/gfx/gl/GLContext.h +++ b/gfx/gl/GLContext.h @@ -95,6 +95,7 @@ enum class GLFeature { element_index_uint, ES2_compatibility, ES3_compatibility, + EXT_color_buffer_float, frag_color_float, frag_depth, framebuffer_blit, diff --git a/gfx/gl/GLContextFeatures.cpp b/gfx/gl/GLContextFeatures.cpp index d328e9f164ea..9e65c58c99a2 100644 --- a/gfx/gl/GLContextFeatures.cpp +++ b/gfx/gl/GLContextFeatures.cpp @@ -186,6 +186,16 @@ static const FeatureInfo sFeatureInfoArr[] = { GLContext::Extensions_End } }, + { + "EXT_color_buffer_float", + GLVersion::GL3, + GLESVersion::NONE, + GLContext::Extension_None, + { + GLContext::EXT_color_buffer_float, + GLContext::Extensions_End + } + }, { // Removes clamping for float color outputs from frag shaders. "frag_color_float",