mirror of
https://github.com/love2d/love.git
synced 2026-08-19 04:06:17 +02:00
opengl: attempt to fix the Android workaround for r8 pixel format support.
This commit is contained in:
@@ -1693,6 +1693,17 @@ void Graphics::initCapabilities()
|
|||||||
pixelFormatUsage[i][0] = computePixelFormatUsage(format, false);
|
pixelFormatUsage[i][0] = computePixelFormatUsage(format, false);
|
||||||
pixelFormatUsage[i][1] = computePixelFormatUsage(format, true);
|
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)
|
uint32 Graphics::computePixelFormatUsage(PixelFormat format, bool readable)
|
||||||
|
|||||||
@@ -324,14 +324,6 @@ void OpenGL::setupContext()
|
|||||||
setColorWriteMask(state.colorWriteMask);
|
setColorWriteMask(state.colorWriteMask);
|
||||||
|
|
||||||
contextInitialized = true;
|
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()
|
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]);
|
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)
|
if (target == TEXTURE_2D || target == TEXTURE_CUBE)
|
||||||
glTexStorage2D(gltarget, levels, fmt.internalformat, width, height);
|
glTexStorage2D(gltarget, levels, fmt.internalformat, width, height);
|
||||||
|
|||||||
Reference in New Issue
Block a user