mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-09-11 13:48:30 +09:00
[Feat] (MG_State/Texture): separate mipmap from TextureObjectBase
This commit is contained in:
@@ -52,7 +52,9 @@ namespace MobileGL {
|
||||
IntVec3 FramebufferAttachment::GetSize() const {
|
||||
if (IsTexture()) {
|
||||
// TODO: get correct upload target
|
||||
return m_texture->GetMipmapTexelSize(TextureUploadTarget::Texture2D, m_textureLevel);
|
||||
MOBILEGL_ASSERT(nullptr != dynamic_cast<MG_State::GLState::TextureMipmapObject*>(m_texture.get()), "Texture object here should always be an object with mipmap");
|
||||
auto textureMipmapObject = static_cast<MG_State::GLState::TextureMipmapObject*>(m_texture.get());
|
||||
return textureMipmapObject->GetMipmapTexelSize(TextureUploadTarget::Texture2D, m_textureLevel);
|
||||
} else if (IsRenderbuffer()) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
@@ -49,6 +49,11 @@ namespace MobileGL {
|
||||
Unknown = -1
|
||||
};
|
||||
|
||||
enum class TextureStorageType {
|
||||
Mipmap,
|
||||
Buffer
|
||||
};
|
||||
|
||||
enum class TextureInputFormat {
|
||||
Red,
|
||||
RG,
|
||||
|
||||
@@ -14,14 +14,7 @@ namespace MobileGL {
|
||||
using TargetEnum = TextureTarget;
|
||||
virtual ~ITextureObject() = default;
|
||||
|
||||
virtual Uint GetMipmapLevelCount() const = 0;
|
||||
virtual const IntVec3 GetMipmapTexelSize(TextureUploadTarget target, Uint mipmapLevel) const = 0;
|
||||
virtual const SizeT GetMipmapByteSize(TextureUploadTarget target, Uint mipmapLevel) const = 0;
|
||||
virtual void AllocateStorage(TextureUploadTarget uploadTarget, Uint mipmapLevel, MipmapInput input) = 0;
|
||||
virtual void UpdateMipmapSubData(TextureUploadTarget uploadTarget, Uint mipmapLevel, DataPtr input) = 0;
|
||||
virtual void* MapMipmapData(TextureUploadTarget uploadTarget, Uint mipmapLevel) = 0;
|
||||
virtual void MarkStorageDirty(TextureUploadTarget uploadTarget, Uint mipmapLevel, bool dirty) = 0;
|
||||
virtual bool IsStorageDirty(TextureUploadTarget uploadTarget, Uint mipmapLevel) const = 0;
|
||||
virtual TextureStorageType GetStorageType() const = 0;
|
||||
|
||||
virtual TextureInternalFormat GetFormat() const = 0;
|
||||
virtual TextureTarget GetTarget() const = 0;
|
||||
@@ -49,17 +42,6 @@ namespace MobileGL {
|
||||
TextureObjectBase(TextureTarget target, Uint externalIndex);
|
||||
virtual ~TextureObjectBase() = default;
|
||||
|
||||
// Mipmap ops
|
||||
// Uint GetMipmapLevelCount() const = 0;
|
||||
// const IntVec3 GetMipmapTexelSize(TextureUploadTarget target, Uint mipmapLevel) const =
|
||||
// 0; const SizeT GetMipmapByteSize(TextureUploadTarget target, Uint mipmapLevel) const =
|
||||
// 0; void AllocateStorage(TextureUploadTarget uploadTarget, Uint mipmapLevel,
|
||||
// MipmapInput input) = 0; void UpdateMipmapSubData(TextureUploadTarget uploadTarget,
|
||||
// Uint mipmapLevel, DataPtr input) = 0; void* MapMipmapData(TextureUploadTarget
|
||||
// uploadTarget, Uint mipmapLevel) = 0; void MarkStorageDirty(TextureUploadTarget
|
||||
// uploadTarget, Uint mipmapLevel, bool dirty) = 0; bool
|
||||
// IsStorageDirty(TextureUploadTarget uploadTarget, Uint mipmapLevel) const = 0;
|
||||
|
||||
TextureInternalFormat GetFormat() const override;
|
||||
TextureTarget GetTarget() const override;
|
||||
IntVec3 GetBaseSize() const override;
|
||||
@@ -87,10 +69,26 @@ namespace MobileGL {
|
||||
UintVec2 m_levelRange = {0, 1000};
|
||||
};
|
||||
|
||||
class TextureObjectWithOneMipmap : public TextureObjectBase {
|
||||
class TextureMipmapObject : public TextureObjectBase {
|
||||
public:
|
||||
TextureMipmapObject(TextureTarget target, Uint externalIndex): TextureObjectBase(target, externalIndex) {}
|
||||
|
||||
TextureStorageType GetStorageType() const override { return TextureStorageType::Mipmap; }
|
||||
|
||||
virtual Uint GetMipmapLevelCount() const = 0;
|
||||
virtual const IntVec3 GetMipmapTexelSize(TextureUploadTarget target, Uint mipmapLevel) const = 0;
|
||||
virtual const SizeT GetMipmapByteSize(TextureUploadTarget target, Uint mipmapLevel) const = 0;
|
||||
virtual void AllocateStorage(TextureUploadTarget uploadTarget, Uint mipmapLevel, MipmapInput input) = 0;
|
||||
virtual void UpdateMipmapSubData(TextureUploadTarget uploadTarget, Uint mipmapLevel, DataPtr input) = 0;
|
||||
virtual void* MapMipmapData(TextureUploadTarget uploadTarget, Uint mipmapLevel) = 0;
|
||||
virtual void MarkStorageDirty(TextureUploadTarget uploadTarget, Uint mipmapLevel, bool dirty) = 0;
|
||||
virtual bool IsStorageDirty(TextureUploadTarget uploadTarget, Uint mipmapLevel) const = 0;
|
||||
};
|
||||
|
||||
class TextureObjectWithOneMipmap : public TextureMipmapObject {
|
||||
public:
|
||||
TextureObjectWithOneMipmap(TextureTarget target, Uint externalIndex)
|
||||
: TextureObjectBase(target, externalIndex) {}
|
||||
: TextureMipmapObject(target, externalIndex) {}
|
||||
virtual ~TextureObjectWithOneMipmap() = default;
|
||||
|
||||
Uint GetMipmapLevelCount() const override;
|
||||
|
||||
@@ -4,7 +4,7 @@ namespace MobileGL {
|
||||
namespace MG_State {
|
||||
namespace GLState {
|
||||
TextureObject2DCube::TextureObject2DCube(Uint externalIndex)
|
||||
: TextureObjectBase(TextureTarget::TextureCubeMap, externalIndex) {}
|
||||
: TextureMipmapObject(TextureTarget::TextureCubeMap, externalIndex) {}
|
||||
|
||||
Uint TextureObject2DCube::GetMipmapLevelCount() const {
|
||||
return m_textureStorage.GetLevelCount();
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
namespace MobileGL {
|
||||
namespace MG_State {
|
||||
namespace GLState {
|
||||
class TextureObject2DCube : public TextureObjectBase {
|
||||
class TextureObject2DCube : public TextureMipmapObject {
|
||||
public:
|
||||
explicit TextureObject2DCube(Uint externalIndex);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user