Bug 1545890 - Depth textures are filterable like RED textures. r=lsalzman
authorJeff Gilbert <jgilbert@mozilla.com>
Mon, 22 Apr 2019 20:57:57 +0000
changeset 470422 8b552b0169ac49cab72e9aebeb15a2b87d35055b
parent 470421 8ce092764f601dc1d02c2f7a779ff405796b1b03
child 470423 6fea732af7666d74602f9ed66b71c742648f5389
push id35905
push userdvarga@mozilla.com
push dateTue, 23 Apr 2019 09:53:27 +0000
treeherdermozilla-central@831918f009f6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerslsalzman
bugs1545890
milestone68.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1545890 - Depth textures are filterable like RED textures. r=lsalzman Differential Revision: https://phabricator.services.mozilla.com/D28267
dom/canvas/WebGLExtensionDepthTexture.cpp
dom/canvas/WebGLFormats.cpp
--- a/dom/canvas/WebGLExtensionDepthTexture.cpp
+++ b/dom/canvas/WebGLExtensionDepthTexture.cpp
@@ -6,45 +6,43 @@
 #include "WebGLExtensions.h"
 
 #include "GLContext.h"
 #include "mozilla/dom/WebGLRenderingContextBinding.h"
 #include "WebGLContext.h"
 
 namespace mozilla {
 
-WebGLExtensionDepthTexture::WebGLExtensionDepthTexture(WebGLContext* webgl)
+WebGLExtensionDepthTexture::WebGLExtensionDepthTexture(
+    WebGLContext* const webgl)
     : WebGLExtensionBase(webgl) {
   auto& fua = webgl->mFormatUsage;
 
   const auto fnAdd = [&fua](webgl::EffectiveFormat effFormat,
                             GLenum unpackFormat, GLenum unpackType) {
     auto usage = fua->EditUsage(effFormat);
-    usage->isFilterable = true;
-    usage->SetRenderable();
+    MOZ_ASSERT(usage->isFilterable);
+    MOZ_ASSERT(usage->IsRenderable());
 
     const webgl::PackingInfo pi = {unpackFormat, unpackType};
     const webgl::DriverUnpackInfo dui = {unpackFormat, unpackFormat,
                                          unpackType};
     fua->AddTexUnpack(usage, pi, dui);
-
     fua->AllowUnsizedTexFormat(pi, usage);
   };
 
   fnAdd(webgl::EffectiveFormat::DEPTH_COMPONENT16, LOCAL_GL_DEPTH_COMPONENT,
         LOCAL_GL_UNSIGNED_SHORT);
-
   fnAdd(webgl::EffectiveFormat::DEPTH_COMPONENT24, LOCAL_GL_DEPTH_COMPONENT,
         LOCAL_GL_UNSIGNED_INT);
-
   fnAdd(webgl::EffectiveFormat::DEPTH24_STENCIL8, LOCAL_GL_DEPTH_STENCIL,
         LOCAL_GL_UNSIGNED_INT_24_8);
 }
 
-WebGLExtensionDepthTexture::~WebGLExtensionDepthTexture() {}
+WebGLExtensionDepthTexture::~WebGLExtensionDepthTexture() = default;
 
 bool WebGLExtensionDepthTexture::IsSupported(const WebGLContext* const webgl) {
   if (webgl->IsWebGL2()) return false;
 
   // WEBGL_depth_texture supports DEPTH_STENCIL textures
   const auto& gl = webgl->gl;
   if (!gl->IsSupported(gl::GLFeature::packed_depth_stencil)) return false;
 
--- a/dom/canvas/WebGLFormats.cpp
+++ b/dom/canvas/WebGLFormats.cpp
@@ -813,21 +813,22 @@ UniquePtr<FormatUsageAuthority> FormatUs
   // RGB8 is not guaranteed to be renderable, but we should allow it for
   // web-compat. Min-capability mode should mark this as non-renderable.
   fnSet(EffectiveFormat::RGB8, true, true);
 
   fnSet(EffectiveFormat::Luminance8Alpha8, false, true);
   fnSet(EffectiveFormat::Luminance8, false, true);
   fnSet(EffectiveFormat::Alpha8, false, true);
 
-  fnSet(EffectiveFormat::DEPTH_COMPONENT16, true, false);
+  fnSet(EffectiveFormat::DEPTH_COMPONENT16, true, true);
+  fnSet(EffectiveFormat::DEPTH_COMPONENT24, true, true); // Requires WEBGL_depth_texture.
   fnSet(EffectiveFormat::STENCIL_INDEX8, true, false);
 
   // Added in WebGL 1.0 spec:
-  fnSet(EffectiveFormat::DEPTH24_STENCIL8, true, false);
+  fnSet(EffectiveFormat::DEPTH24_STENCIL8, true, true);
 
   ////////////////////////////////////
   // RB formats
 
 #define FOO(x) \
   ptr->AllowRBFormat(LOCAL_GL_##x, ptr->GetUsage(EffectiveFormat::x))
 
   FOO(RGBA4);
@@ -1043,21 +1044,24 @@ UniquePtr<FormatUsageAuthority> FormatUs
   fnAllowES3TexFormat(FOO(RGBA8I), true, false);
   fnAllowES3TexFormat(FOO(RGBA8UI), true, false);
   fnAllowES3TexFormat(FOO(RGBA16I), true, false);
   fnAllowES3TexFormat(FOO(RGBA16UI), true, false);
   fnAllowES3TexFormat(FOO(RGBA32I), true, false);
   fnAllowES3TexFormat(FOO(RGBA32UI), true, false);
 
   // GLES 3.0.4, p133, table 3.14
-  fnAllowES3TexFormat(FOO(DEPTH_COMPONENT16), true, false);
-  fnAllowES3TexFormat(FOO(DEPTH_COMPONENT24), true, false);
-  fnAllowES3TexFormat(FOO(DEPTH_COMPONENT32F), true, false);
-  fnAllowES3TexFormat(FOO(DEPTH24_STENCIL8), true, false);
-  fnAllowES3TexFormat(FOO(DEPTH32F_STENCIL8), true, false);
+  // p151:
+  //   Depth textures and the depth components of depth/stencil textures can be
+  //   treated as `RED` textures during texture filtering and application.
+  fnAllowES3TexFormat(FOO(DEPTH_COMPONENT16), true, true);
+  fnAllowES3TexFormat(FOO(DEPTH_COMPONENT24), true, true);
+  fnAllowES3TexFormat(FOO(DEPTH_COMPONENT32F), true, true);
+  fnAllowES3TexFormat(FOO(DEPTH24_STENCIL8), true, true);
+  fnAllowES3TexFormat(FOO(DEPTH32F_STENCIL8), true, true);
 
 #undef FOO
 
   // GLES 3.0.4, p206, "Required Renderbuffer Formats":
   // "Implementations are also required to support STENCIL_INDEX8. Requesting
   // this internal format for a renderbuffer will allocate at least 8 stencil
   // bit planes."