mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-27 14:52:16 +00:00
Bug 1885032 - Support EXT_depth_clamp in webgl. r=gfx-reviewers,webidl,lsalzman,smaug
Differential Revision: https://phabricator.services.mozilla.com/D215713
This commit is contained in:
parent
c7188972f0
commit
19b0fabe6e
@ -1155,6 +1155,11 @@ DOMInterfaces = {
|
||||
'headerFile': 'ClientWebGLExtensions.h'
|
||||
},
|
||||
|
||||
'EXT_depth_clamp': {
|
||||
'nativeType': 'mozilla::ClientWebGLExtensionDepthClamp',
|
||||
'headerFile': 'ClientWebGLExtensions.h'
|
||||
},
|
||||
|
||||
'EXT_disjoint_timer_query': {
|
||||
'nativeType': 'mozilla::ClientWebGLExtensionDisjointTimerQuery',
|
||||
'headerFile': 'ClientWebGLExtensions.h'
|
||||
|
@ -939,6 +939,8 @@ bool ClientWebGLContext::CreateHostContext(const uvec2& requestedSize) {
|
||||
// Init state
|
||||
const auto& limits = Limits();
|
||||
auto& state = State();
|
||||
state.mIsEnabledMap = webgl::MakeIsEnabledMap(mIsWebGL2);
|
||||
|
||||
state.mDefaultTfo = new WebGLTransformFeedbackJS(*this);
|
||||
state.mDefaultVao = new WebGLVertexArrayJS(this);
|
||||
|
||||
@ -978,8 +980,6 @@ bool ClientWebGLContext::CreateHostContext(const uvec2& requestedSize) {
|
||||
.mCurrentQueryByTarget[LOCAL_GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN];
|
||||
}
|
||||
|
||||
state.mIsEnabledMap = Some(webgl::MakeIsEnabledMap(mIsWebGL2));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -1934,7 +1934,7 @@ void ClientWebGLContext::SetEnabledI(const GLenum cap, const Maybe<GLuint> i,
|
||||
const FuncScope funcScope(*this, "enable/disable");
|
||||
if (IsContextLost()) return;
|
||||
|
||||
auto& map = *mNotLost->state.mIsEnabledMap;
|
||||
auto& map = mNotLost->state.mIsEnabledMap;
|
||||
auto slot = MaybeFind(map, cap);
|
||||
if (i && cap != LOCAL_GL_BLEND) {
|
||||
slot = nullptr;
|
||||
@ -1955,7 +1955,7 @@ bool ClientWebGLContext::IsEnabled(const GLenum cap) const {
|
||||
const FuncScope funcScope(*this, "isEnabled");
|
||||
if (IsContextLost()) return false;
|
||||
|
||||
const auto& map = *mNotLost->state.mIsEnabledMap;
|
||||
const auto& map = mNotLost->state.mIsEnabledMap;
|
||||
const auto slot = MaybeFind(map, cap);
|
||||
if (!slot) {
|
||||
EnqueueError_ArgEnum("cap", cap);
|
||||
@ -2163,6 +2163,11 @@ void ClientWebGLContext::GetParameter(JSContext* cx, GLenum pname,
|
||||
retval.set(JS::NumberValue(UnderlyingValue(state.mProvokingVertex)));
|
||||
return;
|
||||
|
||||
case LOCAL_GL_DEPTH_CLAMP:
|
||||
if (!IsExtensionEnabled(WebGLExtensionID::EXT_depth_clamp)) break;
|
||||
retval.set(JS::BooleanValue(state.mIsEnabledMap[LOCAL_GL_DEPTH_CLAMP]));
|
||||
return;
|
||||
|
||||
// -
|
||||
// Array returns
|
||||
|
||||
@ -2318,7 +2323,7 @@ void ClientWebGLContext::GetParameter(JSContext* cx, GLenum pname,
|
||||
retval.set(JS::NumberValue(state.mPixelUnpackState.skipRows));
|
||||
return;
|
||||
} // switch pname
|
||||
} // if webgl2
|
||||
} // if webgl2
|
||||
|
||||
// -
|
||||
|
||||
|
@ -177,7 +177,7 @@ class ContextGenerationInfo final {
|
||||
|
||||
webgl::ProvokingVertex mProvokingVertex = webgl::ProvokingVertex::LastVertex;
|
||||
|
||||
mutable Maybe<std::unordered_map<GLenum, bool>> mIsEnabledMap;
|
||||
mutable std::unordered_map<GLenum, bool> mIsEnabledMap;
|
||||
};
|
||||
|
||||
// -
|
||||
|
@ -57,6 +57,21 @@ DEFINE_WEBGL_EXTENSION_GOOP(WEBGL_provoking_vertex,
|
||||
|
||||
// --------------
|
||||
|
||||
JSObject* ClientWebGLExtensionDepthClamp::WrapObject(
|
||||
JSContext* cx, JS::Handle<JSObject*> givenProto) {
|
||||
return dom::EXT_depth_clamp_Binding::Wrap(cx, this, givenProto);
|
||||
}
|
||||
|
||||
ClientWebGLExtensionDepthClamp::ClientWebGLExtensionDepthClamp(
|
||||
ClientWebGLContext& webgl)
|
||||
: ClientWebGLExtensionBase(webgl) {
|
||||
auto& state = webgl.State();
|
||||
// Add slot for new key:
|
||||
state.mIsEnabledMap[LOCAL_GL_DEPTH_CLAMP] = false;
|
||||
}
|
||||
|
||||
// --------------
|
||||
|
||||
JSObject* ClientWebGLExtensionDisjointTimerQuery::WrapObject(
|
||||
JSContext* cx, JS::Handle<JSObject*> givenProto) {
|
||||
return dom::EXT_disjoint_timer_query_Binding::Wrap(cx, this, givenProto);
|
||||
|
@ -105,6 +105,8 @@ class ClientWebGLExtensionDebugShaders : public ClientWebGLExtensionBase {
|
||||
}
|
||||
};
|
||||
|
||||
DECLARE_SIMPLE_WEBGL_EXTENSION(WebGLExtensionDepthClamp)
|
||||
|
||||
DECLARE_SIMPLE_WEBGL_EXTENSION(WebGLExtensionDepthTexture)
|
||||
|
||||
DECLARE_SIMPLE_WEBGL_EXTENSION(WebGLExtensionElementIndexUint)
|
||||
|
@ -697,6 +697,13 @@ void WebGLContext::FinishInit() {
|
||||
mScissorRect = {0, 0, size.width, size.height};
|
||||
mScissorRect.Apply(*gl);
|
||||
|
||||
{
|
||||
const auto& isEnabledMap = webgl::MakeIsEnabledMap(IsWebGL2());
|
||||
for (const auto& pair : isEnabledMap) {
|
||||
mIsEnabledMapKeys.insert(pair.first);
|
||||
}
|
||||
}
|
||||
|
||||
//////
|
||||
// Check everything
|
||||
|
||||
|
@ -207,6 +207,7 @@ class WebGLContext : public VRefCounted, public SupportsWeakPtr {
|
||||
friend class WebGLExtensionCompressedTextureRGTC;
|
||||
friend class WebGLExtensionCompressedTextureS3TC;
|
||||
friend class WebGLExtensionCompressedTextureS3TC_SRGB;
|
||||
friend class WebGLExtensionDepthClamp;
|
||||
friend class WebGLExtensionDepthTexture;
|
||||
friend class WebGLExtensionDisjointTimerQuery;
|
||||
friend class WebGLExtensionDrawBuffers;
|
||||
@ -1237,6 +1238,8 @@ class WebGLContext : public VRefCounted, public SupportsWeakPtr {
|
||||
std::bitset<webgl::kMaxDrawBuffers> mColorWriteMaskNonzero = -1;
|
||||
std::bitset<webgl::kMaxDrawBuffers> mBlendEnabled = 0;
|
||||
|
||||
std::unordered_set<GLenum> mIsEnabledMapKeys;
|
||||
|
||||
GLint mViewportX = 0;
|
||||
GLint mViewportY = 0;
|
||||
GLsizei mViewportWidth = 0;
|
||||
|
@ -26,6 +26,7 @@ const char* GetExtensionName(const WebGLExtensionID ext) {
|
||||
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_depth_clamp)
|
||||
WEBGL_EXTENSION_IDENTIFIER(EXT_disjoint_timer_query)
|
||||
WEBGL_EXTENSION_IDENTIFIER(EXT_float_blend)
|
||||
WEBGL_EXTENSION_IDENTIFIER(EXT_frag_depth)
|
||||
@ -137,6 +138,8 @@ RefPtr<ClientWebGLExtensionBase> ClientWebGLContext::GetExtension(
|
||||
return new ClientWebGLExtensionEXTColorBufferFloat(*this);
|
||||
case WebGLExtensionID::EXT_color_buffer_half_float:
|
||||
return new ClientWebGLExtensionColorBufferHalfFloat(*this);
|
||||
case WebGLExtensionID::EXT_depth_clamp:
|
||||
return new ClientWebGLExtensionDepthClamp(*this);
|
||||
case WebGLExtensionID::EXT_disjoint_timer_query:
|
||||
return new ClientWebGLExtensionDisjointTimerQuery(*this);
|
||||
case WebGLExtensionID::EXT_float_blend:
|
||||
@ -258,6 +261,9 @@ bool WebGLContext::IsExtensionSupported(WebGLExtensionID ext) const {
|
||||
case WebGLExtensionID::EXT_color_buffer_half_float:
|
||||
return WebGLExtensionColorBufferHalfFloat::IsSupported(this);
|
||||
|
||||
case WebGLExtensionID::EXT_depth_clamp:
|
||||
return gl->IsSupported(gl::GLFeature::depth_clamp);
|
||||
|
||||
case WebGLExtensionID::EXT_disjoint_timer_query:
|
||||
return WebGLExtensionDisjointTimerQuery::IsSupported(this);
|
||||
|
||||
@ -414,6 +420,9 @@ void WebGLContext::RequestExtension(const WebGLExtensionID ext,
|
||||
case WebGLExtensionID::EXT_color_buffer_half_float:
|
||||
slot.reset(new WebGLExtensionColorBufferHalfFloat(this));
|
||||
break;
|
||||
case WebGLExtensionID::EXT_depth_clamp:
|
||||
slot.reset(new WebGLExtensionDepthClamp(this));
|
||||
break;
|
||||
case WebGLExtensionID::EXT_disjoint_timer_query:
|
||||
slot.reset(new WebGLExtensionDisjointTimerQuery(this));
|
||||
break;
|
||||
|
@ -27,13 +27,7 @@ void WebGLContext::SetEnabled(const GLenum cap, const Maybe<GLuint> i,
|
||||
const FuncScope funcScope(*this, "enable(i)/disable(i)");
|
||||
if (IsContextLost()) return;
|
||||
|
||||
static const auto webgl1Map = webgl::MakeIsEnabledMap(false);
|
||||
static const auto webgl2Map = webgl::MakeIsEnabledMap(true);
|
||||
const auto* map = &webgl2Map;
|
||||
if (!IsWebGL2()) {
|
||||
map = &webgl1Map;
|
||||
}
|
||||
if (!MaybeFind(*map, cap)) {
|
||||
if (!mIsEnabledMapKeys.count(cap)) {
|
||||
MOZ_ASSERT(false, "Bad cap.");
|
||||
return;
|
||||
}
|
||||
|
@ -433,6 +433,13 @@ bool WebGLExtensionCompressedTextureS3TC_SRGB::IsSupported(
|
||||
|
||||
// -
|
||||
|
||||
WebGLExtensionDepthClamp::WebGLExtensionDepthClamp(WebGLContext* const webgl)
|
||||
: WebGLExtensionBase(webgl) {
|
||||
webgl->mIsEnabledMapKeys.insert(LOCAL_GL_DEPTH_CLAMP);
|
||||
}
|
||||
|
||||
// -
|
||||
|
||||
WebGLExtensionDepthTexture::WebGLExtensionDepthTexture(
|
||||
WebGLContext* const webgl)
|
||||
: WebGLExtensionBase(webgl) {
|
||||
|
@ -118,6 +118,11 @@ class WebGLExtensionDebugShaders : public WebGLExtensionBase {
|
||||
: WebGLExtensionBase(webgl) {}
|
||||
};
|
||||
|
||||
class WebGLExtensionDepthClamp : public WebGLExtensionBase {
|
||||
public:
|
||||
explicit WebGLExtensionDepthClamp(WebGLContext* webgl);
|
||||
};
|
||||
|
||||
class WebGLExtensionDepthTexture : public WebGLExtensionBase {
|
||||
public:
|
||||
explicit WebGLExtensionDepthTexture(WebGLContext*);
|
||||
|
@ -215,6 +215,7 @@ enum class WebGLExtensionID : uint8_t {
|
||||
EXT_blend_minmax,
|
||||
EXT_color_buffer_float,
|
||||
EXT_color_buffer_half_float,
|
||||
EXT_depth_clamp,
|
||||
EXT_disjoint_timer_query,
|
||||
EXT_float_blend,
|
||||
EXT_frag_depth,
|
||||
|
@ -0,0 +1,18 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset='utf-8'/>
|
||||
<script src='/tests/SimpleTest/SimpleTest.js'></script>
|
||||
<link rel='stylesheet' href='/tests/SimpleTest/test.css'>
|
||||
<script src='ensure-ext.js'></script>
|
||||
</head>
|
||||
<body>
|
||||
<script>
|
||||
|
||||
'use strict';
|
||||
EnsureExtFor('webgl', 'EXT_depth_clamp');
|
||||
EnsureExtFor('webgl2', 'EXT_depth_clamp');
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -40,6 +40,7 @@ var defaultExts = [
|
||||
// Community Approved
|
||||
['EXT_color_buffer_float' , [FORBID , ENSURE ]],
|
||||
['EXT_color_buffer_half_float' , [MACHINE_SPECIFIC, FORBID ]],
|
||||
['EXT_depth_clamp' , [MACHINE_SPECIFIC, MACHINE_SPECIFIC]],
|
||||
['EXT_disjoint_timer_query' , [MACHINE_SPECIFIC, MACHINE_SPECIFIC]],
|
||||
['EXT_float_blend' , [MACHINE_SPECIFIC, MACHINE_SPECIFIC]],
|
||||
['EXT_sRGB' , [MACHINE_SPECIFIC, FORBID ]],
|
||||
|
@ -18,6 +18,12 @@ support-files = [
|
||||
|
||||
["ensure-exts/test_EXT_color_buffer_half_float.html"]
|
||||
|
||||
["ensure-exts/test_EXT_depth_clamp.html"]
|
||||
fail-if = [
|
||||
"os == 'android'",
|
||||
"os == 'win'",
|
||||
]
|
||||
|
||||
["ensure-exts/test_EXT_disjoint_timer_query.html"]
|
||||
fail-if = ["true"]
|
||||
|
||||
|
@ -1229,6 +1229,11 @@ interface WEBGL_provoking_vertex {
|
||||
undefined provokingVertexWEBGL(GLenum provokeMode);
|
||||
};
|
||||
|
||||
[Exposed=(Window,Worker), LegacyNoInterfaceObject]
|
||||
interface EXT_depth_clamp {
|
||||
const GLenum DEPTH_CLAMP_EXT = 0x864F;
|
||||
};
|
||||
|
||||
// https://immersive-web.github.io/webxr/#dom-webglcontextattributes-xrcompatible
|
||||
partial dictionary WebGLContextAttributes {
|
||||
[Pref="dom.vr.webxr.enabled"]
|
||||
|
@ -102,6 +102,7 @@ static const char* const sExtensionNames[] = {
|
||||
"GL_ARB_color_buffer_float",
|
||||
"GL_ARB_compatibility",
|
||||
"GL_ARB_copy_buffer",
|
||||
"GL_ARB_depth_clamp",
|
||||
"GL_ARB_depth_texture",
|
||||
"GL_ARB_draw_buffers",
|
||||
"GL_ARB_draw_instanced",
|
||||
@ -142,6 +143,7 @@ static const char* const sExtensionNames[] = {
|
||||
"GL_EXT_color_buffer_float",
|
||||
"GL_EXT_color_buffer_half_float",
|
||||
"GL_EXT_copy_texture",
|
||||
"GL_EXT_depth_clamp",
|
||||
"GL_EXT_disjoint_timer_query",
|
||||
"GL_EXT_draw_buffers",
|
||||
"GL_EXT_draw_buffers2",
|
||||
|
@ -83,6 +83,7 @@ enum class GLFeature {
|
||||
blend_minmax,
|
||||
clear_buffers,
|
||||
copy_buffer,
|
||||
depth_clamp,
|
||||
depth_texture,
|
||||
draw_buffers,
|
||||
draw_buffers_indexed,
|
||||
@ -380,6 +381,7 @@ class GLContext : public GenericAtomicRefCounted, public SupportsWeakPtr {
|
||||
ARB_color_buffer_float,
|
||||
ARB_compatibility,
|
||||
ARB_copy_buffer,
|
||||
ARB_depth_clamp,
|
||||
ARB_depth_texture,
|
||||
ARB_draw_buffers,
|
||||
ARB_draw_instanced,
|
||||
@ -420,6 +422,7 @@ class GLContext : public GenericAtomicRefCounted, public SupportsWeakPtr {
|
||||
EXT_color_buffer_float,
|
||||
EXT_color_buffer_half_float,
|
||||
EXT_copy_texture,
|
||||
EXT_depth_clamp,
|
||||
EXT_disjoint_timer_query,
|
||||
EXT_draw_buffers,
|
||||
EXT_draw_buffers2,
|
||||
|
@ -90,6 +90,12 @@ static const FeatureInfo sFeatureInfoArr[] = {
|
||||
GLESVersion::ES3,
|
||||
GLContext::ARB_copy_buffer,
|
||||
{GLContext::Extensions_End}},
|
||||
{"depth_clamp",
|
||||
GLVersion::GL3_2,
|
||||
GLESVersion::NONE,
|
||||
GLContext::Extension_None,
|
||||
{GLContext::ARB_depth_clamp, GLContext::EXT_depth_clamp,
|
||||
GLContext::Extensions_End}},
|
||||
{"depth_texture",
|
||||
GLVersion::GL2,
|
||||
GLESVersion::ES3,
|
||||
|
Loading…
Reference in New Issue
Block a user