mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-29 20:07:30 +09:00
[WebGL] Implement webgl.max-size-per-texture-mib
This commit is contained in:
parent
3fccd404fb
commit
2f0acd868e
3 changed files with 38 additions and 14 deletions
|
|
@ -1032,9 +1032,27 @@ ValidateCompressedTexImageRestrictions(const char* funcName, WebGLContext* webgl
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
ValidateTargetForFormat(const char* funcName, WebGLContext* webgl, TexImageTarget target,
|
ValidateFormatAndSize(const char* funcName,
|
||||||
const webgl::FormatInfo* format)
|
WebGLContext* webgl,
|
||||||
{
|
TexImageTarget target,
|
||||||
|
const webgl::FormatInfo* format,
|
||||||
|
const uint32_t width,
|
||||||
|
const uint32_t height,
|
||||||
|
const uint32_t depth) {
|
||||||
|
// Check if texture size will likely be rejected by the driver and give a more
|
||||||
|
// meaningful error message.
|
||||||
|
auto baseImageSize = CheckedInt<uint64_t>(format->estimatedBytesPerPixel) *
|
||||||
|
width * height * depth;
|
||||||
|
if (target == LOCAL_GL_TEXTURE_CUBE_MAP) {
|
||||||
|
baseImageSize *= 6;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!baseImageSize.isValid() ||
|
||||||
|
baseImageSize.value() > (uint64_t)gfxPrefs::WebGLMaxSizePerTextureMB * (1024 * 1024)) {
|
||||||
|
webgl->ErrorOutOfMemory("Texture size too large; base image MB > webgl.max-size-per-texture-mb");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// GLES 3.0.4 p127:
|
// GLES 3.0.4 p127:
|
||||||
// "Textures with a base internal format of DEPTH_COMPONENT or DEPTH_STENCIL are
|
// "Textures with a base internal format of DEPTH_COMPONENT or DEPTH_STENCIL are
|
||||||
// supported by texture image specification commands only if `target` is TEXTURE_2D,
|
// supported by texture image specification commands only if `target` is TEXTURE_2D,
|
||||||
|
|
@ -1137,7 +1155,8 @@ WebGLTexture::TexStorage(const char* funcName, TexTarget target, GLsizei levels,
|
||||||
}
|
}
|
||||||
auto dstFormat = dstUsage->format;
|
auto dstFormat = dstUsage->format;
|
||||||
|
|
||||||
if (!ValidateTargetForFormat(funcName, mContext, testTarget, dstFormat))
|
if (!ValidateFormatAndSize(funcName, mContext, testTarget, dstFormat,
|
||||||
|
width, height, depth))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (dstFormat->compression) {
|
if (dstFormat->compression) {
|
||||||
|
|
@ -1264,7 +1283,8 @@ WebGLTexture::TexImage(const char* funcName, TexImageTarget target, GLint level,
|
||||||
// Check that source and dest info are compatible
|
// Check that source and dest info are compatible
|
||||||
auto dstFormat = dstUsage->format;
|
auto dstFormat = dstUsage->format;
|
||||||
|
|
||||||
if (!ValidateTargetForFormat(funcName, mContext, target, dstFormat))
|
if (!ValidateFormatAndSize(funcName, mContext, target, dstFormat,
|
||||||
|
blob->mWidth, blob->mHeight, blob->mDepth))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!mContext->IsWebGL2() && dstFormat->d) {
|
if (!mContext->IsWebGL2() && dstFormat->d) {
|
||||||
|
|
@ -1484,7 +1504,8 @@ WebGLTexture::CompressedTexImage(const char* funcName, TexImageTarget target, GL
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ValidateTargetForFormat(funcName, mContext, target, format))
|
if (!ValidateFormatAndSize(funcName, mContext, target, format,
|
||||||
|
blob->mWidth, blob->mHeight, blob->mDepth))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
////////////////////////////////////
|
////////////////////////////////////
|
||||||
|
|
@ -2143,7 +2164,8 @@ WebGLTexture::CopyTexImage2D(TexImageTarget target, GLint level, GLenum internal
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const auto& dstFormat = dstUsage->format;
|
const auto& dstFormat = dstUsage->format;
|
||||||
if (!ValidateTargetForFormat(funcName, mContext, target, dstFormat))
|
if (!ValidateFormatAndSize(funcName, mContext, target, dstFormat,
|
||||||
|
width, height, depth))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!mContext->IsWebGL2() && dstFormat->d) {
|
if (!mContext->IsWebGL2() && dstFormat->d) {
|
||||||
|
|
|
||||||
|
|
@ -593,6 +593,7 @@ private:
|
||||||
DECL_GFX_PREF(Once, "webgl.force-layers-readback", WebGLForceLayersReadback, bool, false);
|
DECL_GFX_PREF(Once, "webgl.force-layers-readback", WebGLForceLayersReadback, bool, false);
|
||||||
DECL_GFX_PREF(Live, "webgl.lose-context-on-memory-pressure", WebGLLoseContextOnMemoryPressure, bool, false);
|
DECL_GFX_PREF(Live, "webgl.lose-context-on-memory-pressure", WebGLLoseContextOnMemoryPressure, bool, false);
|
||||||
DECL_GFX_PREF(Live, "webgl.max-warnings-per-context", WebGLMaxWarningsPerContext, uint32_t, 32);
|
DECL_GFX_PREF(Live, "webgl.max-warnings-per-context", WebGLMaxWarningsPerContext, uint32_t, 32);
|
||||||
|
DECL_GFX_PREF(Live, "webgl.max-size-per-texture-mb", WebGLMaxSizePerTextureMB, uint32_t, 1024);
|
||||||
DECL_GFX_PREF(Live, "webgl.min_capability_mode", WebGLMinCapabilityMode, bool, false);
|
DECL_GFX_PREF(Live, "webgl.min_capability_mode", WebGLMinCapabilityMode, bool, false);
|
||||||
DECL_GFX_PREF(Live, "webgl.msaa-force", WebGLForceMSAA, bool, false);
|
DECL_GFX_PREF(Live, "webgl.msaa-force", WebGLForceMSAA, bool, false);
|
||||||
DECL_GFX_PREF(Live, "webgl.prefer-16bpp", WebGLPrefer16bpp, bool, false);
|
DECL_GFX_PREF(Live, "webgl.prefer-16bpp", WebGLPrefer16bpp, bool, false);
|
||||||
|
|
|
||||||
|
|
@ -4280,6 +4280,7 @@ pref("webgl.lose-context-on-memory-pressure", false);
|
||||||
pref("webgl.can-lose-context-in-foreground", true);
|
pref("webgl.can-lose-context-in-foreground", true);
|
||||||
pref("webgl.restore-context-when-visible", true);
|
pref("webgl.restore-context-when-visible", true);
|
||||||
pref("webgl.max-warnings-per-context", 32);
|
pref("webgl.max-warnings-per-context", 32);
|
||||||
|
pref("webgl.max-size-per-texture-mb", 1024);
|
||||||
pref("webgl.enable-draft-extensions", false);
|
pref("webgl.enable-draft-extensions", false);
|
||||||
pref("webgl.enable-privileged-extensions", false);
|
pref("webgl.enable-privileged-extensions", false);
|
||||||
pref("webgl.bypass-shader-validation", false);
|
pref("webgl.bypass-shader-validation", false);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue