зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1325113 - Implement support for WEBGL_compressed_texture_s3tc_srgb - r=jgilbert,qdot
MozReview-Commit-ID: mI4dlB2lK
This commit is contained in:
Родитель
9f268f0537
Коммит
901459a071
|
@ -1159,6 +1159,11 @@ DOMInterfaces = {
|
|||
'headerFile': 'WebGLExtensions.h'
|
||||
},
|
||||
|
||||
'WEBGL_compressed_texture_s3tc_srgb': {
|
||||
'nativeType': 'mozilla::WebGLExtensionCompressedTextureS3TC_SRGB',
|
||||
'headerFile': 'WebGLExtensions.h'
|
||||
},
|
||||
|
||||
'WEBGL_depth_texture': {
|
||||
'nativeType': 'mozilla::WebGLExtensionDepthTexture',
|
||||
'headerFile': 'WebGLExtensions.h'
|
||||
|
|
|
@ -310,6 +310,7 @@ class WebGLContext
|
|||
friend class WebGLExtensionCompressedTextureETC1;
|
||||
friend class WebGLExtensionCompressedTexturePVRTC;
|
||||
friend class WebGLExtensionCompressedTextureS3TC;
|
||||
friend class WebGLExtensionCompressedTextureS3TC_SRGB;
|
||||
friend class WebGLExtensionDepthTexture;
|
||||
friend class WebGLExtensionDisjointTimerQuery;
|
||||
friend class WebGLExtensionDrawBuffers;
|
||||
|
|
|
@ -55,6 +55,7 @@ WebGLContext::GetExtensionString(WebGLExtensionID ext)
|
|||
WEBGL_EXTENSION_IDENTIFIER(WEBGL_compressed_texture_etc1)
|
||||
WEBGL_EXTENSION_IDENTIFIER(WEBGL_compressed_texture_pvrtc)
|
||||
WEBGL_EXTENSION_IDENTIFIER(WEBGL_compressed_texture_s3tc)
|
||||
WEBGL_EXTENSION_IDENTIFIER(WEBGL_compressed_texture_s3tc_srgb)
|
||||
WEBGL_EXTENSION_IDENTIFIER(WEBGL_debug_renderer_info)
|
||||
WEBGL_EXTENSION_IDENTIFIER(WEBGL_debug_shaders)
|
||||
WEBGL_EXTENSION_IDENTIFIER(WEBGL_depth_texture)
|
||||
|
@ -139,13 +140,10 @@ WebGLContext::IsExtensionSupported(WebGLExtensionID ext) const
|
|||
case WebGLExtensionID::WEBGL_compressed_texture_pvrtc:
|
||||
return gl->IsExtensionSupported(gl::GLContext::IMG_texture_compression_pvrtc);
|
||||
case WebGLExtensionID::WEBGL_compressed_texture_s3tc:
|
||||
if (gl->IsExtensionSupported(gl::GLContext::EXT_texture_compression_s3tc))
|
||||
return true;
|
||||
|
||||
return gl->IsExtensionSupported(gl::GLContext::EXT_texture_compression_dxt1) &&
|
||||
gl->IsExtensionSupported(gl::GLContext::ANGLE_texture_compression_dxt3) &&
|
||||
gl->IsExtensionSupported(gl::GLContext::ANGLE_texture_compression_dxt5);
|
||||
|
||||
return WebGLExtensionCompressedTextureS3TC::IsSupported(this);
|
||||
case WebGLExtensionID::WEBGL_compressed_texture_s3tc_srgb:
|
||||
return WebGLExtensionCompressedTextureS3TC::IsSupported(this) &&
|
||||
gl->IsExtensionSupported(gl::GLContext::EXT_texture_sRGB);
|
||||
case WebGLExtensionID::WEBGL_debug_renderer_info:
|
||||
return Preferences::GetBool("webgl.enable-debug-renderer-info", false);
|
||||
|
||||
|
@ -430,6 +428,9 @@ WebGLContext::EnableExtension(WebGLExtensionID ext)
|
|||
case WebGLExtensionID::WEBGL_compressed_texture_s3tc:
|
||||
obj = new WebGLExtensionCompressedTextureS3TC(this);
|
||||
break;
|
||||
case WebGLExtensionID::WEBGL_compressed_texture_s3tc_srgb:
|
||||
obj = new WebGLExtensionCompressedTextureS3TC_SRGB(this);
|
||||
break;
|
||||
case WebGLExtensionID::WEBGL_debug_renderer_info:
|
||||
obj = new WebGLExtensionDebugRendererInfo(this);
|
||||
break;
|
||||
|
|
|
@ -640,6 +640,10 @@ IsCompressedTextureFormat(GLenum format)
|
|||
case LOCAL_GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
|
||||
case LOCAL_GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
|
||||
case LOCAL_GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
|
||||
case LOCAL_GL_COMPRESSED_SRGB_S3TC_DXT1_EXT:
|
||||
case LOCAL_GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT:
|
||||
case LOCAL_GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT:
|
||||
case LOCAL_GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT:
|
||||
case LOCAL_GL_ATC_RGB:
|
||||
case LOCAL_GL_ATC_RGBA_EXPLICIT_ALPHA:
|
||||
case LOCAL_GL_ATC_RGBA_INTERPOLATED_ALPHA:
|
||||
|
|
|
@ -42,6 +42,18 @@ WebGLExtensionCompressedTextureS3TC::~WebGLExtensionCompressedTextureS3TC()
|
|||
{
|
||||
}
|
||||
|
||||
bool
|
||||
WebGLExtensionCompressedTextureS3TC::IsSupported(const WebGLContext* webgl)
|
||||
{
|
||||
gl::GLContext* gl = webgl->GL();
|
||||
if (gl->IsExtensionSupported(gl::GLContext::EXT_texture_compression_s3tc))
|
||||
return true;
|
||||
|
||||
return gl->IsExtensionSupported(gl::GLContext::EXT_texture_compression_dxt1) &&
|
||||
gl->IsExtensionSupported(gl::GLContext::ANGLE_texture_compression_dxt3) &&
|
||||
gl->IsExtensionSupported(gl::GLContext::ANGLE_texture_compression_dxt5);
|
||||
}
|
||||
|
||||
IMPL_WEBGL_EXTENSION_GOOP(WebGLExtensionCompressedTextureS3TC, WEBGL_compressed_texture_s3tc)
|
||||
|
||||
} // namespace mozilla
|
||||
|
|
|
@ -0,0 +1,47 @@
|
|||
/* 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/WebGLRenderingContextBinding.h"
|
||||
#include "WebGLContext.h"
|
||||
|
||||
#ifdef FOO
|
||||
#error FOO is already defined! We use FOO() macros to keep things succinct in this file.
|
||||
#endif
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
WebGLExtensionCompressedTextureS3TC_SRGB::WebGLExtensionCompressedTextureS3TC_SRGB(WebGLContext* webgl)
|
||||
: WebGLExtensionBase(webgl)
|
||||
{
|
||||
RefPtr<WebGLContext> webgl_ = webgl; // Bug 1201275
|
||||
const auto fnAdd = [&webgl_](GLenum sizedFormat, webgl::EffectiveFormat effFormat) {
|
||||
auto& fua = webgl_->mFormatUsage;
|
||||
|
||||
auto usage = fua->EditUsage(effFormat);
|
||||
usage->isFilterable = true;
|
||||
fua->AllowSizedTexFormat(sizedFormat, usage);
|
||||
|
||||
webgl_->mCompressedTextureFormats.AppendElement(sizedFormat);
|
||||
};
|
||||
|
||||
#define FOO(x) LOCAL_GL_ ## x, webgl::EffectiveFormat::x
|
||||
|
||||
fnAdd(FOO(COMPRESSED_SRGB_S3TC_DXT1_EXT));
|
||||
fnAdd(FOO(COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT));
|
||||
fnAdd(FOO(COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT));
|
||||
fnAdd(FOO(COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT));
|
||||
|
||||
#undef FOO
|
||||
}
|
||||
|
||||
WebGLExtensionCompressedTextureS3TC_SRGB::~WebGLExtensionCompressedTextureS3TC_SRGB()
|
||||
{
|
||||
}
|
||||
|
||||
IMPL_WEBGL_EXTENSION_GOOP(WebGLExtensionCompressedTextureS3TC_SRGB, WEBGL_compressed_texture_s3tc_srgb)
|
||||
|
||||
} // namespace mozilla
|
|
@ -126,6 +126,18 @@ public:
|
|||
explicit WebGLExtensionCompressedTextureS3TC(WebGLContext*);
|
||||
virtual ~WebGLExtensionCompressedTextureS3TC();
|
||||
|
||||
static bool IsSupported(const WebGLContext*);
|
||||
|
||||
DECL_WEBGL_EXTENSION_GOOP
|
||||
};
|
||||
|
||||
class WebGLExtensionCompressedTextureS3TC_SRGB
|
||||
: public WebGLExtensionBase
|
||||
{
|
||||
public:
|
||||
explicit WebGLExtensionCompressedTextureS3TC_SRGB(WebGLContext*);
|
||||
virtual ~WebGLExtensionCompressedTextureS3TC_SRGB();
|
||||
|
||||
DECL_WEBGL_EXTENSION_GOOP
|
||||
};
|
||||
|
||||
|
|
|
@ -113,6 +113,12 @@ InitCompressedFormatInfo()
|
|||
AddCompressedFormatInfo(EffectiveFormat::COMPRESSED_RGBA_S3TC_DXT3_EXT, 128, 4, 4, CompressionFamily::S3TC);
|
||||
AddCompressedFormatInfo(EffectiveFormat::COMPRESSED_RGBA_S3TC_DXT5_EXT, 128, 4, 4, CompressionFamily::S3TC);
|
||||
|
||||
// EXT_texture_compression_s3tc_srgb
|
||||
AddCompressedFormatInfo(EffectiveFormat::COMPRESSED_SRGB_S3TC_DXT1_EXT , 64, 4, 4, CompressionFamily::S3TC);
|
||||
AddCompressedFormatInfo(EffectiveFormat::COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT, 64, 4, 4, CompressionFamily::S3TC);
|
||||
AddCompressedFormatInfo(EffectiveFormat::COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT, 128, 4, 4, CompressionFamily::S3TC);
|
||||
AddCompressedFormatInfo(EffectiveFormat::COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT, 128, 4, 4, CompressionFamily::S3TC);
|
||||
|
||||
// KHR_texture_compression_astc_ldr
|
||||
AddCompressedFormatInfo(EffectiveFormat::COMPRESSED_RGBA_ASTC_4x4_KHR , 128, 4, 4, CompressionFamily::ASTC);
|
||||
AddCompressedFormatInfo(EffectiveFormat::COMPRESSED_RGBA_ASTC_5x4_KHR , 128, 5, 4, CompressionFamily::ASTC);
|
||||
|
@ -323,6 +329,12 @@ InitFormatInfo()
|
|||
AddFormatInfo(FOO(COMPRESSED_RGBA_S3TC_DXT3_EXT), 0, 1,1,1,1, 0,0, UnsizedFormat::RGBA, false, ComponentType::NormUInt);
|
||||
AddFormatInfo(FOO(COMPRESSED_RGBA_S3TC_DXT5_EXT), 0, 1,1,1,1, 0,0, UnsizedFormat::RGBA, false, ComponentType::NormUInt);
|
||||
|
||||
// EXT_texture_compression_s3tc_srgb
|
||||
AddFormatInfo(FOO(COMPRESSED_SRGB_S3TC_DXT1_EXT ), 0, 1,1,1,0, 0,0, UnsizedFormat::RGB , true, ComponentType::NormUInt);
|
||||
AddFormatInfo(FOO(COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT), 0, 1,1,1,1, 0,0, UnsizedFormat::RGBA, true, ComponentType::NormUInt);
|
||||
AddFormatInfo(FOO(COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT), 0, 1,1,1,1, 0,0, UnsizedFormat::RGBA, true, ComponentType::NormUInt);
|
||||
AddFormatInfo(FOO(COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT), 0, 1,1,1,1, 0,0, UnsizedFormat::RGBA, true, ComponentType::NormUInt);
|
||||
|
||||
// KHR_texture_compression_astc_ldr
|
||||
AddFormatInfo(FOO(COMPRESSED_RGBA_ASTC_4x4_KHR ), 0, 1,1,1,1, 0,0, UnsizedFormat::RGBA, false, ComponentType::NormUInt);
|
||||
AddFormatInfo(FOO(COMPRESSED_RGBA_ASTC_5x4_KHR ), 0, 1,1,1,1, 0,0, UnsizedFormat::RGBA, false, ComponentType::NormUInt);
|
||||
|
|
|
@ -119,6 +119,12 @@ enum class EffectiveFormat : EffectiveFormatValueT {
|
|||
COMPRESSED_RGBA_S3TC_DXT3_EXT,
|
||||
COMPRESSED_RGBA_S3TC_DXT5_EXT,
|
||||
|
||||
// EXT_texture_sRGB
|
||||
COMPRESSED_SRGB_S3TC_DXT1_EXT,
|
||||
COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT,
|
||||
COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT,
|
||||
COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT,
|
||||
|
||||
// KHR_texture_compression_astc_ldr
|
||||
COMPRESSED_RGBA_ASTC_4x4_KHR,
|
||||
COMPRESSED_RGBA_ASTC_5x4_KHR,
|
||||
|
|
|
@ -347,6 +347,10 @@ STRONG_GLENUM_BEGIN(TexInternalFormat)
|
|||
STRONG_GLENUM_VALUE(COMPRESSED_RGBA_S3TC_DXT1_EXT),
|
||||
STRONG_GLENUM_VALUE(COMPRESSED_RGBA_S3TC_DXT3_EXT),
|
||||
STRONG_GLENUM_VALUE(COMPRESSED_RGBA_S3TC_DXT5_EXT),
|
||||
STRONG_GLENUM_VALUE(COMPRESSED_SRGB_S3TC_DXT1_EXT),
|
||||
STRONG_GLENUM_VALUE(COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT),
|
||||
STRONG_GLENUM_VALUE(COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT),
|
||||
STRONG_GLENUM_VALUE(COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT),
|
||||
STRONG_GLENUM_VALUE(DEPTH_STENCIL),
|
||||
STRONG_GLENUM_VALUE(ATC_RGBA_INTERPOLATED_ALPHA),
|
||||
STRONG_GLENUM_VALUE(RGBA32F),
|
||||
|
|
|
@ -164,6 +164,7 @@ enum class WebGLExtensionID : uint8_t {
|
|||
WEBGL_compressed_texture_etc1,
|
||||
WEBGL_compressed_texture_pvrtc,
|
||||
WEBGL_compressed_texture_s3tc,
|
||||
WEBGL_compressed_texture_s3tc_srgb,
|
||||
WEBGL_debug_renderer_info,
|
||||
WEBGL_debug_shaders,
|
||||
WEBGL_depth_texture,
|
||||
|
|
|
@ -135,6 +135,7 @@ UNIFIED_SOURCES += [
|
|||
'WebGLExtensionCompressedTextureETC1.cpp',
|
||||
'WebGLExtensionCompressedTexturePVRTC.cpp',
|
||||
'WebGLExtensionCompressedTextureS3TC.cpp',
|
||||
'WebGLExtensionCompressedTextureS3TC_SRGB.cpp',
|
||||
'WebGLExtensionDebugRendererInfo.cpp',
|
||||
'WebGLExtensionDebugShaders.cpp',
|
||||
'WebGLExtensionDepthTexture.cpp',
|
||||
|
|
|
@ -819,6 +819,15 @@ interface WEBGL_compressed_texture_s3tc
|
|||
const GLenum COMPRESSED_RGBA_S3TC_DXT5_EXT = 0x83F3;
|
||||
};
|
||||
|
||||
[NoInterfaceObject]
|
||||
interface WEBGL_compressed_texture_s3tc_srgb {
|
||||
/* Compressed Texture Formats */
|
||||
const GLenum COMPRESSED_SRGB_S3TC_DXT1_EXT = 0x8C4C;
|
||||
const GLenum COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT = 0x8C4D;
|
||||
const GLenum COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT = 0x8C4E;
|
||||
const GLenum COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT = 0x8C4F;
|
||||
};
|
||||
|
||||
[NoInterfaceObject]
|
||||
interface WEBGL_compressed_texture_astc {
|
||||
/* Compressed Texture Format */
|
||||
|
|
Загрузка…
Ссылка в новой задаче