opengl: attempt to fix the Android workaround for r8 pixel format support.

This commit is contained in:
Sasha Szpakowski
2024-03-17 13:54:40 -03:00
parent 60911c5181
commit 4d1865fe1a
2 changed files with 22 additions and 9 deletions
+11
View File
@@ -1693,6 +1693,17 @@ void Graphics::initCapabilities()
pixelFormatUsage[i][0] = computePixelFormatUsage(format, false);
pixelFormatUsage[i][1] = computePixelFormatUsage(format, true);
}
#ifdef LOVE_ANDROID
// This can't be done in initContext with the rest of the bug checks because
// isPixelFormatSupported relies on state initialized here / after init.
if (GLAD_ES_VERSION_3_0 && !isPixelFormatSupported(PIXELFORMAT_R8_UNORM, PIXELFORMATUSAGEFLAGS_SAMPLE | PIXELFORMATUSAGEFLAGS_RENDERTARGET))
{
gl.bugs.brokenR8PixelFormat = true;
pixelFormatUsage[PIXELFORMAT_R8_UNORM][0] = computePixelFormatUsage(PIXELFORMAT_R8_UNORM, false);
pixelFormatUsage[PIXELFORMAT_R8_UNORM][1] = computePixelFormatUsage(PIXELFORMAT_R8_UNORM, true);
}
#endif
}
uint32 Graphics::computePixelFormatUsage(PixelFormat format, bool readable)
+11 -9
View File
@@ -324,14 +324,6 @@ void OpenGL::setupContext()
setColorWriteMask(state.colorWriteMask);
contextInitialized = true;
#ifdef LOVE_ANDROID
// This can't be done in initContext with the rest of the bug checks because
// isPixelFormatSupported relies on state initialized here / after init.
auto gfx = Module::getInstance<Graphics>(Module::M_GRAPHICS);
if (GLAD_ES_VERSION_3_0 && gfx != nullptr && !gfx->isPixelFormatSupported(PIXELFORMAT_R8_UNORM, PIXELFORMATUSAGEFLAGS_SAMPLE | PIXELFORMATUSAGEFLAGS_RENDERTARGET))
bugs.brokenR8PixelFormat = true;
#endif
}
void OpenGL::deInitContext()
@@ -1344,7 +1336,17 @@ bool OpenGL::rawTexStorage(TextureType target, int levels, PixelFormat pixelform
glTexParameteri(gltarget, GL_TEXTURE_SWIZZLE_A, fmt.swizzle[3]);
}
if (isTexStorageSupported())
bool usetexstorage = isTexStorageSupported();
// The fallback for bugs.brokenR8PixelFormat is GL_LUMINANCE, which doesn't have a sized
// version in ES3 so it can't be used with glTexStorage.
if (pixelformat == PIXELFORMAT_R8_UNORM && bugs.brokenR8PixelFormat && GLAD_ES_VERSION_3_0)
{
usetexstorage = false;
fmt.internalformat = fmt.externalformat;
}
if (usetexstorage)
{
if (target == TEXTURE_2D || target == TEXTURE_CUBE)
glTexStorage2D(gltarget, levels, fmt.internalformat, width, height);