Skip to content

Commit

Permalink
Backed out changeset a4a346ecefd7 (bug 1726265) for causing failures …
Browse files Browse the repository at this point in the history
…at test_2_conformance2__extensions__oes-draw-buffers-indexed.html. CLOSED TREE
  • Loading branch information
Butkovits Atila committed Aug 20, 2021
1 parent b5c52e9 commit 477919f
Show file tree
Hide file tree
Showing 31 changed files with 496 additions and 871 deletions.
5 changes: 0 additions & 5 deletions dom/bindings/Bindings.conf
Original file line number Diff line number Diff line change
Expand Up @@ -1165,11 +1165,6 @@ DOMInterfaces = {
'headerFile': 'ClientWebGLExtensions.h'
},

'OES_draw_buffers_indexed': {
'nativeType': 'mozilla::ClientWebGLExtensionDrawBuffersIndexed',
'headerFile': 'ClientWebGLExtensions.h'
},

'OES_element_index_uint': {
'nativeType': 'mozilla::ClientWebGLExtensionElementIndexUint',
'headerFile': 'ClientWebGLExtensions.h'
Expand Down
74 changes: 27 additions & 47 deletions dom/canvas/ClientWebGLContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@

#include "ClientWebGLContext.h"

#include <bitset>

#include "ClientWebGLExtensions.h"
#include "Layers.h"
#include "gfxCrashReporterUtils.h"
Expand Down Expand Up @@ -1624,10 +1622,9 @@ bool ClientWebGLContext::IsVertexArray(

// ------------------------- GL State -------------------------

void ClientWebGLContext::SetEnabledI(GLenum cap, Maybe<GLuint> i,
bool val) const {
Run<RPROC(SetEnabled)>(cap, i, val);
}
void ClientWebGLContext::Disable(GLenum cap) const { Run<RPROC(Disable)>(cap); }

void ClientWebGLContext::Enable(GLenum cap) const { Run<RPROC(Enable)>(cap); }

bool ClientWebGLContext::IsEnabled(GLenum cap) const {
const FuncScope funcScope(*this, "isEnabled");
Expand Down Expand Up @@ -1899,6 +1896,17 @@ void ClientWebGLContext::GetParameter(JSContext* cx, GLenum pname,
retval.set(Create<dom::Int32Array>(cx, this, state.mViewport, rv));
return;

// 4 bools
case LOCAL_GL_COLOR_WRITEMASK: {
JS::Rooted<JS::Value> arr(cx);
const auto& src = state.mColorWriteMask;
if (!dom::ToJSValue(cx, src.data(), src.size(), &arr)) {
rv = NS_ERROR_OUT_OF_MEMORY;
}
retval.set(arr);
return;
}

// any
case LOCAL_GL_COMPRESSED_TEXTURE_FORMATS:
retval.set(Create<dom::Uint32Array>(cx, this,
Expand Down Expand Up @@ -2178,19 +2186,6 @@ void ClientWebGLContext::GetParameter(JSContext* cx, GLenum pname,
retval.set(JS::BooleanValue(*maybe));
break;

// 4 bools
case LOCAL_GL_COLOR_WRITEMASK: {
const auto mask = uint8_t(*maybe);
const auto bs = std::bitset<4>(mask);
const auto src = std::array<bool, 4>{bs[0], bs[1], bs[2], bs[3]};
JS::Rooted<JS::Value> arr(cx);
if (!dom::ToJSValue(cx, src.data(), src.size(), &arr)) {
rv = NS_ERROR_OUT_OF_MEMORY;
}
retval.set(arr);
return;
}

default:
retval.set(JS::NumberValue(*maybe));
break;
Expand Down Expand Up @@ -2358,7 +2353,6 @@ void ClientWebGLContext::GetIndexedParameter(
retval.set(JS::NullValue());
const FuncScope funcScope(*this, "getIndexedParameter");
if (IsContextLost()) return;
auto keepalive = mNotLost;

const auto& state = State();

Expand Down Expand Up @@ -2401,22 +2395,7 @@ void ClientWebGLContext::GetIndexedParameter(
return ret;
}();
if (maybe) {
switch (target) {
case LOCAL_GL_COLOR_WRITEMASK: {
const auto bs = std::bitset<4>(*maybe);
const auto src = std::array<bool, 4>{bs[0], bs[1], bs[2], bs[3]};
JS::Rooted<JS::Value> arr(cx);
if (!dom::ToJSValue(cx, src.data(), src.size(), &arr)) {
rv = NS_ERROR_OUT_OF_MEMORY;
}
retval.set(arr);
return;
}

default:
retval.set(JS::NumberValue(*maybe));
return;
}
retval.set(JS::NumberValue(*maybe));
}
}

Expand Down Expand Up @@ -2591,15 +2570,14 @@ void ClientWebGLContext::BlendColor(GLclampf r, GLclampf g, GLclampf b,
Run<RPROC(BlendColor)>(r, g, b, a);
}

void ClientWebGLContext::BlendEquationSeparateI(Maybe<GLuint> i, GLenum modeRGB,
GLenum modeAlpha) {
Run<RPROC(BlendEquationSeparate)>(i, modeRGB, modeAlpha);
void ClientWebGLContext::BlendEquationSeparate(GLenum modeRGB,
GLenum modeAlpha) {
Run<RPROC(BlendEquationSeparate)>(modeRGB, modeAlpha);
}

void ClientWebGLContext::BlendFuncSeparateI(Maybe<GLuint> i, GLenum srcRGB,
GLenum dstRGB, GLenum srcAlpha,
GLenum dstAlpha) {
Run<RPROC(BlendFuncSeparate)>(i, srcRGB, dstRGB, srcAlpha, dstAlpha);
void ClientWebGLContext::BlendFuncSeparate(GLenum srcRGB, GLenum dstRGB,
GLenum srcAlpha, GLenum dstAlpha) {
Run<RPROC(BlendFuncSeparate)>(srcRGB, dstRGB, srcAlpha, dstAlpha);
}

GLenum ClientWebGLContext::CheckFramebufferStatus(GLenum target) {
Expand Down Expand Up @@ -2700,13 +2678,15 @@ void ClientWebGLContext::ClearDepth(GLclampf v) { Run<RPROC(ClearDepth)>(v); }

void ClientWebGLContext::ClearStencil(GLint v) { Run<RPROC(ClearStencil)>(v); }

void ClientWebGLContext::ColorMaskI(Maybe<GLuint> i, bool r, bool g,
bool b, bool a) const {
void ClientWebGLContext::ColorMask(WebGLboolean r, WebGLboolean g,
WebGLboolean b, WebGLboolean a) {
const FuncScope funcScope(*this, "colorMask");
if (IsContextLost()) return;
auto& state = State();

state.mColorWriteMask = {r, g, b, a};

const uint8_t mask = uint8_t(r << 0) | uint8_t(g << 1) | uint8_t(b << 2) | uint8_t(a << 3);
Run<RPROC(ColorMask)>(i, mask);
Run<RPROC(ColorMask)>(r, g, b, a);
}

void ClientWebGLContext::CullFace(GLenum face) { Run<RPROC(CullFace)>(face); }
Expand Down
25 changes: 7 additions & 18 deletions dom/canvas/ClientWebGLContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ class ContextGenerationInfo final {

std::vector<TypedQuad> mGenericVertexAttribs;

std::array<bool, 4> mColorWriteMask = {{true, true, true, true}};
std::array<int32_t, 4> mScissor = {};
std::array<int32_t, 4> mViewport = {};
std::array<float, 4> mClearColor = {{0, 0, 0, 0}};
Expand Down Expand Up @@ -1059,9 +1060,8 @@ class ClientWebGLContext final : public nsICanvasRenderingContextInternal,
public:
bool IsContextLost() const { return !mNotLost; }

void Disable(GLenum cap) const { SetEnabledI(cap, {}, false); }
void Enable(GLenum cap) const { SetEnabledI(cap, {}, true); }
void SetEnabledI(GLenum cap, Maybe<GLuint> i, bool val) const;
void Disable(GLenum cap) const;
void Enable(GLenum cap) const;
bool IsEnabled(GLenum cap) const;

private:
Expand Down Expand Up @@ -1228,18 +1228,9 @@ class ClientWebGLContext final : public nsICanvasRenderingContextInternal,
BlendFuncSeparate(sfactor, dfactor, sfactor, dfactor);
}

void BlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha) {
BlendEquationSeparateI({}, modeRGB, modeAlpha);
}
void BlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha);
void BlendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha,
GLenum dstAlpha) {
BlendFuncSeparateI({}, srcRGB, dstRGB, srcAlpha, dstAlpha);
}

void BlendEquationSeparateI(Maybe<GLuint> buf, GLenum modeRGB,
GLenum modeAlpha);
void BlendFuncSeparateI(Maybe<GLuint> buf, GLenum srcRGB, GLenum dstRGB,
GLenum srcAlpha, GLenum dstAlpha);
GLenum dstAlpha);

// -

Expand Down Expand Up @@ -1281,10 +1272,8 @@ class ClientWebGLContext final : public nsICanvasRenderingContextInternal,

void ClearStencil(GLint v);

void ColorMask(bool r, bool g, bool b, bool a) const {
ColorMaskI({}, r, g, b, a);
}
void ColorMaskI(Maybe<GLuint> buf, bool r, bool g, bool b, bool a) const;
void ColorMask(WebGLboolean r, WebGLboolean g, WebGLboolean b,
WebGLboolean a);

void CullFace(GLenum face);

Expand Down
2 changes: 0 additions & 2 deletions dom/canvas/ClientWebGLExtensions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ DEFINE_WEBGL_EXTENSION_GOOP(EXT_texture_filter_anisotropic,
WebGLExtensionTextureFilterAnisotropic)
DEFINE_WEBGL_EXTENSION_GOOP(EXT_texture_norm16, WebGLExtensionTextureNorm16)
DEFINE_WEBGL_EXTENSION_GOOP(MOZ_debug, WebGLExtensionMOZDebug)
DEFINE_WEBGL_EXTENSION_GOOP(OES_draw_buffers_indexed,
WebGLExtensionDrawBuffersIndexed)
DEFINE_WEBGL_EXTENSION_GOOP(OES_element_index_uint,
WebGLExtensionElementIndexUint)
DEFINE_WEBGL_EXTENSION_GOOP(OES_fbo_render_mipmap,
Expand Down
60 changes: 0 additions & 60 deletions dom/canvas/ClientWebGLExtensions.h
Original file line number Diff line number Diff line change
Expand Up @@ -362,66 +362,6 @@ class ClientWebGLExtensionMultiview : public ClientWebGLExtensionBase {
}
};

class ClientWebGLExtensionDrawBuffersIndexed : public ClientWebGLExtensionBase {
public:
virtual JSObject* WrapObject(JSContext* cx,
JS::Handle<JSObject*> givenProto) override;
explicit ClientWebGLExtensionDrawBuffersIndexed(ClientWebGLContext&);

void EnableiOES(const GLenum target, const GLuint buf) const {
if (MOZ_UNLIKELY(!mContext)) {
AutoJsWarning("enableiOES: Extension is `invalidated`.");
return;
}
mContext->SetEnabledI(target, Some(buf), true);
}

void DisableiOES(const GLenum target, const GLuint buf) const {
if (MOZ_UNLIKELY(!mContext)) {
AutoJsWarning("disableiOES: Extension is `invalidated`.");
return;
}
mContext->SetEnabledI(target, Some(buf), false);
}

void BlendEquationiOES(const GLuint buf, const GLenum mode) const {
BlendEquationSeparateiOES(buf, mode, mode);
}

void BlendEquationSeparateiOES(const GLuint buf, const GLenum modeRgb,
const GLenum modeAlpha) const {
if (MOZ_UNLIKELY(!mContext)) {
AutoJsWarning("blendEquationSeparateiOES: Extension is `invalidated`.");
return;
}
mContext->BlendEquationSeparateI(Some(buf), modeRgb, modeAlpha);
}

void BlendFunciOES(const GLuint buf, const GLenum src,
const GLenum dst) const {
BlendFuncSeparateiOES(buf, src, dst, src, dst);
}

void BlendFuncSeparateiOES(const GLuint buf, const GLenum srcRgb,
const GLenum dstRgb, const GLenum srcAlpha,
const GLenum dstAlpha) const {
if (MOZ_UNLIKELY(!mContext)) {
AutoJsWarning("blendFuncSeparateiOES: Extension is `invalidated`.");
return;
}
mContext->BlendFuncSeparateI(Some(buf), srcRgb, dstRgb, srcAlpha, dstAlpha);
}

void ColorMaskiOES(const GLuint buf, const bool r, const bool g, const bool b,
const bool a) const {
if (MOZ_UNLIKELY(!mContext)) {
AutoJsWarning("colorMaskiOES: Extension is `invalidated`.");
return;
}
mContext->ColorMaskI(Some(buf), r, g, b, a);
}
};

} // namespace mozilla

#endif // CLIENTWEBGLEXTENSIONS_H_
22 changes: 11 additions & 11 deletions dom/canvas/HostWebGLContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -241,9 +241,9 @@ class HostWebGLContext final : public SupportsWeakPtr {
// ------------------------- GL State -------------------------
bool IsContextLost() const { return mContext->IsContextLost(); }

void SetEnabled(GLenum cap, Maybe<GLuint> i, bool val) const {
mContext->SetEnabled(cap, i, val);
}
void Disable(GLenum cap) const { mContext->Disable(cap); }

void Enable(GLenum cap) const { mContext->Enable(cap); }

bool IsEnabled(GLenum cap) const { return mContext->IsEnabled(cap); }

Expand Down Expand Up @@ -277,14 +277,13 @@ class HostWebGLContext final : public SupportsWeakPtr {
mContext->BlendColor(r, g, b, a);
}

void BlendEquationSeparate(Maybe<GLuint> i, GLenum modeRGB,
GLenum modeAlpha) const {
mContext->BlendEquationSeparate(i, modeRGB, modeAlpha);
void BlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha) const {
mContext->BlendEquationSeparate(modeRGB, modeAlpha);
}

void BlendFuncSeparate(Maybe<GLuint> i, GLenum srcRGB, GLenum dstRGB,
GLenum srcAlpha, GLenum dstAlpha) const {
mContext->BlendFuncSeparate(i, srcRGB, dstRGB, srcAlpha, dstAlpha);
void BlendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha,
GLenum dstAlpha) const {
mContext->BlendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha);
}

GLenum CheckFramebufferStatus(GLenum target) const {
Expand All @@ -301,8 +300,9 @@ class HostWebGLContext final : public SupportsWeakPtr {

void ClearStencil(GLint v) const { mContext->ClearStencil(v); }

void ColorMask(Maybe<GLuint> i, uint8_t mask) const {
mContext->ColorMask(i, mask);
void ColorMask(WebGLboolean r, WebGLboolean g, WebGLboolean b,
WebGLboolean a) const {
mContext->ColorMask(r, g, b, a);
}

void CompileShader(const ObjectId id) const {
Expand Down
30 changes: 1 addition & 29 deletions dom/canvas/WebGL2ContextUniforms.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,34 +25,6 @@ Maybe<double> WebGL2Context::GetIndexedParameter(const GLenum pname,
const FuncScope funcScope(*this, "getIndexedParameter");
if (IsContextLost()) return {};

if (IsExtensionEnabled(WebGLExtensionID::OES_draw_buffers_indexed)) {
switch (pname) {
case LOCAL_GL_BLEND_EQUATION_RGB:
case LOCAL_GL_BLEND_EQUATION_ALPHA:
case LOCAL_GL_BLEND_SRC_RGB:
case LOCAL_GL_BLEND_SRC_ALPHA:
case LOCAL_GL_BLEND_DST_RGB:
case LOCAL_GL_BLEND_DST_ALPHA:
case LOCAL_GL_COLOR_WRITEMASK: {
const auto limit = MaxValidDrawBuffers();
if (index >= limit) {
ErrorInvalidValue("`index` (%u) must be < %s (%u)", index,
"MAX_DRAW_BUFFERS", limit);
return {};
}

std::array<GLint, 4> data = {};
gl->fGetIntegeri_v(pname, index, data.data());
auto val = data[0];
if (pname == LOCAL_GL_COLOR_WRITEMASK) {
val = (bool(data[0]) << 0 | bool(data[1]) << 1 | bool(data[2]) << 2 |
bool(data[3]) << 3);
}
return Some(val);
}
}
}

const auto* bindings = &mIndexedUniformBufferBindings;
const char* limitStr = "MAX_UNIFORM_BUFFER_BINDINGS";
switch (pname) {
Expand All @@ -67,7 +39,7 @@ Maybe<double> WebGL2Context::GetIndexedParameter(const GLenum pname,
break;

default:
ErrorInvalidEnumArg("pname", pname);
ErrorInvalidEnumInfo("pname", pname);
return {};
}

Expand Down
Loading

0 comments on commit 477919f

Please sign in to comment.