mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-09-12 14:18:31 +09:00
[Fix] (MG_Impl/GLImpl): refresh generated mipmap storage [skip ci]
This commit is contained in:
@@ -614,7 +614,9 @@ namespace MobileGL::MG_Backend::DirectVulkan {
|
|||||||
srcWidth, srcHeight, srcDepth);
|
srcWidth, srcHeight, srcDepth);
|
||||||
}
|
}
|
||||||
void GenerateMipmap(GLenum target) {
|
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");
|
MOBILEGL_ASSERT(MG_State::pGLContext, "DirectVulkan::GenerateMipmap called with null GL context");
|
||||||
pVulkanRenderer->GenerateMipmap(target);
|
pVulkanRenderer->GenerateMipmap(target);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -233,7 +233,7 @@ namespace MobileGL::MG_Impl::GLImpl {
|
|||||||
|
|
||||||
const SizeT bytesPerTexel = baseByteSize / baseTexelCount;
|
const SizeT bytesPerTexel = baseByteSize / baseTexelCount;
|
||||||
const Uint requiredLevelCount = ComputeFullMipmapLevelCount(baseTexelSize);
|
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 IntVec3 levelTexelSize = ComputeMipmapTexelSize(baseTexelSize, level);
|
||||||
const SizeT levelByteSize = bytesPerTexel * static_cast<SizeT>(levelTexelSize.x()) *
|
const SizeT levelByteSize = bytesPerTexel * static_cast<SizeT>(levelTexelSize.x()) *
|
||||||
static_cast<SizeT>(levelTexelSize.y()) *
|
static_cast<SizeT>(levelTexelSize.y()) *
|
||||||
@@ -244,6 +244,12 @@ namespace MobileGL::MG_Impl::GLImpl {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EnsureGeneratedMipmapStorageAllocated(MG_State::GLState::TextureObjectMipmap& texture) {
|
||||||
|
for (const TextureUploadTarget uploadTarget : texture.GetUploadTargets()) {
|
||||||
|
EnsureGeneratedMipmapStorageAllocated(texture, uploadTarget);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Bool IsMultisampleTextureTarget(TextureTarget target) {
|
Bool IsMultisampleTextureTarget(TextureTarget target) {
|
||||||
return target == TextureTarget::Texture2DMultisample ||
|
return target == TextureTarget::Texture2DMultisample ||
|
||||||
target == TextureTarget::Texture2DMultisampleArray;
|
target == TextureTarget::Texture2DMultisampleArray;
|
||||||
@@ -3043,6 +3049,7 @@ namespace MobileGL::MG_Impl::GLImpl {
|
|||||||
if (textureObject) {
|
if (textureObject) {
|
||||||
auto* mipmapTexture = dynamic_cast<MG_State::GLState::TextureObjectMipmap*>(textureObject.get());
|
auto* mipmapTexture = dynamic_cast<MG_State::GLState::TextureObjectMipmap*>(textureObject.get());
|
||||||
MOBILEGL_ASSERT(mipmapTexture != nullptr, "GenerateMipmap requires mipmap texture storage.");
|
MOBILEGL_ASSERT(mipmapTexture != nullptr, "GenerateMipmap requires mipmap texture storage.");
|
||||||
|
EnsureGeneratedMipmapStorageAllocated(*mipmapTexture);
|
||||||
}
|
}
|
||||||
GenerateMipmap_Backend(target);
|
GenerateMipmap_Backend(target);
|
||||||
}
|
}
|
||||||
@@ -3053,7 +3060,13 @@ namespace MobileGL::MG_Impl::GLImpl {
|
|||||||
auto* mipmapTexture = dynamic_cast<MG_State::GLState::TextureObjectMipmap*>(textureObject.get());
|
auto* mipmapTexture = dynamic_cast<MG_State::GLState::TextureObjectMipmap*>(textureObject.get());
|
||||||
MOBILEGL_ASSERT(mipmapTexture != nullptr, "GenerateTextureMipmap requires mipmap texture storage.");
|
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) {
|
void GetTexImage(GLenum target, GLint level, GLenum format, GLenum type, GLvoid* pixels) {
|
||||||
|
|||||||
Reference in New Issue
Block a user