[Fix] (MG_Impl/GLImpl): refresh generated mipmap storage [skip ci]

This commit is contained in:
2026-07-02 19:22:39 +08:00
parent 91120d86ba
commit 4439162fea
2 changed files with 18 additions and 3 deletions
@@ -614,7 +614,9 @@ namespace MobileGL::MG_Backend::DirectVulkan {
srcWidth, srcHeight, srcDepth);
}
void GenerateMipmap(GLenum target) {
MOBILEGL_ASSERT(pVulkanRenderer, "DirectVulkan::GenerateMipmap called with null VulkanRenderer");
if (!pVulkanRenderer) {
return;
}
MOBILEGL_ASSERT(MG_State::pGLContext, "DirectVulkan::GenerateMipmap called with null GL context");
pVulkanRenderer->GenerateMipmap(target);
}
+15 -2
View File
@@ -233,7 +233,7 @@ namespace MobileGL::MG_Impl::GLImpl {
const SizeT bytesPerTexel = baseByteSize / baseTexelCount;
const Uint requiredLevelCount = ComputeFullMipmapLevelCount(baseTexelSize);
for (Uint level = existingLevelCount; level < requiredLevelCount; ++level) {
for (Uint level = 1; level < requiredLevelCount; ++level) {
const IntVec3 levelTexelSize = ComputeMipmapTexelSize(baseTexelSize, level);
const SizeT levelByteSize = bytesPerTexel * static_cast<SizeT>(levelTexelSize.x()) *
static_cast<SizeT>(levelTexelSize.y()) *
@@ -244,6 +244,12 @@ namespace MobileGL::MG_Impl::GLImpl {
return true;
}
void EnsureGeneratedMipmapStorageAllocated(MG_State::GLState::TextureObjectMipmap& texture) {
for (const TextureUploadTarget uploadTarget : texture.GetUploadTargets()) {
EnsureGeneratedMipmapStorageAllocated(texture, uploadTarget);
}
}
Bool IsMultisampleTextureTarget(TextureTarget target) {
return target == TextureTarget::Texture2DMultisample ||
target == TextureTarget::Texture2DMultisampleArray;
@@ -3043,6 +3049,7 @@ namespace MobileGL::MG_Impl::GLImpl {
if (textureObject) {
auto* mipmapTexture = dynamic_cast<MG_State::GLState::TextureObjectMipmap*>(textureObject.get());
MOBILEGL_ASSERT(mipmapTexture != nullptr, "GenerateMipmap requires mipmap texture storage.");
EnsureGeneratedMipmapStorageAllocated(*mipmapTexture);
}
GenerateMipmap_Backend(target);
}
@@ -3053,7 +3060,13 @@ namespace MobileGL::MG_Impl::GLImpl {
auto* mipmapTexture = dynamic_cast<MG_State::GLState::TextureObjectMipmap*>(textureObject.get());
MOBILEGL_ASSERT(mipmapTexture != nullptr, "GenerateTextureMipmap requires mipmap texture storage.");
}
WithTemporarilyBoundNamedTexture(textureObject, [&](GLenum target) { GenerateMipmap_Backend(target); });
WithTemporarilyBoundNamedTexture(textureObject, [&](GLenum target) {
if (textureObject) {
auto* mipmapTexture = dynamic_cast<MG_State::GLState::TextureObjectMipmap*>(textureObject.get());
EnsureGeneratedMipmapStorageAllocated(*mipmapTexture);
}
GenerateMipmap_Backend(target);
});
}
void GetTexImage(GLenum target, GLint level, GLenum format, GLenum type, GLvoid* pixels) {