mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-09-12 14:18:31 +09:00
[Fix] (DirectGLES, MG_Util): raw framebuffer writes while GL_FRAMEBUFFER_SRGB is off
GLES core always encodes a fragment written into an sRGB colour attachment, and offers no switch to stop it. Desktop GL has one, GL_FRAMEBUFFER_SRGB, and it starts out disabled - so a GL application that never touches it expects its writes to land raw. The frontend models exactly that (the capability reads as disabled and DirectVulkan attaches the UNORM twin to honour it), but DirectGLES was passing the draw straight to a driver that encodes anyway. The value therefore came back one conversion short of the reference wherever it was written and then read again: rendering into an sRGB texture and fetching it in a shader decodes once but had encoded twice, which is how KHR-GL32.texture_size_promotion read 0.0142 for GL_SRGB8_ALPHA8 where 0.00111 was expected. Detect GL_EXT_sRGB_write_control and sync GL_FRAMEBUFFER_SRGB from the frontend capability alongside the other enables, starting from the driver's enabled state so the first sync always pushes the disable down.
This commit is contained in:
@@ -824,6 +824,9 @@ namespace MobileGL::MG_Util::BackendLoader {
|
||||
if (std::strcmp(extension, "GL_EXT_texture_norm16") == 0) {
|
||||
caps.SupportsNorm16Texture = true;
|
||||
}
|
||||
if (std::strcmp(extension, "GL_EXT_sRGB_write_control") == 0) {
|
||||
caps.SupportsSrgbWriteControl = true;
|
||||
}
|
||||
if (std::strcmp(extension, "GL_EXT_texture_filter_anisotropic") == 0) {
|
||||
caps.SupportsTextureFilterAnisotropy = true;
|
||||
}
|
||||
|
||||
@@ -1031,6 +1031,10 @@ namespace MobileGL {
|
||||
String GLESShadingLanguageVersionString;
|
||||
Bool SupportsPersistentMapping = false;
|
||||
Bool SupportsNorm16Texture = false;
|
||||
// GL_EXT_sRGB_write_control is present, so GL_FRAMEBUFFER_SRGB can be turned off.
|
||||
// GLES has no such switch in core: writes into an sRGB attachment are ALWAYS encoded,
|
||||
// while desktop GL leaves GL_FRAMEBUFFER_SRGB disabled by default and writes raw.
|
||||
Bool SupportsSrgbWriteControl = false;
|
||||
// GL_EXT_texture_filter_anisotropic is present, so sampler/texture
|
||||
// anisotropy may be forwarded without raising GL_INVALID_ENUM in GLES.
|
||||
Bool SupportsTextureFilterAnisotropy = false;
|
||||
|
||||
Reference in New Issue
Block a user