mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-09-09 04:38:30 +09:00
[Fix] (MG_State/Texture): properly implement GetBaseSize() and IsComplete() for cubemap
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user