Turned DataStorage enum into flags

Allowing for example hybrid buffer implementation


Former-commit-id: 74af1ba5b11b945abdfa6b46d0c11d600eca6d7c
This commit is contained in:
Lynix
2015-01-06 13:36:58 +01:00
parent fc1e75d379
commit 5cbdd8832c
8 changed files with 35 additions and 34 deletions

View File

@@ -30,7 +30,7 @@ m_size(0)
{
}
NzBuffer::NzBuffer(nzBufferType type, unsigned int size, nzDataStorage storage, nzBufferUsage usage) :
NzBuffer::NzBuffer(nzBufferType type, unsigned int size, nzUInt32 storage, nzBufferUsage usage) :
m_type(type),
m_impl(nullptr)
{
@@ -63,7 +63,7 @@ bool NzBuffer::CopyContent(const NzBuffer& buffer)
return Fill(mapper.GetPointer(), 0, buffer.GetSize());
}
bool NzBuffer::Create(unsigned int size, nzDataStorage storage, nzBufferUsage usage)
bool NzBuffer::Create(unsigned int size, nzUInt32 storage, nzBufferUsage usage)
{
Destroy();
@@ -131,7 +131,7 @@ unsigned int NzBuffer::GetSize() const
return m_size;
}
nzDataStorage NzBuffer::GetStorage() const
nzUInt32 NzBuffer::GetStorage() const
{
return m_storage;
}
@@ -148,7 +148,7 @@ nzBufferUsage NzBuffer::GetUsage() const
bool NzBuffer::IsHardware() const
{
return m_storage == nzDataStorage_Hardware;
return m_storage & nzDataStorage_Hardware;
}
bool NzBuffer::IsValid() const
@@ -200,7 +200,7 @@ void* NzBuffer::Map(nzBufferAccess access, unsigned int offset, unsigned int siz
return m_impl->Map(access, offset, (size == 0) ? m_size-offset : size);
}
bool NzBuffer::SetStorage(nzDataStorage storage)
bool NzBuffer::SetStorage(nzUInt32 storage)
{
#if NAZARA_UTILITY_SAFE
if (!m_impl)
@@ -275,12 +275,12 @@ void NzBuffer::Unmap() const
NazaraWarning("Failed to unmap buffer (it's content may be undefined)"); ///TODO: Unexpected ?
}
bool NzBuffer::IsStorageSupported(nzDataStorage storage)
bool NzBuffer::IsStorageSupported(nzUInt32 storage)
{
return s_bufferFactories[storage] != nullptr;
}
void NzBuffer::SetBufferFactory(nzDataStorage storage, BufferFactory func)
void NzBuffer::SetBufferFactory(nzUInt32 storage, BufferFactory func)
{
s_bufferFactories[storage] = func;
}

View File

@@ -24,7 +24,7 @@ NzIndexBuffer::NzIndexBuffer(bool largeIndices, NzBuffer* buffer, unsigned int s
Reset(largeIndices, buffer, startOffset, endOffset);
}
NzIndexBuffer::NzIndexBuffer(bool largeIndices, unsigned int length, nzDataStorage storage, nzBufferUsage usage)
NzIndexBuffer::NzIndexBuffer(bool largeIndices, unsigned int length, nzUInt32 storage, nzBufferUsage usage)
{
NzErrorFlags(nzErrorFlag_ThrowException, true);
Reset(largeIndices, length, storage, usage);
@@ -220,7 +220,7 @@ void NzIndexBuffer::Reset(bool largeIndices, NzBuffer* buffer, unsigned int star
m_startOffset = startOffset;
}
void NzIndexBuffer::Reset(bool largeIndices, unsigned int length, nzDataStorage storage, nzBufferUsage usage)
void NzIndexBuffer::Reset(bool largeIndices, unsigned int length, nzUInt32 storage, nzBufferUsage usage)
{
unsigned int stride = (largeIndices) ? sizeof(nzUInt32) : sizeof(nzUInt16);
@@ -251,7 +251,7 @@ void NzIndexBuffer::Reset(NzIndexBuffer&& indexBuffer) noexcept
m_startOffset = indexBuffer.m_startOffset;
}
bool NzIndexBuffer::SetStorage(nzDataStorage storage)
bool NzIndexBuffer::SetStorage(nzUInt32 storage)
{
return m_buffer->SetStorage(storage);
}

View File

@@ -20,7 +20,7 @@ NzVertexBuffer::NzVertexBuffer(const NzVertexDeclaration* vertexDeclaration, NzB
Reset(vertexDeclaration, buffer, startOffset, endOffset);
}
NzVertexBuffer::NzVertexBuffer(const NzVertexDeclaration* vertexDeclaration, unsigned int length, nzDataStorage storage, nzBufferUsage usage)
NzVertexBuffer::NzVertexBuffer(const NzVertexDeclaration* vertexDeclaration, unsigned int length, nzUInt32 storage, nzBufferUsage usage)
{
NzErrorFlags(nzErrorFlag_ThrowException, true);
Reset(vertexDeclaration, length, storage, usage);
@@ -230,7 +230,7 @@ void NzVertexBuffer::Reset(const NzVertexDeclaration* vertexDeclaration, NzBuffe
m_vertexDeclaration = vertexDeclaration;
}
void NzVertexBuffer::Reset(const NzVertexDeclaration* vertexDeclaration, unsigned int length, nzDataStorage storage, nzBufferUsage usage)
void NzVertexBuffer::Reset(const NzVertexDeclaration* vertexDeclaration, unsigned int length, nzUInt32 storage, nzBufferUsage usage)
{
m_endOffset = length * ((vertexDeclaration) ? vertexDeclaration->GetStride() : 1);
m_startOffset = 0;
@@ -259,7 +259,7 @@ void NzVertexBuffer::Reset(NzVertexBuffer&& vertexBuffer) noexcept
m_vertexDeclaration = std::move(vertexBuffer.m_vertexDeclaration);
}
bool NzVertexBuffer::SetStorage(nzDataStorage storage)
bool NzVertexBuffer::SetStorage(nzUInt32 storage)
{
return m_buffer->SetStorage(storage);
}