Bug 1544446 - Restrict macOS MAX_TEXTURE_SIZE to 8192. r=lsalzman

Also clean up MAX_TEXTURE_SIZE restriction code.

Differential Revision: https://phabricator.services.mozilla.com/D36144

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Jeff Gilbert 2019-06-27 01:54:06 +00:00
Родитель 91dd7e5ead
Коммит 4e80fa71e2
1 изменённых файлов: 29 добавлений и 16 удалений

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

@ -838,37 +838,35 @@ bool GLContext::InitImpl() {
raw_fGetIntegerv(LOCAL_GL_MAX_VIEWPORT_DIMS, mMaxViewportDims); raw_fGetIntegerv(LOCAL_GL_MAX_VIEWPORT_DIMS, mMaxViewportDims);
if (mWorkAroundDriverBugs) { if (mWorkAroundDriverBugs) {
int maxTexSize = INT32_MAX;
int maxCubeSize = INT32_MAX;
#ifdef XP_MACOSX #ifdef XP_MACOSX
if (!nsCocoaFeatures::IsAtLeastVersion(10, 12)) { if (!nsCocoaFeatures::IsAtLeastVersion(10, 12)) {
if (mVendor == GLVendor::Intel) { if (mVendor == GLVendor::Intel) {
// see bug 737182 for 2D textures, bug 684882 for cube map textures. // see bug 737182 for 2D textures, bug 684882 for cube map textures.
mMaxTextureSize = std::min(mMaxTextureSize, 4096); maxTexSize = 4096;
mMaxCubeMapTextureSize = std::min(mMaxCubeMapTextureSize, 512); maxCubeSize = 512;
// for good measure, we align renderbuffers on what we do for 2D
// textures
mMaxRenderbufferSize = std::min(mMaxRenderbufferSize, 4096);
mNeedsTextureSizeChecks = true;
} else if (mVendor == GLVendor::NVIDIA) { } else if (mVendor == GLVendor::NVIDIA) {
// See bug 879656. 8192 fails, 8191 works. // See bug 879656. 8192 fails, 8191 works.
mMaxTextureSize = std::min(mMaxTextureSize, 8191); maxTexSize = 8191;
mMaxRenderbufferSize = std::min(mMaxRenderbufferSize, 8191);
// Part of the bug 879656, but it also doesn't hurt the 877949
mNeedsTextureSizeChecks = true;
} }
} else {
// https://bugzilla.mozilla.org/show_bug.cgi?id=1544446
// Mojave exposes 16k textures, but gives FRAMEBUFFER_UNSUPPORTED for any
// 16k*16k FB except rgba8 without depth/stencil.
// The max supported sizes changes based on involved formats.
// (RGBA32F more restrictive than RGBA16F)
maxTexSize = 8192;
} }
#endif #endif
#ifdef MOZ_X11 #ifdef MOZ_X11
if (mVendor == GLVendor::Nouveau) { if (mVendor == GLVendor::Nouveau) {
// see bug 814716. Clamp MaxCubeMapTextureSize at 2K for Nouveau. // see bug 814716. Clamp MaxCubeMapTextureSize at 2K for Nouveau.
mMaxCubeMapTextureSize = std::min(mMaxCubeMapTextureSize, 2048); maxCubeSize = 2048;
mNeedsTextureSizeChecks = true;
} else if (mVendor == GLVendor::Intel) { } else if (mVendor == GLVendor::Intel) {
// Bug 1199923. Driver seems to report a larger max size than // Bug 1199923. Driver seems to report a larger max size than
// actually supported. // actually supported.
mMaxTextureSize /= 2; maxTexSize = mMaxTextureSize / 2;
mMaxRenderbufferSize /= 2;
mNeedsTextureSizeChecks = true;
} }
// Bug 1367570. Explicitly set vertex attributes [1,3] to opaque // Bug 1367570. Explicitly set vertex attributes [1,3] to opaque
// black because Nvidia doesn't do it for us. // black because Nvidia doesn't do it for us.
@ -902,6 +900,21 @@ bool GLContext::InitImpl() {
mNeedsCheckAfterAttachTextureToFb = true; mNeedsCheckAfterAttachTextureToFb = true;
} }
#endif #endif
// -
const auto fnLimit = [&](int* const driver, const int limit) {
if (*driver > limit) {
*driver = limit;
mNeedsTextureSizeChecks = true;
}
};
fnLimit(&mMaxTextureSize, maxTexSize);
fnLimit(&mMaxRenderbufferSize, maxTexSize);
maxCubeSize = std::min(maxCubeSize, maxTexSize);
fnLimit(&mMaxCubeMapTextureSize, maxCubeSize);
} }
if (IsSupported(GLFeature::framebuffer_multisample)) { if (IsSupported(GLFeature::framebuffer_multisample)) {