[Fix] some format quirk

This commit is contained in:
2025-05-07 17:15:50 +08:00
parent a17497522a
commit d1eb029671
3 changed files with 29 additions and 9 deletions
@@ -123,15 +123,22 @@ namespace MG_GL::GL {
for (auto& [level, mip] : texObj.params.mipmapData) { for (auto& [level, mip] : texObj.params.mipmapData) {
const void* data = !mip.pixelData.empty() ? mip.pixelData.data() : nullptr; const void* data = !mip.pixelData.empty() ? mip.pixelData.data() : nullptr;
switch (target) { switch (target) {
case GL_TEXTURE_2D: case GL_TEXTURE_2D: {
CallAndCheck(::GLES::glTexImage2D( GLenum type = mip.type;
target, level, mip.internalFormat, // Mali cannot use GL_FLOAT as depth format
mip.width, mip.height, 0, if (mip.internalFormat == GL_DEPTH_COMPONENT) {
mip.format, mip.type, data type = GL_UNSIGNED_INT;
);) }
CallAndCheck(::GLES::glTexImage2D(
target, level, mip.internalFormat,
mip.width, mip.height, 0,
mip.format, type, data
);)
s_textureLevelUploaded[mgTexId][level] = true; s_textureLevelUploaded[mgTexId][level] = true;
MG_Util::Debug::LogD("Initial upload texture %u level %d (size=%zu)", mgTexId, level, mip.pixelData.size()); MG_Util::Debug::LogD("Initial upload texture %u level %d (size=%zu)",
mgTexId, level, mip.pixelData.size());
break; break;
}
default: default:
MG_Util::Debug::LogE("Unsupported target: %s", MG_Util::Debug::GLEnumToString(target)); MG_Util::Debug::LogE("Unsupported target: %s", MG_Util::Debug::GLEnumToString(target));
} }
@@ -256,10 +263,10 @@ namespace MG_GL::GL {
GLuint expectedGLTexId = 0; GLuint expectedGLTexId = 0;
if (mgAtt.handle != 0) { if (mgAtt.handle != 0) {
if (s_textureMap.count(mgAtt.handle)) { if (s_textureMap.find(mgAtt.handle) != s_textureMap.end()) {
expectedGLTexId = s_textureMap[mgAtt.handle]; expectedGLTexId = s_textureMap[mgAtt.handle];
} else { } else {
MG_Util::Debug::LogE("MobileGL Texture %u for FBO %u attachment 0x%X not found in s_textureMap during FBO sync!", mgAtt.handle, fb, mgAttachmentPoint); MG_Util::Debug::LogE("MobileGL Texture %u for FBO %u attachment %s not found in s_textureMap during FBO sync!", mgAtt.handle, fb, MG_Util::Debug::GLEnumToString(mgAttachmentPoint));
for (auto const& [key, val] : s_textureMap) for (auto const& [key, val] : s_textureMap)
MG_Util::Debug::LogW(" key: %d, val: %d", key, val); MG_Util::Debug::LogW(" key: %d, val: %d", key, val);
continue; continue;
@@ -788,6 +795,10 @@ namespace MG_GL::GL {
GLenum filter) { GLenum filter) {
MG_Util::Debug::LogD("BlitFramebuffer, srcX0=%d, srcY0=%d, srcX1=%d, srcY1=%d, dstX0=%d, dstY0=%d, dstX1=%d, dstY1=%d, mask=0x%x, filter=%s", MG_Util::Debug::LogD("BlitFramebuffer, srcX0=%d, srcY0=%d, srcX1=%d, srcY1=%d, dstX0=%d, dstY0=%d, dstX1=%d, dstY1=%d, mask=0x%x, filter=%s",
srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, MG_Util::Debug::GLEnumToString(filter)); srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, MG_Util::Debug::GLEnumToString(filter));
TextureState* textureState = MG_State_T::textureState;
// Texture
SyncAllTexturesToGLES(textureState);
// Realize FBO states // Realize FBO states
RealizeFBOState(GL_DRAW_FRAMEBUFFER); RealizeFBOState(GL_DRAW_FRAMEBUFFER);
@@ -894,6 +905,11 @@ namespace MG_GL::GL {
// lastBoundFBO[0] = currentFBO; // lastBoundFBO[0] = currentFBO;
// } // }
TextureState* textureState = MG_State_T::textureState;
// Texture
SyncAllTexturesToGLES(textureState);
RealizeFBOState(GL_DRAW_FRAMEBUFFER); RealizeFBOState(GL_DRAW_FRAMEBUFFER);
static GLfloat lastClearColor[4] = {-1.0f, -1.0f, -1.0f, -1.0f}; static GLfloat lastClearColor[4] = {-1.0f, -1.0f, -1.0f, -1.0f};
@@ -45,6 +45,7 @@ namespace MG_GL::GL {
GLenum result = MG_State::AttachTexture2DToFramebuffer( GLenum result = MG_State::AttachTexture2DToFramebuffer(
target, attachment, textarget, texture, level target, attachment, textarget, texture, level
); );
if (result == GL_NO_ERROR) return; if (result == GL_NO_ERROR) return;
MG_State::SetError(result); MG_State::SetError(result);
MG_Util::Debug::LogE("Texture attachment failed: %s", MG_Util::Debug::GLEnumToString(result)); MG_Util::Debug::LogE("Texture attachment failed: %s", MG_Util::Debug::GLEnumToString(result));
+3
View File
@@ -1212,6 +1212,9 @@ void Log##name(const char* format, ...) { \
CASE(GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT) CASE(GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT)
CASE(GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS) CASE(GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS)
CASE(GL_FRAMEBUFFER_UNSUPPORTED) CASE(GL_FRAMEBUFFER_UNSUPPORTED)
CASE(GL_COLOR_ATTACHMENT0)
CASE(GL_DEPTH_ATTACHMENT)
CASE(GL_STENCIL_ATTACHMENT)
/* /*
* Miscellaneous * Miscellaneous
*/ */