2018-11-30 22:52:05 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2013-08-27 01:12:53 +04:00
|
|
|
/* 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"
|
2020-01-09 01:19:14 +03:00
|
|
|
#include "ClientWebGLExtensions.h"
|
2013-08-27 01:12:53 +04:00
|
|
|
#include "GLContext.h"
|
2016-11-16 22:10:22 +03:00
|
|
|
#include "mozilla/dom/BindingDeclarations.h"
|
2020-01-09 01:19:16 +03:00
|
|
|
#include "mozilla/dom/ToJSValue.h"
|
|
|
|
#include "mozilla/EnumeratedRange.h"
|
|
|
|
#include "nsString.h"
|
|
|
|
#include "WebGLContextUtils.h"
|
|
|
|
#include "WebGLExtensions.h"
|
2013-08-27 01:12:53 +04:00
|
|
|
|
2014-11-14 07:03:50 +03:00
|
|
|
namespace mozilla {
|
2013-08-27 01:12:53 +04:00
|
|
|
|
2020-01-09 01:19:16 +03:00
|
|
|
const char* GetExtensionName(const WebGLExtensionID ext) {
|
|
|
|
static EnumeratedArray<WebGLExtensionID, WebGLExtensionID::Max, const char*>
|
|
|
|
sExtensionNamesEnumeratedArray;
|
2014-05-31 00:21:23 +04:00
|
|
|
static bool initialized = false;
|
|
|
|
|
|
|
|
if (!initialized) {
|
|
|
|
initialized = true;
|
|
|
|
|
|
|
|
#define WEBGL_EXTENSION_IDENTIFIER(x) \
|
|
|
|
sExtensionNamesEnumeratedArray[WebGLExtensionID::x] = #x;
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2014-05-31 00:21:23 +04:00
|
|
|
WEBGL_EXTENSION_IDENTIFIER(ANGLE_instanced_arrays)
|
2014-06-14 20:07:53 +04:00
|
|
|
WEBGL_EXTENSION_IDENTIFIER(EXT_blend_minmax)
|
2016-05-05 02:39:02 +03:00
|
|
|
WEBGL_EXTENSION_IDENTIFIER(EXT_color_buffer_float)
|
2014-05-31 00:21:23 +04:00
|
|
|
WEBGL_EXTENSION_IDENTIFIER(EXT_color_buffer_half_float)
|
2019-02-01 02:39:12 +03:00
|
|
|
WEBGL_EXTENSION_IDENTIFIER(EXT_disjoint_timer_query)
|
|
|
|
WEBGL_EXTENSION_IDENTIFIER(EXT_float_blend)
|
2014-05-31 00:21:23 +04:00
|
|
|
WEBGL_EXTENSION_IDENTIFIER(EXT_frag_depth)
|
2014-07-24 19:58:43 +04:00
|
|
|
WEBGL_EXTENSION_IDENTIFIER(EXT_shader_texture_lod)
|
2015-01-08 03:28:05 +03:00
|
|
|
WEBGL_EXTENSION_IDENTIFIER(EXT_sRGB)
|
2018-09-28 02:37:40 +03:00
|
|
|
WEBGL_EXTENSION_IDENTIFIER(EXT_texture_compression_bptc)
|
|
|
|
WEBGL_EXTENSION_IDENTIFIER(EXT_texture_compression_rgtc)
|
2014-05-31 00:21:23 +04:00
|
|
|
WEBGL_EXTENSION_IDENTIFIER(EXT_texture_filter_anisotropic)
|
2017-04-11 11:50:59 +03:00
|
|
|
WEBGL_EXTENSION_IDENTIFIER(MOZ_debug)
|
2014-05-31 00:21:23 +04:00
|
|
|
WEBGL_EXTENSION_IDENTIFIER(OES_element_index_uint)
|
2019-02-22 22:25:20 +03:00
|
|
|
WEBGL_EXTENSION_IDENTIFIER(OES_fbo_render_mipmap)
|
2014-05-31 00:21:23 +04:00
|
|
|
WEBGL_EXTENSION_IDENTIFIER(OES_standard_derivatives)
|
|
|
|
WEBGL_EXTENSION_IDENTIFIER(OES_texture_float)
|
|
|
|
WEBGL_EXTENSION_IDENTIFIER(OES_texture_float_linear)
|
|
|
|
WEBGL_EXTENSION_IDENTIFIER(OES_texture_half_float)
|
|
|
|
WEBGL_EXTENSION_IDENTIFIER(OES_texture_half_float_linear)
|
|
|
|
WEBGL_EXTENSION_IDENTIFIER(OES_vertex_array_object)
|
2019-05-23 23:48:21 +03:00
|
|
|
WEBGL_EXTENSION_IDENTIFIER(OVR_multiview2)
|
2014-05-31 00:21:23 +04:00
|
|
|
WEBGL_EXTENSION_IDENTIFIER(WEBGL_color_buffer_float)
|
2016-11-23 05:59:35 +03:00
|
|
|
WEBGL_EXTENSION_IDENTIFIER(WEBGL_compressed_texture_astc)
|
2016-11-11 03:37:03 +03:00
|
|
|
WEBGL_EXTENSION_IDENTIFIER(WEBGL_compressed_texture_etc)
|
2014-05-31 00:21:23 +04:00
|
|
|
WEBGL_EXTENSION_IDENTIFIER(WEBGL_compressed_texture_etc1)
|
|
|
|
WEBGL_EXTENSION_IDENTIFIER(WEBGL_compressed_texture_pvrtc)
|
|
|
|
WEBGL_EXTENSION_IDENTIFIER(WEBGL_compressed_texture_s3tc)
|
2017-05-30 18:21:33 +03:00
|
|
|
WEBGL_EXTENSION_IDENTIFIER(WEBGL_compressed_texture_s3tc_srgb)
|
2014-05-31 00:21:23 +04:00
|
|
|
WEBGL_EXTENSION_IDENTIFIER(WEBGL_debug_renderer_info)
|
|
|
|
WEBGL_EXTENSION_IDENTIFIER(WEBGL_debug_shaders)
|
|
|
|
WEBGL_EXTENSION_IDENTIFIER(WEBGL_depth_texture)
|
|
|
|
WEBGL_EXTENSION_IDENTIFIER(WEBGL_draw_buffers)
|
2019-06-25 22:48:24 +03:00
|
|
|
WEBGL_EXTENSION_IDENTIFIER(WEBGL_explicit_present)
|
2014-05-31 00:21:23 +04:00
|
|
|
WEBGL_EXTENSION_IDENTIFIER(WEBGL_lose_context)
|
|
|
|
|
|
|
|
#undef WEBGL_EXTENSION_IDENTIFIER
|
|
|
|
}
|
2014-04-26 06:34:07 +04:00
|
|
|
|
2014-05-31 00:21:23 +04:00
|
|
|
return sExtensionNamesEnumeratedArray[ext];
|
2013-08-27 01:12:53 +04:00
|
|
|
}
|
|
|
|
|
2020-01-09 01:19:16 +03:00
|
|
|
// ----------------------------
|
|
|
|
// ClientWebGLContext
|
2014-02-12 02:37:05 +04:00
|
|
|
|
2020-01-09 01:19:16 +03:00
|
|
|
void ClientWebGLContext::GetExtension(JSContext* cx, const nsAString& wideName,
|
|
|
|
JS::MutableHandle<JSObject*> retval,
|
|
|
|
dom::CallerType callerType,
|
|
|
|
ErrorResult& rv) {
|
|
|
|
retval.set(nullptr);
|
|
|
|
const FuncScope funcScope(*this, "getExtension");
|
|
|
|
if (IsContextLost()) return;
|
2014-02-12 02:37:05 +04:00
|
|
|
|
2020-01-09 01:19:16 +03:00
|
|
|
const auto name = NS_ConvertUTF16toUTF8(wideName);
|
|
|
|
|
|
|
|
auto ext = WebGLExtensionID::Max;
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2020-01-09 01:19:16 +03:00
|
|
|
// step 1: figure what extension is wanted
|
|
|
|
for (const auto extension : MakeEnumeratedRange(WebGLExtensionID::Max)) {
|
|
|
|
const auto& curName = GetExtensionName(extension);
|
2020-05-27 21:11:12 +03:00
|
|
|
if (name.Equals(curName, nsCaseInsensitiveCStringComparator)) {
|
2020-01-09 01:19:16 +03:00
|
|
|
ext = extension;
|
|
|
|
break;
|
2013-08-27 01:12:53 +04:00
|
|
|
}
|
2018-11-30 13:46:48 +03:00
|
|
|
}
|
2013-08-27 01:12:53 +04:00
|
|
|
|
2020-01-09 01:19:16 +03:00
|
|
|
if (ext == WebGLExtensionID::Max) return;
|
|
|
|
|
|
|
|
RefPtr<ClientWebGLExtensionBase> extObj;
|
|
|
|
if (ext == WebGLExtensionID::WEBGL_lose_context) {
|
|
|
|
extObj = mExtLoseContext;
|
|
|
|
} else {
|
|
|
|
extObj = GetExtension(ext, callerType);
|
|
|
|
}
|
|
|
|
if (!extObj) return;
|
|
|
|
|
|
|
|
// Ugh, this would be easier returning `any` than `object`.
|
|
|
|
JS::Rooted<JS::Value> v(cx);
|
|
|
|
MOZ_ALWAYS_TRUE(dom::ToJSValue(cx, extObj, &v));
|
|
|
|
if (v.isObject()) {
|
|
|
|
retval.set(&v.toObject());
|
|
|
|
}
|
2013-08-27 01:12:53 +04:00
|
|
|
}
|
|
|
|
|
2020-01-09 01:19:16 +03:00
|
|
|
RefPtr<ClientWebGLExtensionBase> ClientWebGLContext::GetExtension(
|
|
|
|
const WebGLExtensionID ext, const dom::CallerType callerType) {
|
|
|
|
if (ext == WebGLExtensionID::WEBGL_lose_context) {
|
|
|
|
// Always the same.
|
|
|
|
return mExtLoseContext;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!mNotLost) return nullptr;
|
|
|
|
|
|
|
|
if (!IsSupported(ext, callerType)) return nullptr;
|
|
|
|
|
2020-08-01 02:04:44 +03:00
|
|
|
auto& extSlot = mNotLost->extensions[UnderlyingValue(ext)];
|
2020-01-09 01:19:16 +03:00
|
|
|
if (MOZ_UNLIKELY(!extSlot)) {
|
|
|
|
extSlot = [&]() -> RefPtr<ClientWebGLExtensionBase> {
|
|
|
|
switch (ext) {
|
|
|
|
// ANGLE_
|
|
|
|
case WebGLExtensionID::ANGLE_instanced_arrays:
|
|
|
|
return new ClientWebGLExtensionInstancedArrays(*this);
|
|
|
|
|
|
|
|
// EXT_
|
|
|
|
case WebGLExtensionID::EXT_blend_minmax:
|
|
|
|
return new ClientWebGLExtensionBlendMinMax(*this);
|
|
|
|
case WebGLExtensionID::EXT_color_buffer_float:
|
|
|
|
return new ClientWebGLExtensionEXTColorBufferFloat(*this);
|
|
|
|
case WebGLExtensionID::EXT_color_buffer_half_float:
|
|
|
|
return new ClientWebGLExtensionColorBufferHalfFloat(*this);
|
|
|
|
case WebGLExtensionID::EXT_disjoint_timer_query:
|
|
|
|
return new ClientWebGLExtensionDisjointTimerQuery(*this);
|
|
|
|
case WebGLExtensionID::EXT_float_blend:
|
|
|
|
return new ClientWebGLExtensionFloatBlend(*this);
|
|
|
|
case WebGLExtensionID::EXT_frag_depth:
|
|
|
|
return new ClientWebGLExtensionFragDepth(*this);
|
|
|
|
case WebGLExtensionID::EXT_shader_texture_lod:
|
|
|
|
return new ClientWebGLExtensionShaderTextureLod(*this);
|
|
|
|
case WebGLExtensionID::EXT_sRGB:
|
|
|
|
return new ClientWebGLExtensionSRGB(*this);
|
|
|
|
case WebGLExtensionID::EXT_texture_compression_bptc:
|
|
|
|
return new ClientWebGLExtensionCompressedTextureBPTC(*this);
|
|
|
|
case WebGLExtensionID::EXT_texture_compression_rgtc:
|
|
|
|
return new ClientWebGLExtensionCompressedTextureRGTC(*this);
|
|
|
|
case WebGLExtensionID::EXT_texture_filter_anisotropic:
|
|
|
|
return new ClientWebGLExtensionTextureFilterAnisotropic(*this);
|
|
|
|
|
|
|
|
// MOZ_
|
|
|
|
case WebGLExtensionID::MOZ_debug:
|
|
|
|
return new ClientWebGLExtensionMOZDebug(*this);
|
|
|
|
|
|
|
|
// OES_
|
|
|
|
case WebGLExtensionID::OES_element_index_uint:
|
|
|
|
return new ClientWebGLExtensionElementIndexUint(*this);
|
|
|
|
case WebGLExtensionID::OES_fbo_render_mipmap:
|
|
|
|
return new ClientWebGLExtensionFBORenderMipmap(*this);
|
|
|
|
case WebGLExtensionID::OES_standard_derivatives:
|
|
|
|
return new ClientWebGLExtensionStandardDerivatives(*this);
|
|
|
|
case WebGLExtensionID::OES_texture_float:
|
|
|
|
return new ClientWebGLExtensionTextureFloat(*this);
|
|
|
|
case WebGLExtensionID::OES_texture_float_linear:
|
|
|
|
return new ClientWebGLExtensionTextureFloatLinear(*this);
|
|
|
|
case WebGLExtensionID::OES_texture_half_float:
|
|
|
|
return new ClientWebGLExtensionTextureHalfFloat(*this);
|
|
|
|
case WebGLExtensionID::OES_texture_half_float_linear:
|
|
|
|
return new ClientWebGLExtensionTextureHalfFloatLinear(*this);
|
|
|
|
case WebGLExtensionID::OES_vertex_array_object:
|
|
|
|
return new ClientWebGLExtensionVertexArray(*this);
|
|
|
|
|
|
|
|
// OVR_
|
|
|
|
case WebGLExtensionID::OVR_multiview2:
|
|
|
|
return new ClientWebGLExtensionMultiview(*this);
|
|
|
|
|
|
|
|
// WEBGL_
|
|
|
|
case WebGLExtensionID::WEBGL_color_buffer_float:
|
|
|
|
return new ClientWebGLExtensionColorBufferFloat(*this);
|
|
|
|
case WebGLExtensionID::WEBGL_compressed_texture_astc:
|
|
|
|
return new ClientWebGLExtensionCompressedTextureASTC(*this);
|
|
|
|
case WebGLExtensionID::WEBGL_compressed_texture_etc:
|
|
|
|
return new ClientWebGLExtensionCompressedTextureES3(*this);
|
|
|
|
case WebGLExtensionID::WEBGL_compressed_texture_etc1:
|
|
|
|
return new ClientWebGLExtensionCompressedTextureETC1(*this);
|
|
|
|
case WebGLExtensionID::WEBGL_compressed_texture_pvrtc:
|
|
|
|
return new ClientWebGLExtensionCompressedTexturePVRTC(*this);
|
|
|
|
case WebGLExtensionID::WEBGL_compressed_texture_s3tc:
|
|
|
|
return new ClientWebGLExtensionCompressedTextureS3TC(*this);
|
|
|
|
case WebGLExtensionID::WEBGL_compressed_texture_s3tc_srgb:
|
|
|
|
return new ClientWebGLExtensionCompressedTextureS3TC_SRGB(*this);
|
|
|
|
case WebGLExtensionID::WEBGL_debug_renderer_info:
|
|
|
|
return new ClientWebGLExtensionDebugRendererInfo(*this);
|
|
|
|
case WebGLExtensionID::WEBGL_debug_shaders:
|
|
|
|
return new ClientWebGLExtensionDebugShaders(*this);
|
|
|
|
case WebGLExtensionID::WEBGL_depth_texture:
|
|
|
|
return new ClientWebGLExtensionDepthTexture(*this);
|
|
|
|
case WebGLExtensionID::WEBGL_draw_buffers:
|
|
|
|
return new ClientWebGLExtensionDrawBuffers(*this);
|
|
|
|
case WebGLExtensionID::WEBGL_explicit_present:
|
|
|
|
return new ClientWebGLExtensionExplicitPresent(*this);
|
|
|
|
|
|
|
|
case WebGLExtensionID::WEBGL_lose_context:
|
|
|
|
case WebGLExtensionID::Max:
|
|
|
|
break;
|
|
|
|
}
|
2020-01-09 01:19:23 +03:00
|
|
|
MOZ_CRASH("illegal extension enum");
|
2020-01-09 01:19:16 +03:00
|
|
|
}();
|
|
|
|
MOZ_ASSERT(extSlot);
|
|
|
|
RequestExtension(ext);
|
|
|
|
}
|
|
|
|
|
|
|
|
return extSlot;
|
|
|
|
}
|
2013-08-27 01:12:53 +04:00
|
|
|
|
2020-01-09 01:19:16 +03:00
|
|
|
// ----------------------------
|
|
|
|
// WebGLContext
|
2019-03-06 02:20:08 +03:00
|
|
|
|
2020-01-09 01:19:16 +03:00
|
|
|
bool WebGLContext::IsExtensionSupported(WebGLExtensionID ext) const {
|
2015-11-24 08:55:59 +03:00
|
|
|
switch (ext) {
|
2020-01-09 01:19:16 +03:00
|
|
|
case WebGLExtensionID::MOZ_debug:
|
2020-01-09 01:19:23 +03:00
|
|
|
case WebGLExtensionID::WEBGL_debug_renderer_info:
|
|
|
|
case WebGLExtensionID::WEBGL_debug_shaders:
|
|
|
|
case WebGLExtensionID::WEBGL_lose_context:
|
2020-01-09 01:19:16 +03:00
|
|
|
// Always supported.
|
|
|
|
return true;
|
|
|
|
|
2015-11-25 07:15:29 +03:00
|
|
|
// In alphabetical order
|
2019-02-05 06:34:49 +03:00
|
|
|
// ANGLE_
|
|
|
|
case WebGLExtensionID::ANGLE_instanced_arrays:
|
|
|
|
return WebGLExtensionInstancedArrays::IsSupported(this);
|
|
|
|
|
2015-01-08 03:28:05 +03:00
|
|
|
// EXT_
|
2019-02-05 06:34:49 +03:00
|
|
|
case WebGLExtensionID::EXT_blend_minmax:
|
|
|
|
return WebGLExtensionBlendMinMax::IsSupported(this);
|
|
|
|
|
|
|
|
case WebGLExtensionID::EXT_color_buffer_float:
|
|
|
|
return WebGLExtensionEXTColorBufferFloat::IsSupported(this);
|
|
|
|
|
|
|
|
case WebGLExtensionID::EXT_color_buffer_half_float:
|
|
|
|
return WebGLExtensionColorBufferHalfFloat::IsSupported(this);
|
|
|
|
|
2020-01-09 01:19:16 +03:00
|
|
|
case WebGLExtensionID::EXT_disjoint_timer_query:
|
|
|
|
return WebGLExtensionDisjointTimerQuery::IsSupported(this);
|
|
|
|
|
2019-02-05 06:34:49 +03:00
|
|
|
case WebGLExtensionID::EXT_float_blend:
|
|
|
|
return WebGLExtensionFloatBlend::IsSupported(this);
|
|
|
|
|
|
|
|
case WebGLExtensionID::EXT_frag_depth:
|
|
|
|
return WebGLExtensionFragDepth::IsSupported(this);
|
|
|
|
|
|
|
|
case WebGLExtensionID::EXT_shader_texture_lod:
|
|
|
|
return WebGLExtensionShaderTextureLod::IsSupported(this);
|
|
|
|
|
|
|
|
case WebGLExtensionID::EXT_sRGB:
|
|
|
|
return WebGLExtensionSRGB::IsSupported(this);
|
|
|
|
|
2018-09-28 02:37:40 +03:00
|
|
|
case WebGLExtensionID::EXT_texture_compression_bptc:
|
|
|
|
return WebGLExtensionCompressedTextureBPTC::IsSupported(this);
|
|
|
|
|
|
|
|
case WebGLExtensionID::EXT_texture_compression_rgtc:
|
|
|
|
return WebGLExtensionCompressedTextureRGTC::IsSupported(this);
|
|
|
|
|
2015-01-08 03:28:05 +03:00
|
|
|
case WebGLExtensionID::EXT_texture_filter_anisotropic:
|
|
|
|
return gl->IsExtensionSupported(
|
|
|
|
gl::GLContext::EXT_texture_filter_anisotropic);
|
|
|
|
|
|
|
|
// OES_
|
2019-02-05 06:34:49 +03:00
|
|
|
case WebGLExtensionID::OES_element_index_uint:
|
|
|
|
if (IsWebGL2()) return false;
|
|
|
|
return gl->IsSupported(gl::GLFeature::element_index_uint);
|
|
|
|
|
2019-02-22 22:25:20 +03:00
|
|
|
case WebGLExtensionID::OES_fbo_render_mipmap:
|
|
|
|
return WebGLExtensionFBORenderMipmap::IsSupported(this);
|
|
|
|
|
2019-02-05 06:34:49 +03:00
|
|
|
case WebGLExtensionID::OES_standard_derivatives:
|
|
|
|
if (IsWebGL2()) return false;
|
|
|
|
return gl->IsSupported(gl::GLFeature::standard_derivatives);
|
|
|
|
|
|
|
|
case WebGLExtensionID::OES_texture_float:
|
|
|
|
return WebGLExtensionTextureFloat::IsSupported(this);
|
|
|
|
|
2014-11-14 07:03:50 +03:00
|
|
|
case WebGLExtensionID::OES_texture_float_linear:
|
|
|
|
return gl->IsSupported(gl::GLFeature::texture_float_linear);
|
|
|
|
|
2019-02-05 06:34:49 +03:00
|
|
|
case WebGLExtensionID::OES_texture_half_float:
|
|
|
|
return WebGLExtensionTextureHalfFloat::IsSupported(this);
|
|
|
|
|
|
|
|
case WebGLExtensionID::OES_texture_half_float_linear:
|
|
|
|
if (IsWebGL2()) return false;
|
|
|
|
return gl->IsSupported(gl::GLFeature::texture_half_float_linear);
|
|
|
|
|
|
|
|
case WebGLExtensionID::OES_vertex_array_object:
|
|
|
|
return !IsWebGL2(); // Always supported in webgl1.
|
|
|
|
|
2019-05-23 23:48:21 +03:00
|
|
|
// OVR_
|
|
|
|
case WebGLExtensionID::OVR_multiview2:
|
|
|
|
return WebGLExtensionMultiview::IsSupported(this);
|
|
|
|
|
2015-01-08 03:28:05 +03:00
|
|
|
// WEBGL_
|
2019-02-05 06:34:49 +03:00
|
|
|
case WebGLExtensionID::WEBGL_color_buffer_float:
|
|
|
|
return WebGLExtensionColorBufferFloat::IsSupported(this);
|
|
|
|
|
2016-11-23 05:59:35 +03:00
|
|
|
case WebGLExtensionID::WEBGL_compressed_texture_astc:
|
|
|
|
return WebGLExtensionCompressedTextureASTC::IsSupported(this);
|
2019-02-05 06:34:49 +03:00
|
|
|
|
2016-11-11 03:37:03 +03:00
|
|
|
case WebGLExtensionID::WEBGL_compressed_texture_etc:
|
2017-01-26 01:13:15 +03:00
|
|
|
return gl->IsSupported(gl::GLFeature::ES3_compatibility) &&
|
|
|
|
!gl->IsANGLE();
|
2019-02-05 06:34:49 +03:00
|
|
|
|
2014-11-14 07:03:50 +03:00
|
|
|
case WebGLExtensionID::WEBGL_compressed_texture_etc1:
|
2017-01-26 01:13:15 +03:00
|
|
|
return gl->IsExtensionSupported(
|
|
|
|
gl::GLContext::OES_compressed_ETC1_RGB8_texture) &&
|
|
|
|
!gl->IsANGLE();
|
2019-02-05 06:34:49 +03:00
|
|
|
|
2014-11-14 07:03:50 +03:00
|
|
|
case WebGLExtensionID::WEBGL_compressed_texture_pvrtc:
|
|
|
|
return gl->IsExtensionSupported(
|
|
|
|
gl::GLContext::IMG_texture_compression_pvrtc);
|
2019-02-05 06:34:49 +03:00
|
|
|
|
2015-01-08 03:28:05 +03:00
|
|
|
case WebGLExtensionID::WEBGL_compressed_texture_s3tc:
|
2017-05-30 18:21:33 +03:00
|
|
|
return WebGLExtensionCompressedTextureS3TC::IsSupported(this);
|
2019-02-05 06:34:49 +03:00
|
|
|
|
2017-05-30 18:21:33 +03:00
|
|
|
case WebGLExtensionID::WEBGL_compressed_texture_s3tc_srgb:
|
2017-08-09 02:32:23 +03:00
|
|
|
return WebGLExtensionCompressedTextureS3TC_SRGB::IsSupported(this);
|
2019-02-05 06:34:49 +03:00
|
|
|
|
|
|
|
case WebGLExtensionID::WEBGL_depth_texture:
|
|
|
|
return WebGLExtensionDepthTexture::IsSupported(this);
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2019-02-05 06:34:49 +03:00
|
|
|
case WebGLExtensionID::WEBGL_draw_buffers:
|
|
|
|
return WebGLExtensionDrawBuffers::IsSupported(this);
|
2019-02-01 02:39:12 +03:00
|
|
|
|
2019-06-25 22:48:24 +03:00
|
|
|
case WebGLExtensionID::WEBGL_explicit_present:
|
|
|
|
return WebGLExtensionExplicitPresent::IsSupported(this);
|
|
|
|
|
2019-02-05 06:34:49 +03:00
|
|
|
case WebGLExtensionID::Max:
|
2020-01-09 01:19:16 +03:00
|
|
|
break;
|
2018-11-30 13:46:48 +03:00
|
|
|
}
|
2013-08-27 01:12:53 +04:00
|
|
|
|
2020-01-09 01:19:16 +03:00
|
|
|
MOZ_CRASH();
|
2013-08-27 01:12:53 +04:00
|
|
|
}
|
|
|
|
|
2019-07-09 08:21:30 +03:00
|
|
|
bool WebGLContext::IsExtensionExplicit(const WebGLExtensionID ext) const {
|
|
|
|
return mExtensions[ext] && mExtensions[ext]->IsExplicit();
|
|
|
|
}
|
|
|
|
|
2020-01-09 01:19:16 +03:00
|
|
|
void WebGLContext::WarnIfImplicit(const WebGLExtensionID ext) const {
|
2019-07-09 08:21:30 +03:00
|
|
|
const auto& extension = mExtensions[ext];
|
|
|
|
if (!extension || extension->IsExplicit()) return;
|
|
|
|
|
|
|
|
GenerateWarning(
|
|
|
|
"Using format enabled by implicitly enabled extension: %s. "
|
|
|
|
"For maximal portability enable it explicitly.",
|
2020-01-09 01:19:16 +03:00
|
|
|
GetExtensionName(ext));
|
2013-08-27 01:12:53 +04:00
|
|
|
}
|
|
|
|
|
2020-01-09 01:19:16 +03:00
|
|
|
void WebGLContext::RequestExtension(const WebGLExtensionID ext,
|
|
|
|
const bool explicitly) {
|
|
|
|
const auto& limits = Limits();
|
|
|
|
if (!limits.supportedExtensions[ext]) return;
|
2013-08-27 01:12:53 +04:00
|
|
|
|
2020-01-09 01:19:16 +03:00
|
|
|
auto& slot = mExtensions[ext];
|
2013-08-27 01:12:53 +04:00
|
|
|
switch (ext) {
|
2015-01-08 03:28:05 +03:00
|
|
|
// ANGLE_
|
|
|
|
case WebGLExtensionID::ANGLE_instanced_arrays:
|
2020-01-09 01:19:16 +03:00
|
|
|
slot.reset(new WebGLExtensionInstancedArrays(this));
|
2014-11-14 07:03:50 +03:00
|
|
|
break;
|
2015-01-08 03:28:05 +03:00
|
|
|
|
|
|
|
// EXT_
|
|
|
|
case WebGLExtensionID::EXT_blend_minmax:
|
2020-01-09 01:19:16 +03:00
|
|
|
slot.reset(new WebGLExtensionBlendMinMax(this));
|
2014-11-14 07:03:50 +03:00
|
|
|
break;
|
2016-05-05 02:39:02 +03:00
|
|
|
case WebGLExtensionID::EXT_color_buffer_float:
|
2020-01-09 01:19:16 +03:00
|
|
|
slot.reset(new WebGLExtensionEXTColorBufferFloat(this));
|
2016-05-05 02:39:02 +03:00
|
|
|
break;
|
2015-01-08 03:28:05 +03:00
|
|
|
case WebGLExtensionID::EXT_color_buffer_half_float:
|
2020-01-09 01:19:16 +03:00
|
|
|
slot.reset(new WebGLExtensionColorBufferHalfFloat(this));
|
2014-11-14 07:03:50 +03:00
|
|
|
break;
|
2015-05-27 14:12:00 +03:00
|
|
|
case WebGLExtensionID::EXT_disjoint_timer_query:
|
2020-01-09 01:19:16 +03:00
|
|
|
slot.reset(new WebGLExtensionDisjointTimerQuery(this));
|
2015-05-27 14:12:00 +03:00
|
|
|
break;
|
2019-02-01 02:39:12 +03:00
|
|
|
case WebGLExtensionID::EXT_float_blend:
|
2020-01-09 01:19:16 +03:00
|
|
|
slot.reset(new WebGLExtensionFloatBlend(this));
|
2019-02-01 02:39:12 +03:00
|
|
|
break;
|
2015-01-08 03:28:05 +03:00
|
|
|
case WebGLExtensionID::EXT_frag_depth:
|
2020-01-09 01:19:16 +03:00
|
|
|
slot.reset(new WebGLExtensionFragDepth(this));
|
2014-11-14 07:03:50 +03:00
|
|
|
break;
|
2015-01-08 03:28:05 +03:00
|
|
|
case WebGLExtensionID::EXT_shader_texture_lod:
|
2020-01-09 01:19:16 +03:00
|
|
|
slot.reset(new WebGLExtensionShaderTextureLod(this));
|
2014-11-14 07:03:50 +03:00
|
|
|
break;
|
2015-01-08 03:28:05 +03:00
|
|
|
case WebGLExtensionID::EXT_sRGB:
|
2020-01-09 01:19:16 +03:00
|
|
|
slot.reset(new WebGLExtensionSRGB(this));
|
2014-11-14 07:03:50 +03:00
|
|
|
break;
|
2018-09-28 02:37:40 +03:00
|
|
|
case WebGLExtensionID::EXT_texture_compression_bptc:
|
2020-01-09 01:19:16 +03:00
|
|
|
slot.reset(new WebGLExtensionCompressedTextureBPTC(this));
|
2018-09-28 02:37:40 +03:00
|
|
|
break;
|
|
|
|
case WebGLExtensionID::EXT_texture_compression_rgtc:
|
2020-01-09 01:19:16 +03:00
|
|
|
slot.reset(new WebGLExtensionCompressedTextureRGTC(this));
|
2018-09-28 02:37:40 +03:00
|
|
|
break;
|
2015-01-08 03:28:05 +03:00
|
|
|
case WebGLExtensionID::EXT_texture_filter_anisotropic:
|
2020-01-09 01:19:16 +03:00
|
|
|
slot.reset(new WebGLExtensionTextureFilterAnisotropic(this));
|
2014-11-14 07:03:50 +03:00
|
|
|
break;
|
2015-01-08 03:28:05 +03:00
|
|
|
|
2017-01-31 05:58:52 +03:00
|
|
|
// MOZ_
|
2017-04-11 11:50:59 +03:00
|
|
|
case WebGLExtensionID::MOZ_debug:
|
2020-01-09 01:19:16 +03:00
|
|
|
slot.reset(new WebGLExtensionMOZDebug(this));
|
2017-01-31 05:58:52 +03:00
|
|
|
break;
|
|
|
|
|
2015-01-08 03:28:05 +03:00
|
|
|
// OES_
|
|
|
|
case WebGLExtensionID::OES_element_index_uint:
|
2020-01-09 01:19:16 +03:00
|
|
|
slot.reset(new WebGLExtensionElementIndexUint(this));
|
2014-11-14 07:03:50 +03:00
|
|
|
break;
|
2019-02-22 22:25:20 +03:00
|
|
|
case WebGLExtensionID::OES_fbo_render_mipmap:
|
2020-01-09 01:19:16 +03:00
|
|
|
slot.reset(new WebGLExtensionFBORenderMipmap(this));
|
2019-02-22 22:25:20 +03:00
|
|
|
break;
|
2015-01-08 03:28:05 +03:00
|
|
|
case WebGLExtensionID::OES_standard_derivatives:
|
2020-01-09 01:19:16 +03:00
|
|
|
slot.reset(new WebGLExtensionStandardDerivatives(this));
|
2014-11-14 07:03:50 +03:00
|
|
|
break;
|
|
|
|
case WebGLExtensionID::OES_texture_float:
|
2020-01-09 01:19:16 +03:00
|
|
|
slot.reset(new WebGLExtensionTextureFloat(this));
|
2014-11-14 07:03:50 +03:00
|
|
|
break;
|
|
|
|
case WebGLExtensionID::OES_texture_float_linear:
|
2020-01-09 01:19:16 +03:00
|
|
|
slot.reset(new WebGLExtensionTextureFloatLinear(this));
|
2014-11-14 07:03:50 +03:00
|
|
|
break;
|
|
|
|
case WebGLExtensionID::OES_texture_half_float:
|
2020-01-09 01:19:16 +03:00
|
|
|
slot.reset(new WebGLExtensionTextureHalfFloat(this));
|
2014-11-14 07:03:50 +03:00
|
|
|
break;
|
|
|
|
case WebGLExtensionID::OES_texture_half_float_linear:
|
2020-01-09 01:19:16 +03:00
|
|
|
slot.reset(new WebGLExtensionTextureHalfFloatLinear(this));
|
2014-11-14 07:03:50 +03:00
|
|
|
break;
|
2015-01-08 03:28:05 +03:00
|
|
|
case WebGLExtensionID::OES_vertex_array_object:
|
2020-01-09 01:19:16 +03:00
|
|
|
slot.reset(new WebGLExtensionVertexArray(this));
|
2015-01-08 03:28:05 +03:00
|
|
|
break;
|
|
|
|
|
2019-05-23 23:48:21 +03:00
|
|
|
// WEBGL_
|
|
|
|
case WebGLExtensionID::OVR_multiview2:
|
2020-01-09 01:19:16 +03:00
|
|
|
slot.reset(new WebGLExtensionMultiview(this));
|
2019-05-23 23:48:21 +03:00
|
|
|
break;
|
|
|
|
|
2015-01-08 03:28:05 +03:00
|
|
|
// WEBGL_
|
2014-11-14 07:03:50 +03:00
|
|
|
case WebGLExtensionID::WEBGL_color_buffer_float:
|
2020-01-09 01:19:16 +03:00
|
|
|
slot.reset(new WebGLExtensionColorBufferFloat(this));
|
2014-11-14 07:03:50 +03:00
|
|
|
break;
|
2016-11-23 05:59:35 +03:00
|
|
|
case WebGLExtensionID::WEBGL_compressed_texture_astc:
|
2020-01-09 01:19:16 +03:00
|
|
|
slot.reset(new WebGLExtensionCompressedTextureASTC(this));
|
2016-11-23 05:59:35 +03:00
|
|
|
break;
|
2016-11-11 03:37:03 +03:00
|
|
|
case WebGLExtensionID::WEBGL_compressed_texture_etc:
|
2020-01-09 01:19:16 +03:00
|
|
|
slot.reset(new WebGLExtensionCompressedTextureES3(this));
|
2016-01-08 05:12:22 +03:00
|
|
|
break;
|
2015-01-08 03:28:05 +03:00
|
|
|
case WebGLExtensionID::WEBGL_compressed_texture_etc1:
|
2020-01-09 01:19:16 +03:00
|
|
|
slot.reset(new WebGLExtensionCompressedTextureETC1(this));
|
2014-11-14 07:03:50 +03:00
|
|
|
break;
|
2015-01-08 03:28:05 +03:00
|
|
|
case WebGLExtensionID::WEBGL_compressed_texture_pvrtc:
|
2020-01-09 01:19:16 +03:00
|
|
|
slot.reset(new WebGLExtensionCompressedTexturePVRTC(this));
|
2014-11-14 07:03:50 +03:00
|
|
|
break;
|
2015-01-08 03:28:05 +03:00
|
|
|
case WebGLExtensionID::WEBGL_compressed_texture_s3tc:
|
2020-01-09 01:19:16 +03:00
|
|
|
slot.reset(new WebGLExtensionCompressedTextureS3TC(this));
|
2014-11-14 07:03:50 +03:00
|
|
|
break;
|
2017-05-30 18:21:33 +03:00
|
|
|
case WebGLExtensionID::WEBGL_compressed_texture_s3tc_srgb:
|
2020-01-09 01:19:16 +03:00
|
|
|
slot.reset(new WebGLExtensionCompressedTextureS3TC_SRGB(this));
|
2017-05-30 18:21:33 +03:00
|
|
|
break;
|
2015-01-08 03:28:05 +03:00
|
|
|
case WebGLExtensionID::WEBGL_debug_renderer_info:
|
2020-01-09 01:19:16 +03:00
|
|
|
slot.reset(new WebGLExtensionDebugRendererInfo(this));
|
2014-11-14 07:03:50 +03:00
|
|
|
break;
|
2015-01-08 03:28:05 +03:00
|
|
|
case WebGLExtensionID::WEBGL_debug_shaders:
|
2020-01-09 01:19:16 +03:00
|
|
|
slot.reset(new WebGLExtensionDebugShaders(this));
|
2014-11-14 07:03:50 +03:00
|
|
|
break;
|
2015-01-08 03:28:05 +03:00
|
|
|
case WebGLExtensionID::WEBGL_depth_texture:
|
2020-01-09 01:19:16 +03:00
|
|
|
slot.reset(new WebGLExtensionDepthTexture(this));
|
2014-11-14 07:03:50 +03:00
|
|
|
break;
|
2015-01-08 03:28:05 +03:00
|
|
|
case WebGLExtensionID::WEBGL_draw_buffers:
|
2020-01-09 01:19:16 +03:00
|
|
|
slot.reset(new WebGLExtensionDrawBuffers(this));
|
2015-01-08 03:28:05 +03:00
|
|
|
break;
|
2019-06-25 22:48:24 +03:00
|
|
|
case WebGLExtensionID::WEBGL_explicit_present:
|
2020-01-09 01:19:16 +03:00
|
|
|
slot.reset(new WebGLExtensionExplicitPresent(this));
|
2019-06-25 22:48:24 +03:00
|
|
|
break;
|
2015-01-08 03:28:05 +03:00
|
|
|
case WebGLExtensionID::WEBGL_lose_context:
|
2020-01-09 01:19:16 +03:00
|
|
|
slot.reset(new WebGLExtensionLoseContext(this));
|
2014-11-14 07:03:50 +03:00
|
|
|
break;
|
2015-01-08 03:28:05 +03:00
|
|
|
|
2019-02-05 06:34:49 +03:00
|
|
|
case WebGLExtensionID::Max:
|
|
|
|
MOZ_CRASH();
|
2013-08-27 01:12:53 +04:00
|
|
|
}
|
2020-01-09 01:19:16 +03:00
|
|
|
MOZ_ASSERT(slot);
|
|
|
|
const auto& obj = slot;
|
2013-08-27 01:12:53 +04:00
|
|
|
|
2020-01-09 01:19:16 +03:00
|
|
|
if (explicitly && !obj->IsExplicit()) {
|
|
|
|
obj->SetExplicit();
|
2018-11-30 13:46:48 +03:00
|
|
|
}
|
2020-01-09 01:19:14 +03:00
|
|
|
|
2020-01-09 01:19:16 +03:00
|
|
|
// Also enable implied extensions.
|
2020-01-09 01:19:14 +03:00
|
|
|
switch (ext) {
|
|
|
|
case WebGLExtensionID::EXT_color_buffer_float:
|
2020-01-09 01:19:16 +03:00
|
|
|
RequestExtension(WebGLExtensionID::EXT_float_blend, false);
|
|
|
|
break;
|
2020-01-09 01:19:14 +03:00
|
|
|
|
|
|
|
case WebGLExtensionID::OES_texture_float:
|
2020-01-09 01:19:16 +03:00
|
|
|
RequestExtension(WebGLExtensionID::EXT_float_blend, false);
|
|
|
|
RequestExtension(WebGLExtensionID::WEBGL_color_buffer_float, false);
|
|
|
|
break;
|
|
|
|
|
2020-01-09 01:19:14 +03:00
|
|
|
case WebGLExtensionID::OES_texture_half_float:
|
2020-01-09 01:19:16 +03:00
|
|
|
RequestExtension(WebGLExtensionID::EXT_color_buffer_half_float, false);
|
|
|
|
break;
|
2020-01-09 01:19:14 +03:00
|
|
|
|
|
|
|
case WebGLExtensionID::WEBGL_color_buffer_float:
|
2020-01-09 01:19:16 +03:00
|
|
|
RequestExtension(WebGLExtensionID::EXT_float_blend, false);
|
|
|
|
break;
|
|
|
|
|
2020-01-09 01:19:14 +03:00
|
|
|
default:
|
2020-01-09 01:19:16 +03:00
|
|
|
break;
|
2020-01-09 01:19:14 +03:00
|
|
|
}
|
2013-08-27 01:12:53 +04:00
|
|
|
}
|
|
|
|
|
2014-11-14 07:03:50 +03:00
|
|
|
} // namespace mozilla
|