2013-11-06 22:52:00 +01:00
|
|
|
#pragma once
|
|
|
|
#ifndef CoreBuffer
|
|
|
|
#define CoreBuffer
|
|
|
|
|
2013-11-10 03:19:46 +01:00
|
|
|
#include "CoreIncludes.h"
|
2013-11-06 22:52:00 +01:00
|
|
|
|
|
|
|
namespace Oyster
|
|
|
|
{
|
2013-11-20 10:22:01 +01:00
|
|
|
namespace Graphics
|
2013-11-06 22:52:00 +01:00
|
|
|
{
|
2013-11-20 10:22:01 +01:00
|
|
|
class Buffer
|
2013-11-06 22:52:00 +01:00
|
|
|
{
|
2013-11-20 10:22:01 +01:00
|
|
|
public:
|
|
|
|
enum BUFFER_TYPE
|
|
|
|
{
|
|
|
|
VERTEX_BUFFER,
|
|
|
|
INDEX_BUFFER,
|
|
|
|
CONSTANT_BUFFER_VS,
|
|
|
|
CONSTANT_BUFFER_GS,
|
|
|
|
CONSTANT_BUFFER_PS,
|
|
|
|
CONSTANT_BUFFER_CS,
|
|
|
|
STRUCTURED_BUFFER,
|
|
|
|
BUFFER_TYPE_COUNT
|
|
|
|
};
|
2013-11-06 22:52:00 +01:00
|
|
|
|
2013-11-20 10:22:01 +01:00
|
|
|
enum BUFFER_USAGE
|
|
|
|
{
|
|
|
|
BUFFER_DEFAULT,
|
|
|
|
BUFFER_STREAM_OUT_TARGET,
|
|
|
|
BUFFER_CPU_WRITE,
|
|
|
|
BUFFER_CPU_WRITE_DISCARD,
|
|
|
|
BUFFER_CPU_READ,
|
|
|
|
BUFFER_USAGE_COUNT,
|
|
|
|
BUFFER_USAGE_IMMUTABLE
|
|
|
|
};
|
2013-11-06 22:52:00 +01:00
|
|
|
|
2013-11-20 10:22:01 +01:00
|
|
|
struct BUFFER_INIT_DESC
|
2013-11-06 22:52:00 +01:00
|
|
|
{
|
2013-11-20 10:22:01 +01:00
|
|
|
BUFFER_TYPE Type;
|
|
|
|
UINT32 NumElements;
|
|
|
|
UINT32 ElementSize;
|
|
|
|
BUFFER_USAGE Usage;
|
|
|
|
void* InitData;
|
2013-11-06 22:52:00 +01:00
|
|
|
|
2013-11-20 10:22:01 +01:00
|
|
|
BUFFER_INIT_DESC()
|
|
|
|
{
|
|
|
|
InitData = NULL;
|
|
|
|
Usage = BUFFER_DEFAULT;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
protected:
|
|
|
|
ID3D11Buffer* mBuffer;
|
|
|
|
BUFFER_TYPE mType;
|
|
|
|
BUFFER_USAGE mUsage;
|
2013-11-06 22:52:00 +01:00
|
|
|
|
2013-11-20 10:22:01 +01:00
|
|
|
UINT32 mElementSize;
|
|
|
|
UINT32 mElementCount;
|
|
|
|
public:
|
|
|
|
Buffer();
|
|
|
|
virtual ~Buffer();
|
2013-11-06 22:52:00 +01:00
|
|
|
|
2013-11-20 10:22:01 +01:00
|
|
|
HRESULT Init(const BUFFER_INIT_DESC& initDesc);
|
2013-11-06 22:52:00 +01:00
|
|
|
|
2013-11-20 10:22:01 +01:00
|
|
|
void* Map();
|
|
|
|
void Unmap();
|
2013-11-06 22:52:00 +01:00
|
|
|
|
2013-11-20 10:22:01 +01:00
|
|
|
operator ID3D11Buffer*();
|
|
|
|
operator const ID3D11Buffer*() const;
|
2013-11-06 22:52:00 +01:00
|
|
|
|
2013-11-20 10:22:01 +01:00
|
|
|
HRESULT Apply(UINT32 misc = 0) const;
|
|
|
|
|
|
|
|
ID3D11Buffer* GetBufferPointer();
|
|
|
|
UINT32 GetVertexSize();
|
|
|
|
UINT32 GetElementCount();
|
|
|
|
};
|
|
|
|
}
|
2013-11-06 22:52:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|