mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-09-11 21:58:31 +09:00
[Feat] (MG_State/Texture, MG_Impl/Texture): glTexBuffer (and implement TextureObjectBuffer accordingly)
This commit is contained in:
@@ -52,8 +52,8 @@ namespace MobileGL {
|
||||
IntVec3 FramebufferAttachment::GetSize() const {
|
||||
if (IsTexture()) {
|
||||
// TODO: get correct upload target
|
||||
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());
|
||||
MOBILEGL_ASSERT(nullptr != dynamic_cast<MG_State::GLState::TextureObjectMipmap*>(m_texture.get()), "Texture object here should always be an object with mipmap");
|
||||
auto textureMipmapObject = static_cast<MG_State::GLState::TextureObjectMipmap*>(m_texture.get());
|
||||
return textureMipmapObject->GetMipmapTexelSize(TextureUploadTarget::Texture2D, m_textureLevel);
|
||||
} else if (IsRenderbuffer()) {
|
||||
// TODO
|
||||
|
||||
@@ -38,6 +38,7 @@ namespace MobileGL {
|
||||
CubeMapNegativeY,
|
||||
CubeMapPositiveZ,
|
||||
CubeMapNegativeZ,
|
||||
TextureBuffer,
|
||||
ProxyCubeMap,
|
||||
CubeMapArray,
|
||||
ProxyCubeMapArray,
|
||||
|
||||
@@ -69,9 +69,9 @@ namespace MobileGL {
|
||||
UintVec2 m_levelRange = {0, 1000};
|
||||
};
|
||||
|
||||
class TextureMipmapObject : public TextureObjectBase {
|
||||
class TextureObjectMipmap : public TextureObjectBase {
|
||||
public:
|
||||
TextureMipmapObject(TextureTarget target, Uint externalIndex): TextureObjectBase(target, externalIndex) {}
|
||||
TextureObjectMipmap(TextureTarget target, Uint externalIndex): TextureObjectBase(target, externalIndex) {}
|
||||
|
||||
TextureStorageType GetStorageType() const override { return TextureStorageType::Mipmap; }
|
||||
|
||||
@@ -85,10 +85,10 @@ namespace MobileGL {
|
||||
virtual bool IsStorageDirty(TextureUploadTarget uploadTarget, Uint mipmapLevel) const = 0;
|
||||
};
|
||||
|
||||
class TextureObjectWithOneMipmap : public TextureMipmapObject {
|
||||
class TextureObjectWithOneMipmap : public TextureObjectMipmap {
|
||||
public:
|
||||
TextureObjectWithOneMipmap(TextureTarget target, Uint externalIndex)
|
||||
: TextureMipmapObject(target, externalIndex) {}
|
||||
: TextureObjectMipmap(target, externalIndex) {}
|
||||
virtual ~TextureObjectWithOneMipmap() = default;
|
||||
|
||||
Uint GetMipmapLevelCount() const override;
|
||||
|
||||
@@ -4,7 +4,7 @@ namespace MobileGL {
|
||||
namespace MG_State {
|
||||
namespace GLState {
|
||||
TextureObject2DCube::TextureObject2DCube(Uint externalIndex)
|
||||
: TextureMipmapObject(TextureTarget::TextureCubeMap, externalIndex) {}
|
||||
: TextureObjectMipmap(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 TextureMipmapObject {
|
||||
class TextureObject2DCube : public TextureObjectMipmap {
|
||||
public:
|
||||
explicit TextureObject2DCube(Uint externalIndex);
|
||||
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
#include "TextureObjectBuffer.h"
|
||||
|
||||
namespace MobileGL {
|
||||
namespace MG_State {
|
||||
namespace GLState {
|
||||
TextureObjectBuffer::TextureObjectBuffer(Uint externalIndex)
|
||||
: TextureObjectBase(TextureTarget::TextureBuffer, externalIndex) {}
|
||||
|
||||
Uint TextureObjectBuffer::GetIndexOfTextureUploadTarget(TextureUploadTarget target) const {
|
||||
MOBILEGL_ASSERT(target == TextureUploadTarget::TextureBuffer, "Invalid TextureUploadTarget!");
|
||||
return 0;
|
||||
}
|
||||
|
||||
BindingSlot<BufferObject>& TextureObjectBuffer::GetBufferBindingSlot(TextureUploadTarget target) {
|
||||
MOBILEGL_ASSERT(target == TextureUploadTarget::TextureBuffer, "Invalid TextureUploadTarget!");
|
||||
return m_bufferBindingSlot;
|
||||
}
|
||||
} // namespace GLState
|
||||
} // namespace MG_State
|
||||
} // namespace MobileGL
|
||||
@@ -0,0 +1,23 @@
|
||||
#pragma once
|
||||
#include "TextureObject.h"
|
||||
#include "MG_State/GLState/BufferState/BufferObject.h"
|
||||
|
||||
namespace MobileGL {
|
||||
namespace MG_State {
|
||||
namespace GLState {
|
||||
class TextureObjectBuffer : public TextureObjectBase {
|
||||
public:
|
||||
TextureStorageType GetStorageType() const override { return TextureStorageType::Buffer; }
|
||||
explicit TextureObjectBuffer(Uint externalIndex);
|
||||
const Vector<TextureUploadTarget>& GetUploadTargets() const override { return m_uploadTargets; }
|
||||
BindingSlot<BufferObject>& GetBufferBindingSlot(TextureUploadTarget target = TextureUploadTarget::TextureBuffer);
|
||||
|
||||
protected:
|
||||
Uint GetIndexOfTextureUploadTarget(TextureUploadTarget target) const override;
|
||||
|
||||
BindingSlot<BufferObject> m_bufferBindingSlot = BindingSlot<BufferObject>(BufferTarget::Texture);
|
||||
const Vector<TextureUploadTarget> m_uploadTargets{TextureUploadTarget::TextureBuffer};
|
||||
};
|
||||
} // namespace GLState
|
||||
} // namespace MG_State
|
||||
} // namespace MobileGL
|
||||
@@ -31,8 +31,8 @@ namespace MobileGL {
|
||||
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(TextureObjectBuffer, TextureTarget::TextureBuffer,
|
||||
// {TextureUploadTarget::Unknown});
|
||||
|
||||
STUB_TEXTURE_OBJECT_CLASS_DEFINITION(TextureObject1DArray, TextureTarget::Texture1DArray,
|
||||
{TextureUploadTarget::Texture1DArray});
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include "TextureObject2D.h"
|
||||
#include "TextureObject3D.h"
|
||||
#include "TextureObject2DCube.h"
|
||||
#include "TextureObjectBuffer.h"
|
||||
#include "TextureObjectStubs.h"
|
||||
|
||||
namespace MobileGL {
|
||||
@@ -46,6 +47,9 @@ namespace MobileGL {
|
||||
case TextureTarget::Texture3D:
|
||||
textureObject = MakeShared<TextureObject3D>(index);
|
||||
break;
|
||||
case TextureTarget::TextureBuffer:
|
||||
textureObject = MakeShared<TextureObjectBuffer>(index);
|
||||
break;
|
||||
|
||||
// These texture types are stubbed:
|
||||
case TextureTarget::TextureRectangle:
|
||||
@@ -54,9 +58,6 @@ namespace MobileGL {
|
||||
case TextureTarget::Texture2DMultisample:
|
||||
textureObject = MakeShared<TextureObject2DMultisample>(index);
|
||||
break;
|
||||
case TextureTarget::TextureBuffer:
|
||||
textureObject = MakeShared<TextureObjectBuffer>(index);
|
||||
break;
|
||||
case TextureTarget::Texture1DArray:
|
||||
textureObject = MakeShared<TextureObject1DArray>(index);
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user