mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-09-07 19:58:32 +09:00
[Feat] (MG_State/TextureState): Stubs for unimplemented texture types.
This commit is contained in:
@@ -104,27 +104,32 @@ namespace MobileGL {
|
||||
return m_textureStorage.GetLevelCount();
|
||||
}
|
||||
|
||||
const IntVec3 TextureObjectWithOneMipmap::GetMipmapTexelSize(TextureUploadTarget target, Uint mipmapLevel) const {
|
||||
const IntVec3 TextureObjectWithOneMipmap::GetMipmapTexelSize(TextureUploadTarget target,
|
||||
Uint mipmapLevel) const {
|
||||
return m_textureStorage.GetTexelSize(GetIndexOfTextureUploadTarget(target), mipmapLevel);
|
||||
}
|
||||
|
||||
const SizeT TextureObjectWithOneMipmap::GetMipmapByteSize(TextureUploadTarget target, Uint mipmapLevel) const {
|
||||
const SizeT TextureObjectWithOneMipmap::GetMipmapByteSize(TextureUploadTarget target,
|
||||
Uint mipmapLevel) const {
|
||||
return m_textureStorage.GetByteSize(GetIndexOfTextureUploadTarget(target), mipmapLevel);
|
||||
}
|
||||
|
||||
void TextureObjectWithOneMipmap::AllocateStorage(TextureUploadTarget uploadTarget, Uint mipmapLevel,
|
||||
MipmapInput input) {
|
||||
MipmapInput input) {
|
||||
m_textureStorage.AllocateLevel(GetIndexOfTextureUploadTarget(uploadTarget), mipmapLevel, input);
|
||||
}
|
||||
|
||||
void TextureObjectWithOneMipmap::UpdateMipmapSubData(TextureUploadTarget uploadTarget, Uint mipmapLevel,
|
||||
DataPtr input) {
|
||||
DataPtr input) {
|
||||
m_textureStorage.UpdateSubData(GetIndexOfTextureUploadTarget(uploadTarget), mipmapLevel, input);
|
||||
}
|
||||
|
||||
void* TextureObjectWithOneMipmap::MapMipmapData(TextureUploadTarget uploadTarget, Uint mipmapLevel) {
|
||||
return m_textureStorage.MapData(GetIndexOfTextureUploadTarget(uploadTarget), mipmapLevel);
|
||||
}
|
||||
|
||||
void TextureObjectWithOneMipmap::MarkStorageDirty(TextureUploadTarget uploadTarget, Uint mipmapLevel, bool dirty) {
|
||||
void TextureObjectWithOneMipmap::MarkStorageDirty(TextureUploadTarget uploadTarget, Uint mipmapLevel,
|
||||
bool dirty) {
|
||||
m_textureStorage.MarkDirty(GetIndexOfTextureUploadTarget(uploadTarget), mipmapLevel, dirty);
|
||||
}
|
||||
|
||||
@@ -140,8 +145,7 @@ namespace MobileGL {
|
||||
}
|
||||
|
||||
Bool TextureObjectWithOneMipmap::IsComplete() const {
|
||||
if (!TextureObjectBase::IsComplete())
|
||||
return false;
|
||||
if (!TextureObjectBase::IsComplete()) return false;
|
||||
|
||||
SizeT levelCount = m_textureStorage.GetLevelCount();
|
||||
if (levelCount == 0) {
|
||||
|
||||
@@ -83,7 +83,7 @@ namespace MobileGL {
|
||||
UintVec2 m_levelRange = {0, 1000};
|
||||
};
|
||||
|
||||
class TextureObjectWithOneMipmap: public TextureObjectBase {
|
||||
class TextureObjectWithOneMipmap : public TextureObjectBase {
|
||||
public:
|
||||
TextureObjectWithOneMipmap(TextureTarget target, Uint externalIndex): TextureObjectBase(target, externalIndex) {}
|
||||
virtual ~TextureObjectWithOneMipmap() = default;
|
||||
@@ -99,6 +99,7 @@ namespace MobileGL {
|
||||
|
||||
IntVec3 GetBaseSize() const override;
|
||||
Bool IsComplete() const override;
|
||||
|
||||
protected:
|
||||
TextureStorage<1> m_textureStorage;
|
||||
};
|
||||
|
||||
@@ -7,10 +7,11 @@ namespace MobileGL {
|
||||
: TextureObjectWithOneMipmap(TextureTarget::Texture1D, externalIndex) {}
|
||||
|
||||
Uint TextureObject1D::GetIndexOfTextureUploadTarget(TextureUploadTarget target) const {
|
||||
MOBILEGL_ASSERT(target == TextureUploadTarget::Texture1D || target == TextureUploadTarget::ProxyTexture1D,
|
||||
MOBILEGL_ASSERT(target == TextureUploadTarget::Texture1D ||
|
||||
target == TextureUploadTarget::ProxyTexture1D,
|
||||
"Invalid TextureUploadTarget!");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace GLState
|
||||
} // namespace MG_State
|
||||
} // namespace MobileGL
|
||||
@@ -7,13 +7,12 @@ namespace MobileGL {
|
||||
class TextureObject1D : public TextureObjectWithOneMipmap {
|
||||
public:
|
||||
explicit TextureObject1D(Uint externalIndex);
|
||||
const Vector<TextureUploadTarget>& GetUploadTargets() const override {
|
||||
return m_uploadTargets;
|
||||
}
|
||||
const Vector<TextureUploadTarget>& GetUploadTargets() const override { return m_uploadTargets; }
|
||||
|
||||
protected:
|
||||
Uint GetIndexOfTextureUploadTarget(TextureUploadTarget target) const override;
|
||||
const Vector<TextureUploadTarget> m_uploadTargets {TextureUploadTarget::Texture1D};
|
||||
const Vector<TextureUploadTarget> m_uploadTargets{TextureUploadTarget::Texture1D};
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace GLState
|
||||
} // namespace MG_State
|
||||
} // namespace MobileGL
|
||||
|
||||
@@ -7,10 +7,11 @@ namespace MobileGL {
|
||||
: TextureObjectWithOneMipmap(TextureTarget::Texture2D, externalIndex) {}
|
||||
|
||||
Uint TextureObject2D::GetIndexOfTextureUploadTarget(TextureUploadTarget target) const {
|
||||
MOBILEGL_ASSERT(target == TextureUploadTarget::Texture2D || target == TextureUploadTarget::ProxyTexture2D,
|
||||
MOBILEGL_ASSERT(target == TextureUploadTarget::Texture2D ||
|
||||
target == TextureUploadTarget::ProxyTexture2D,
|
||||
"Invalid TextureUploadTarget!");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace GLState
|
||||
} // namespace MG_State
|
||||
} // namespace MobileGL
|
||||
@@ -7,13 +7,12 @@ namespace MobileGL {
|
||||
class TextureObject2D : public TextureObjectWithOneMipmap {
|
||||
public:
|
||||
explicit TextureObject2D(Uint externalIndex);
|
||||
const Vector<TextureUploadTarget>& GetUploadTargets() const override {
|
||||
return m_uploadTargets;
|
||||
}
|
||||
const Vector<TextureUploadTarget>& GetUploadTargets() const override { return m_uploadTargets; }
|
||||
|
||||
protected:
|
||||
Uint GetIndexOfTextureUploadTarget(TextureUploadTarget target) const override;
|
||||
const Vector<TextureUploadTarget> m_uploadTargets {TextureUploadTarget::Texture2D};
|
||||
const Vector<TextureUploadTarget> m_uploadTargets{TextureUploadTarget::Texture2D};
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace GLState
|
||||
} // namespace MG_State
|
||||
} // namespace MobileGL
|
||||
|
||||
@@ -12,45 +12,39 @@ namespace MobileGL {
|
||||
return m_textureStorage.GetLevelCount();
|
||||
}
|
||||
|
||||
const IntVec3 TextureObject2DCube::GetMipmapTexelSize(TextureUploadTarget target,
|
||||
Uint mipmapLevel) const {
|
||||
const IntVec3 TextureObject2DCube::GetMipmapTexelSize(TextureUploadTarget target, Uint mipmapLevel) const {
|
||||
return m_textureStorage.GetTexelSize(GetIndexOfTextureUploadTarget(target), mipmapLevel);
|
||||
}
|
||||
|
||||
const SizeT TextureObject2DCube::GetMipmapByteSize(TextureUploadTarget target,
|
||||
Uint mipmapLevel) const {
|
||||
const SizeT TextureObject2DCube::GetMipmapByteSize(TextureUploadTarget target, Uint mipmapLevel) const {
|
||||
return m_textureStorage.GetByteSize(GetIndexOfTextureUploadTarget(target), mipmapLevel);
|
||||
}
|
||||
|
||||
void
|
||||
TextureObject2DCube::AllocateStorage(TextureUploadTarget uploadTarget, Uint mipmapLevel,
|
||||
MipmapInput input) {
|
||||
void TextureObject2DCube::AllocateStorage(TextureUploadTarget uploadTarget, Uint mipmapLevel,
|
||||
MipmapInput input) {
|
||||
m_textureStorage.AllocateLevel(GetIndexOfTextureUploadTarget(uploadTarget), mipmapLevel, input);
|
||||
}
|
||||
|
||||
void TextureObject2DCube::UpdateMipmapSubData(TextureUploadTarget uploadTarget,
|
||||
Uint mipmapLevel, DataPtr input) {
|
||||
void TextureObject2DCube::UpdateMipmapSubData(TextureUploadTarget uploadTarget, Uint mipmapLevel,
|
||||
DataPtr input) {
|
||||
m_textureStorage.UpdateSubData(GetIndexOfTextureUploadTarget(uploadTarget), mipmapLevel, input);
|
||||
}
|
||||
|
||||
void *
|
||||
TextureObject2DCube::MapMipmapData(TextureUploadTarget uploadTarget, Uint mipmapLevel) {
|
||||
void* TextureObject2DCube::MapMipmapData(TextureUploadTarget uploadTarget, Uint mipmapLevel) {
|
||||
return m_textureStorage.MapData(GetIndexOfTextureUploadTarget(uploadTarget), mipmapLevel);
|
||||
}
|
||||
|
||||
void TextureObject2DCube::MarkStorageDirty(TextureUploadTarget uploadTarget,
|
||||
Uint mipmapLevel, bool dirty) {
|
||||
void TextureObject2DCube::MarkStorageDirty(TextureUploadTarget uploadTarget, Uint mipmapLevel, bool dirty) {
|
||||
m_textureStorage.MarkDirty(GetIndexOfTextureUploadTarget(uploadTarget), mipmapLevel, dirty);
|
||||
}
|
||||
|
||||
bool TextureObject2DCube::IsStorageDirty(TextureUploadTarget uploadTarget,
|
||||
Uint mipmapLevel) const {
|
||||
bool TextureObject2DCube::IsStorageDirty(TextureUploadTarget uploadTarget, Uint mipmapLevel) const {
|
||||
return m_textureStorage.IsDirty(GetIndexOfTextureUploadTarget(uploadTarget), mipmapLevel);
|
||||
}
|
||||
|
||||
Uint
|
||||
TextureObject2DCube::GetIndexOfTextureUploadTarget(TextureUploadTarget target) const {
|
||||
MOBILEGL_ASSERT(TextureUploadTarget::CubeMapPositiveX <= target && target <= TextureUploadTarget::ProxyCubeMap,
|
||||
Uint TextureObject2DCube::GetIndexOfTextureUploadTarget(TextureUploadTarget target) const {
|
||||
MOBILEGL_ASSERT(TextureUploadTarget::CubeMapPositiveX <= target &&
|
||||
target <= TextureUploadTarget::ProxyCubeMap,
|
||||
"Invalid TextureUploadTarget!");
|
||||
return (Uint)target - (Uint)TextureUploadTarget::CubeMapPositiveX;
|
||||
}
|
||||
@@ -63,8 +57,7 @@ namespace MobileGL {
|
||||
}
|
||||
|
||||
Bool TextureObject2DCube::IsComplete() const {
|
||||
if (!TextureObjectBase::IsComplete())
|
||||
return false;
|
||||
if (!TextureObjectBase::IsComplete()) return false;
|
||||
|
||||
SizeT levelCount = m_textureStorage.GetLevelCount();
|
||||
if (levelCount == 0) {
|
||||
@@ -73,7 +66,7 @@ namespace MobileGL {
|
||||
|
||||
for (SizeT t = 0; t < 6; ++t) {
|
||||
for (SizeT i = 0; i < levelCount; ++i) {
|
||||
const auto &levelSize = m_textureStorage.GetTexelSize(t, i);
|
||||
const auto& levelSize = m_textureStorage.GetTexelSize(t, i);
|
||||
if (levelSize.x() <= 0 || levelSize.y() <= 0 || levelSize.z() <= 0) {
|
||||
return false;
|
||||
}
|
||||
@@ -83,6 +76,6 @@ namespace MobileGL {
|
||||
// TODO: add more completeness checks based on texture type and mipmap levels
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace GLState
|
||||
} // namespace MG_State
|
||||
} // namespace MobileGL
|
||||
|
||||
@@ -8,9 +8,7 @@ namespace MobileGL {
|
||||
public:
|
||||
explicit TextureObject2DCube(Uint externalIndex);
|
||||
|
||||
const Vector<TextureUploadTarget>& GetUploadTargets() const override {
|
||||
return m_uploadTargets;
|
||||
}
|
||||
const Vector<TextureUploadTarget>& GetUploadTargets() const override { return m_uploadTargets; }
|
||||
|
||||
Uint GetMipmapLevelCount() const override;
|
||||
const IntVec3 GetMipmapTexelSize(TextureUploadTarget target, Uint mipmapLevel) const override;
|
||||
@@ -23,18 +21,16 @@ namespace MobileGL {
|
||||
|
||||
IntVec3 GetBaseSize() const override;
|
||||
Bool IsComplete() const override;
|
||||
|
||||
protected:
|
||||
Uint GetIndexOfTextureUploadTarget(TextureUploadTarget target) const override;
|
||||
TextureStorage<6> m_textureStorage;
|
||||
const Vector<TextureUploadTarget> m_uploadTargets {
|
||||
TextureUploadTarget::CubeMapPositiveX,
|
||||
TextureUploadTarget::CubeMapNegativeX,
|
||||
TextureUploadTarget::CubeMapPositiveY,
|
||||
TextureUploadTarget::CubeMapNegativeY,
|
||||
TextureUploadTarget::CubeMapPositiveZ,
|
||||
TextureUploadTarget::CubeMapNegativeZ,
|
||||
const Vector<TextureUploadTarget> m_uploadTargets{
|
||||
TextureUploadTarget::CubeMapPositiveX, TextureUploadTarget::CubeMapNegativeX,
|
||||
TextureUploadTarget::CubeMapPositiveY, TextureUploadTarget::CubeMapNegativeY,
|
||||
TextureUploadTarget::CubeMapPositiveZ, TextureUploadTarget::CubeMapNegativeZ,
|
||||
};
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace GLState
|
||||
} // namespace MG_State
|
||||
} // namespace MobileGL
|
||||
|
||||
@@ -7,10 +7,11 @@ namespace MobileGL {
|
||||
: TextureObjectWithOneMipmap(TextureTarget::Texture3D, externalIndex) {}
|
||||
|
||||
Uint TextureObject3D::GetIndexOfTextureUploadTarget(TextureUploadTarget target) const {
|
||||
MOBILEGL_ASSERT(target == TextureUploadTarget::Texture3D || target == TextureUploadTarget::ProxyTexture3D,
|
||||
MOBILEGL_ASSERT(target == TextureUploadTarget::Texture3D ||
|
||||
target == TextureUploadTarget::ProxyTexture3D,
|
||||
"Invalid TextureUploadTarget!");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace GLState
|
||||
} // namespace MG_State
|
||||
} // namespace MobileGL
|
||||
@@ -7,13 +7,12 @@ namespace MobileGL {
|
||||
class TextureObject3D : public TextureObjectWithOneMipmap {
|
||||
public:
|
||||
explicit TextureObject3D(Uint externalIndex);
|
||||
const Vector<TextureUploadTarget>& GetUploadTargets() const override {
|
||||
return m_uploadTargets;
|
||||
}
|
||||
const Vector<TextureUploadTarget>& GetUploadTargets() const override { return m_uploadTargets; }
|
||||
|
||||
protected:
|
||||
Uint GetIndexOfTextureUploadTarget(TextureUploadTarget target) const override;
|
||||
const Vector<TextureUploadTarget> m_uploadTargets {TextureUploadTarget::Texture3D};
|
||||
const Vector<TextureUploadTarget> m_uploadTargets{TextureUploadTarget::Texture3D};
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace GLState
|
||||
} // namespace MG_State
|
||||
} // namespace MobileGL
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
#pragma once
|
||||
#include "MG_State/GLState/TextureState/TextureEnum.h"
|
||||
#include "TextureObject.h"
|
||||
|
||||
namespace MobileGL {
|
||||
namespace MG_State {
|
||||
namespace GLState {
|
||||
/* These texture types are not yet implemented:
|
||||
* TextureRectangle,
|
||||
* Texture2DMultisample,
|
||||
* TextureBuffer,
|
||||
* Texture1DArray,
|
||||
* Texture2DArray,
|
||||
* TextureCubeMapArray,
|
||||
* Texture2DMultisampleArray
|
||||
*/
|
||||
#define STUB_TEXTURE_OBJECT_CLASS_DEFINITION(className, texTarget, uploadTargets) \
|
||||
class className : public TextureObjectWithOneMipmap { \
|
||||
public: \
|
||||
explicit className(Uint externalIndex) : TextureObjectWithOneMipmap(texTarget, externalIndex) {} \
|
||||
const Vector<TextureUploadTarget>& GetUploadTargets() const override { return m_uploadTargets; } \
|
||||
\
|
||||
protected: \
|
||||
Uint GetIndexOfTextureUploadTarget(TextureUploadTarget target) const override { return 0; } \
|
||||
const Vector<TextureUploadTarget> m_uploadTargets = uploadTargets; \
|
||||
};
|
||||
|
||||
STUB_TEXTURE_OBJECT_CLASS_DEFINITION(TextureObjectRectangle, TextureTarget::TextureRectangle,
|
||||
{TextureUploadTarget::TextureRectangle});
|
||||
|
||||
STUB_TEXTURE_OBJECT_CLASS_DEFINITION(TextureObject2DMultisample, TextureTarget::Texture2DMultisample,
|
||||
{TextureUploadTarget::Texture2DMultisample});
|
||||
|
||||
STUB_TEXTURE_OBJECT_CLASS_DEFINITION(TextureObjectBuffer, TextureTarget::TextureBuffer,
|
||||
{TextureUploadTarget::Unknown});
|
||||
|
||||
STUB_TEXTURE_OBJECT_CLASS_DEFINITION(TextureObject1DArray, TextureTarget::Texture1DArray,
|
||||
{TextureUploadTarget::Texture1DArray});
|
||||
|
||||
STUB_TEXTURE_OBJECT_CLASS_DEFINITION(TextureObject2DArray, TextureTarget::Texture2DArray,
|
||||
{TextureUploadTarget::Texture2D});
|
||||
|
||||
STUB_TEXTURE_OBJECT_CLASS_DEFINITION(TextureObjectCubeMapArray, TextureTarget::TextureCubeMapArray,
|
||||
{TextureUploadTarget::CubeMapArray});
|
||||
|
||||
STUB_TEXTURE_OBJECT_CLASS_DEFINITION(TextureObject2DMultisampleArray,
|
||||
TextureTarget::Texture2DMultisampleArray,
|
||||
{TextureUploadTarget::Texture2DMultisampleArray});
|
||||
#undef STUB_TEXTURE_OBJECT_CLASS_DEFINITION
|
||||
|
||||
} // namespace GLState
|
||||
} // namespace MG_State
|
||||
} // namespace MobileGL
|
||||
@@ -1,10 +1,12 @@
|
||||
#include "TextureState.h"
|
||||
#include "MG_State/GLState/TextureState/TextureObject.h"
|
||||
#include "MG_State/GLState/TextureState/TextureObject1D.h"
|
||||
#include "MG_State/GLState/TextureState/TextureObject2D.h"
|
||||
#include "MG_State/GLState/TextureState/TextureObject3D.h"
|
||||
#include "MG_Util/Types.h"
|
||||
#include "Defines.h"
|
||||
#include "TextureEnum.h"
|
||||
#include "TextureObject.h"
|
||||
#include "TextureObject1D.h"
|
||||
#include "TextureObject2D.h"
|
||||
#include "TextureObject3D.h"
|
||||
#include "TextureObject2DCube.h"
|
||||
#include "TextureObjectStubs.h"
|
||||
|
||||
namespace MobileGL {
|
||||
namespace MG_State {
|
||||
@@ -44,8 +46,31 @@ namespace MobileGL {
|
||||
case TextureTarget::Texture3D:
|
||||
textureObject = MakeShared<TextureObject3D>(index);
|
||||
break;
|
||||
|
||||
// These texture types are stubbed:
|
||||
case TextureTarget::TextureRectangle:
|
||||
textureObject = MakeShared<TextureObjectRectangle>(index);
|
||||
break;
|
||||
case TextureTarget::Texture2DMultisample:
|
||||
textureObject = MakeShared<TextureObject2DMultisample>(index);
|
||||
break;
|
||||
case TextureTarget::TextureBuffer:
|
||||
textureObject = MakeShared<TextureObjectBuffer>(index);
|
||||
break;
|
||||
case TextureTarget::Texture1DArray:
|
||||
textureObject = MakeShared<TextureObject1DArray>(index);
|
||||
break;
|
||||
case TextureTarget::Texture2DArray:
|
||||
textureObject = MakeShared<TextureObject2DArray>(index);
|
||||
break;
|
||||
case TextureTarget::TextureCubeMapArray:
|
||||
textureObject = MakeShared<TextureObjectCubeMapArray>(index);
|
||||
break;
|
||||
case TextureTarget::Texture2DMultisampleArray:
|
||||
textureObject = MakeShared<TextureObject2DMultisampleArray>(index);
|
||||
break;
|
||||
default:
|
||||
// TODO: implement more texture types
|
||||
MOBILEGL_ASSERT(false, "Unimplemented texture type when creating texture object!: %d", (int)target);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -72,9 +97,8 @@ namespace MobileGL {
|
||||
}
|
||||
|
||||
TextureUnit& TextureState::GetUnitObject(Int unit) {
|
||||
if (unit < 0 || unit >= MAX_TEXTURE_IMAGE_UNITS) {
|
||||
THROW_EXCEPTION("Active texture unit is out of range");
|
||||
}
|
||||
MOBILEGL_ASSERT(unit >= 0 && unit < MAX_TEXTURE_IMAGE_UNITS, "Texture unit is out of range: %d > %d",
|
||||
unit, MAX_TEXTURE_IMAGE_UNITS - 1);
|
||||
return m_textureUnits[unit];
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#include "TextureUnit.h"
|
||||
#include "MG_Util/Types.h"
|
||||
|
||||
namespace MobileGL {
|
||||
namespace MG_State {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
#pragma once
|
||||
#include <Includes.h>
|
||||
#include "MG_State/GLState/SamplerState/SamplerObject.h"
|
||||
#include "MG_Util/Types.h"
|
||||
#include <MG_State/GLState/SamplerState/SamplerObject.h>
|
||||
#include "TextureObject.h"
|
||||
|
||||
namespace MobileGL {
|
||||
|
||||
Reference in New Issue
Block a user