[Fix] (MG_State/Texture): properly implement GetBaseSize() and IsComplete() for cubemap

This commit is contained in:
2025-11-27 15:02:22 +08:00
parent e244974928
commit d1f5aff440
3 changed files with 33 additions and 1 deletions
@@ -148,7 +148,7 @@ namespace MobileGL {
return false;
}
for (size_t i = 0; i < levelCount; ++i) {
for (SizeT i = 0; i < levelCount; ++i) {
const auto& levelSize = m_textureStorage.GetTexelSize(0, i);
if (levelSize.x() <= 0 || levelSize.y() <= 0 || levelSize.z() <= 0) {
return false;
@@ -54,6 +54,35 @@ namespace MobileGL {
"Invalid TextureUploadTarget!");
return (Uint)target - (Uint)TextureUploadTarget::CubeMapPositiveX;
}
IntVec3 TextureObject2DCube::GetBaseSize() const {
if (m_textureStorage.GetLevelCount() == 0) {
return {0, 0, 0};
}
return m_textureStorage.GetTexelSize(0, 0);
}
Bool TextureObject2DCube::IsComplete() const {
if (!TextureObjectBase::IsComplete())
return false;
SizeT levelCount = m_textureStorage.GetLevelCount();
if (levelCount == 0) {
return false;
}
for (SizeT t = 0; t < 6; ++t) {
for (SizeT i = 0; i < levelCount; ++i) {
const auto &levelSize = m_textureStorage.GetTexelSize(t, i);
if (levelSize.x() <= 0 || levelSize.y() <= 0 || levelSize.z() <= 0) {
return false;
}
}
}
// TODO: add more completeness checks based on texture type and mipmap levels
return true;
}
}
}
}
@@ -20,6 +20,9 @@ namespace MobileGL {
void* MapMipmapData(TextureUploadTarget uploadTarget, Uint mipmapLevel) override;
void MarkStorageDirty(TextureUploadTarget uploadTarget, Uint mipmapLevel, bool dirty) override;
bool IsStorageDirty(TextureUploadTarget uploadTarget, Uint mipmapLevel) const override;
IntVec3 GetBaseSize() const override;
Bool IsComplete() const override;
protected:
Uint GetIndexOfTextureUploadTarget(TextureUploadTarget target) const override;
TextureStorage<6> m_textureStorage;