2018-11-30 22:52:05 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-08-14 05:17:55 +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 "WebGLExtensions.h"
|
2014-11-14 07:03:50 +03:00
|
|
|
|
2016-07-22 09:25:41 +03:00
|
|
|
#include "GLContext.h"
|
2012-10-04 01:13:05 +04:00
|
|
|
#include "mozilla/dom/WebGLRenderingContextBinding.h"
|
2014-11-14 07:03:50 +03:00
|
|
|
#include "WebGLContext.h"
|
2012-08-14 05:17:55 +04:00
|
|
|
|
2014-11-14 07:03:50 +03:00
|
|
|
namespace mozilla {
|
2012-08-14 05:17:55 +04:00
|
|
|
|
2019-04-22 23:57:57 +03:00
|
|
|
WebGLExtensionDepthTexture::WebGLExtensionDepthTexture(
|
|
|
|
WebGLContext* const webgl)
|
2014-11-14 07:03:50 +03:00
|
|
|
: WebGLExtensionBase(webgl) {
|
2015-11-25 07:15:29 +03:00
|
|
|
auto& fua = webgl->mFormatUsage;
|
|
|
|
|
|
|
|
const auto fnAdd = [&fua](webgl::EffectiveFormat effFormat,
|
|
|
|
GLenum unpackFormat, GLenum unpackType) {
|
|
|
|
auto usage = fua->EditUsage(effFormat);
|
2019-04-22 23:57:57 +03:00
|
|
|
MOZ_ASSERT(usage->isFilterable);
|
|
|
|
MOZ_ASSERT(usage->IsRenderable());
|
2015-11-25 07:15:29 +03:00
|
|
|
|
|
|
|
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);
|
2012-08-14 05:17:55 +04:00
|
|
|
}
|
|
|
|
|
2019-02-05 06:34:49 +03:00
|
|
|
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;
|
|
|
|
|
|
|
|
return gl->IsSupported(gl::GLFeature::depth_texture) ||
|
|
|
|
gl->IsExtensionSupported(gl::GLContext::ANGLE_depth_texture);
|
|
|
|
}
|
|
|
|
|
2014-11-14 07:03:50 +03:00
|
|
|
} // namespace mozilla
|