Bug 1795372 - Keepalive mNotLost within FuncScope. r=gfx-reviewers,lsalzman

Also remove unused FuncScopeId.

Differential Revision: https://phabricator.services.mozilla.com/D159428
This commit is contained in:
Kelsey Gilbert 2022-10-14 23:10:19 +00:00
Родитель 242c704d10
Коммит 2853c1d91c
4 изменённых файлов: 16 добавлений и 92 удалений

Просмотреть файл

@ -4815,15 +4815,14 @@ void ClientWebGLContext::VertexAttribPointerImpl(bool isFuncInt, GLuint index,
// -------------------------------- Drawing -------------------------------
void ClientWebGLContext::DrawArraysInstanced(GLenum mode, GLint first,
GLsizei count, GLsizei primcount,
FuncScopeId) {
GLsizei count, GLsizei primcount) {
Run<RPROC(DrawArraysInstanced)>(mode, first, count, primcount);
AfterDrawCall();
}
void ClientWebGLContext::DrawElementsInstanced(GLenum mode, GLsizei count,
GLenum type, WebGLintptr offset,
GLsizei primcount, FuncScopeId) {
GLsizei primcount) {
Run<RPROC(DrawElementsInstanced)>(mode, count, type, offset, primcount);
AfterDrawCall();
}

Просмотреть файл

@ -810,40 +810,35 @@ class ClientWebGLContext final : public nsICanvasRenderingContextInternal,
class FuncScope final {
public:
const ClientWebGLContext& mWebGL;
const std::shared_ptr<webgl::NotLostData> mKeepNotLostOrNull;
const char* const mFuncName;
const FuncScopeId mId;
FuncScope(const ClientWebGLContext& webgl, const char* funcName)
: mWebGL(webgl),
mFuncName(funcName),
mId(FuncScopeId::FuncScopeIdError) {
mKeepNotLostOrNull(webgl.mNotLost),
mFuncName(funcName) {
// Only set if an "outer" scope hasn't already been set.
if (!mWebGL.mFuncScope) {
mWebGL.mFuncScope = this;
}
}
FuncScope(const ClientWebGLContext* webgl, FuncScopeId aId)
: mWebGL(*webgl), mFuncName(GetFuncScopeName(aId)), mId(aId) {
mWebGL.mFuncScope = this;
}
~FuncScope() {
if (this == mWebGL.mFuncScope) {
mWebGL.mFuncScope = nullptr;
}
}
FuncScope(const FuncScope&) = delete;
FuncScope(FuncScope&&) = delete;
};
protected:
// The scope of the function at the top of the current WebGL function call
// stack
mutable FuncScope* mFuncScope = nullptr;
const auto& CurFuncScope() const { return *mFuncScope; }
FuncScopeId GetFuncScopeId() const {
return mFuncScope ? mFuncScope->mId : FuncScopeId::FuncScopeIdError;
}
const char* FuncName() const {
return mFuncScope ? mFuncScope->mFuncName : nullptr;
}
@ -2051,13 +2046,12 @@ class ClientWebGLContext final : public nsICanvasRenderingContextInternal,
// -------------------------------- Drawing -------------------------------
public:
void DrawArrays(GLenum mode, GLint first, GLsizei count) {
DrawArraysInstanced(mode, first, count, 1, FuncScopeId::drawArrays);
DrawArraysInstanced(mode, first, count, 1);
}
void DrawElements(GLenum mode, GLsizei count, GLenum type,
WebGLintptr byteOffset) {
DrawElementsInstanced(mode, count, type, byteOffset, 1,
FuncScopeId::drawElements);
DrawElementsInstanced(mode, count, type, byteOffset, 1);
}
void DrawRangeElements(GLenum mode, GLuint start, GLuint end, GLsizei count,
@ -2067,8 +2061,7 @@ class ClientWebGLContext final : public nsICanvasRenderingContextInternal,
EnqueueError(LOCAL_GL_INVALID_VALUE, "end must be >= start.");
return;
}
DrawElementsInstanced(mode, count, type, byteOffset, 1,
FuncScopeId::drawRangeElements);
DrawElementsInstanced(mode, count, type, byteOffset, 1);
}
// ------------------------------ Readback -------------------------------
@ -2101,13 +2094,10 @@ class ClientWebGLContext final : public nsICanvasRenderingContextInternal,
void BindVertexArray(WebGLVertexArrayJS*);
void DrawArraysInstanced(GLenum mode, GLint first, GLsizei count,
GLsizei primcount,
FuncScopeId aFuncId = FuncScopeId::drawArrays);
GLsizei primcount);
void DrawElementsInstanced(
GLenum mode, GLsizei count, GLenum type, WebGLintptr offset,
GLsizei primcount,
FuncScopeId aFuncId = FuncScopeId::drawElementsInstanced);
void DrawElementsInstanced(GLenum mode, GLsizei count, GLenum type,
WebGLintptr offset, GLsizei primcount);
void VertexAttribDivisor(GLuint index, GLuint divisor);

Просмотреть файл

@ -228,8 +228,7 @@ class ClientWebGLExtensionInstancedArrays : public ClientWebGLExtensionBase {
AutoJsWarning("drawElementsInstancedANGLE: Extension is `invalidated`.");
return;
}
mContext->DrawElementsInstanced(mode, count, type, offset, primcount,
FuncScopeId::drawElementsInstanced);
mContext->DrawElementsInstanced(mode, count, type, offset, primcount);
}
void VertexAttribDivisorANGLE(GLuint index, GLuint divisor) {
if (MOZ_UNLIKELY(!mContext)) {

Просмотреть файл

@ -880,70 +880,6 @@ class RawBuffer final {
// -
struct CopyableRange final : public Range<const uint8_t> {};
// -
// clang-format off
#define FOREACH_ID(X) \
X(FuncScopeIdError) \
X(compressedTexImage2D) \
X(compressedTexImage3D) \
X(compressedTexSubImage2D) \
X(compressedTexSubImage3D) \
X(copyTexSubImage2D) \
X(copyTexSubImage3D) \
X(drawArrays) \
X(drawArraysInstanced) \
X(drawElements) \
X(drawElementsInstanced) \
X(drawRangeElements) \
X(renderbufferStorage) \
X(renderbufferStorageMultisample) \
X(texImage2D) \
X(texImage3D) \
X(TexStorage2D) \
X(TexStorage3D) \
X(texSubImage2D) \
X(texSubImage3D) \
X(vertexAttrib1f) \
X(vertexAttrib1fv) \
X(vertexAttrib2f) \
X(vertexAttrib2fv) \
X(vertexAttrib3f) \
X(vertexAttrib3fv) \
X(vertexAttrib4f) \
X(vertexAttrib4fv) \
X(vertexAttribI4i) \
X(vertexAttribI4iv) \
X(vertexAttribI4ui) \
X(vertexAttribI4uiv) \
X(vertexAttribIPointer) \
X(vertexAttribPointer)
// clang-format on
enum class FuncScopeId {
#define _(X) X,
FOREACH_ID(_)
#undef _
};
static constexpr const char* const FUNCSCOPE_NAME_BY_ID[] = {
#define _(X) #X,
FOREACH_ID(_)
#undef _
};
#undef FOREACH_ID
inline auto GetFuncScopeName(const FuncScopeId id) {
return FUNCSCOPE_NAME_BY_ID[static_cast<size_t>(id)];
}
// -
template <typename C, typename K>
inline auto MaybeFind(C& container, const K& key)
-> decltype(&(container.find(key)->second)) {