diff --git a/MG/MG_GL/Implementations/GL/Drawing/GL_Drawing.cpp b/MG/MG_GL/Implementations/GL/Drawing/GL_Drawing.cpp index 240a2630..d232454d 100644 --- a/MG/MG_GL/Implementations/GL/Drawing/GL_Drawing.cpp +++ b/MG/MG_GL/Implementations/GL/Drawing/GL_Drawing.cpp @@ -123,15 +123,22 @@ namespace MG_GL::GL { for (auto& [level, mip] : texObj.params.mipmapData) { const void* data = !mip.pixelData.empty() ? mip.pixelData.data() : nullptr; switch (target) { - case GL_TEXTURE_2D: - CallAndCheck(::GLES::glTexImage2D( - target, level, mip.internalFormat, - mip.width, mip.height, 0, - mip.format, mip.type, data - );) + case GL_TEXTURE_2D: { + GLenum type = mip.type; + // Mali cannot use GL_FLOAT as depth format + if (mip.internalFormat == GL_DEPTH_COMPONENT) { + 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; - 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; + } default: MG_Util::Debug::LogE("Unsupported target: %s", MG_Util::Debug::GLEnumToString(target)); } @@ -256,10 +263,10 @@ namespace MG_GL::GL { GLuint expectedGLTexId = 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]; } 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) MG_Util::Debug::LogW(" key: %d, val: %d", key, val); continue; @@ -788,6 +795,10 @@ namespace MG_GL::GL { 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", 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 RealizeFBOState(GL_DRAW_FRAMEBUFFER); @@ -894,6 +905,11 @@ namespace MG_GL::GL { // lastBoundFBO[0] = currentFBO; // } + TextureState* textureState = MG_State_T::textureState; + + // Texture + SyncAllTexturesToGLES(textureState); + RealizeFBOState(GL_DRAW_FRAMEBUFFER); static GLfloat lastClearColor[4] = {-1.0f, -1.0f, -1.0f, -1.0f}; diff --git a/MG/MG_GL/Implementations/GL/Framebuffer/GL_Framebuffer.cpp b/MG/MG_GL/Implementations/GL/Framebuffer/GL_Framebuffer.cpp index 7a4945bc..562c03cc 100644 --- a/MG/MG_GL/Implementations/GL/Framebuffer/GL_Framebuffer.cpp +++ b/MG/MG_GL/Implementations/GL/Framebuffer/GL_Framebuffer.cpp @@ -45,6 +45,7 @@ namespace MG_GL::GL { GLenum result = MG_State::AttachTexture2DToFramebuffer( target, attachment, textarget, texture, level ); + if (result == GL_NO_ERROR) return; MG_State::SetError(result); MG_Util::Debug::LogE("Texture attachment failed: %s", MG_Util::Debug::GLEnumToString(result)); diff --git a/MG/MG_UTIL/Debug/Debug.cpp b/MG/MG_UTIL/Debug/Debug.cpp index 7352c2ea..5add9b7e 100644 --- a/MG/MG_UTIL/Debug/Debug.cpp +++ b/MG/MG_UTIL/Debug/Debug.cpp @@ -1212,6 +1212,9 @@ void Log##name(const char* format, ...) { \ CASE(GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT) CASE(GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS) CASE(GL_FRAMEBUFFER_UNSUPPORTED) + CASE(GL_COLOR_ATTACHMENT0) + CASE(GL_DEPTH_ATTACHMENT) + CASE(GL_STENCIL_ATTACHMENT) /* * Miscellaneous */