diff options
author | Moonchild <moonchild@palemoon.org> | 2023-10-25 07:53:57 +0200 |
---|---|---|
committer | Moonchild <moonchild@palemoon.org> | 2023-10-25 07:53:57 +0200 |
commit | b15a36452d78004c3279159433bc515bf85feb8b (patch) | |
tree | 36b19ee06d6cbc5f8bff971631f7ce2f001d3b0a /dom | |
parent | a71597905c3b3a7ef4912b5d626bc141c7c4c4f9 (diff) | |
download | uxp-b15a36452d78004c3279159433bc515bf85feb8b.tar.gz |
[WebGL] Add preffed limit to WebGL vertCount
Defaults to 30M, working around driver bugs (looking at you, Mesa)
Diffstat (limited to 'dom')
-rw-r--r-- | dom/canvas/WebGLContext.h | 2 | ||||
-rw-r--r-- | dom/canvas/WebGLContextDraw.cpp | 12 |
2 files changed, 14 insertions, 0 deletions
diff --git a/dom/canvas/WebGLContext.h b/dom/canvas/WebGLContext.h index 0510e6898a..8984b71366 100644 --- a/dom/canvas/WebGLContext.h +++ b/dom/canvas/WebGLContext.h @@ -8,6 +8,7 @@ #include <stdarg.h> +#include "gfxPrefs.h" #include "GLContextTypes.h" #include "GLDefs.h" #include "mozilla/Attributes.h" @@ -1397,6 +1398,7 @@ protected: CheckedUint32 mGeneration; WebGLContextOptions mOptions; + const uint32_t mMaxVertIdsPerDraw = gfxPrefs::WebglMaxVertIDsPerDraw(); bool mInvalidated; bool mCapturedFrameInvalidated; diff --git a/dom/canvas/WebGLContextDraw.cpp b/dom/canvas/WebGLContextDraw.cpp index 6c684b2ff8..a01e38c5c6 100644 --- a/dom/canvas/WebGLContextDraw.cpp +++ b/dom/canvas/WebGLContextDraw.cpp @@ -607,6 +607,12 @@ WebGLContext::DrawArraysInstanced(GLenum mode, GLint first, GLsizei vertCount, return; MakeContextCurrent(); + + if (vertCount > mMaxVertIdsPerDraw) {
+ ErrorOutOfMemory(
+ "Context's max vertCount is %u, but %u requested. [webgl.max-vert-ids-per-draw]", mMaxVertIdsPerDraw, vertCount);
+ return;
+ }
bool error = false; ScopedResolveTexturesForDraw scopedResolve(this, funcName, &error); @@ -849,6 +855,12 @@ WebGLContext::DrawElementsInstanced(GLenum mode, GLsizei vertCount, GLenum type, return; MakeContextCurrent(); +
+ if (vertCount > mMaxVertIdsPerDraw) {
+ ErrorOutOfMemory(
+ "Context's max vertCount is %u, but %u requested. [webgl.max-vert-ids-per-draw]", mMaxVertIdsPerDraw, vertCount);
+ return;
+ }
bool error = false; ScopedResolveTexturesForDraw scopedResolve(this, funcName, &error); |