[Feat] (MG_State/TextureState): Implement TextureObjectBase::IsComplete.

This commit is contained in:
BZLZHH
2025-10-02 20:22:12 +08:00
parent ee971306ca
commit 776e1d99cf
2 changed files with 18 additions and 0 deletions
@@ -34,6 +34,22 @@ namespace MobileGL {
return m_mipmaps;
}
Bool TextureObjectBase::IsComplete() const {
if (m_internalFormat == TextureInternalFormat::Unknown) {
return false;
}
if (m_mipmaps.empty()) {
return false;
}
for (const auto& level : m_mipmaps) {
if (level.size.x() <= 0 || level.size.y() <= 0 || level.size.z() <= 0) {
return false;
}
}
// TODO: add more completeness checks based on texture type and mipmap levels
return true;
}
MipmapLevelInternal& TextureObjectBase::GetMipmap(Int index) {
if (index > m_mipmaps.size()) {
// fallback to the last mipmap
@@ -210,6 +210,7 @@ namespace MobileGL {
virtual const Vector<MipmapLevelInternal>& GetMipmaps() const = 0;
virtual MipmapLevelInternal& GetMipmap(Int index) = 0;
virtual void SetInternalFormat(TextureInternalFormat format) = 0;
virtual Bool IsComplete() const = 0;
};
class TextureObjectBase : public ITextureObject {
@@ -225,6 +226,7 @@ namespace MobileGL {
const Vector<MipmapLevelInternal>& GetMipmaps() const override;
MipmapLevelInternal& GetMipmap(Int index) override;
void SetInternalFormat(TextureInternalFormat format) override;
Bool IsComplete() const override;
protected:
virtual void SetMipmapImpl(const MipmapLevelInput& level) = 0;