28 D3D11_BUFFER_DESC desc;
30 desc.BindFlags = D3D11_BIND_SHADER_RESOURCE;
31 desc.MiscFlags = D3D11_RESOURCE_MISC_BUFFER_STRUCTURED;
36 desc.Usage = D3D11_USAGE_IMMUTABLE;
41 desc.Usage = D3D11_USAGE_DYNAMIC;
42 desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
46 desc.Usage = D3D11_USAGE_DEFAULT;
47 desc.BindFlags |= D3D11_BIND_UNORDERED_ACCESS;
52 ID3D11Buffer*
buffer =
nullptr;
56 D3D11_SUBRESOURCE_DATA
data;
57 data.pSysMem = sbuffer->
GetData();
59 data.SysMemSlicePitch = 0;
60 hr = device->CreateBuffer(&desc, &data, &buffer);
64 hr = device->CreateBuffer(&desc,
nullptr, &buffer);
71 if (usage == Resource::SHADER_OUTPUT)
93 return std::make_shared<DX11StructuredBuffer>(
94 reinterpret_cast<ID3D11Device*
>(device),
95 static_cast<StructuredBuffer const*>(
object));
115 ID3D11DeviceContext* context)
121 D3D11_MAPPED_SUBRESOURCE sub;
122 HRESULT hr = context->Map(
mCounterStaging, 0, D3D11_MAP_READ, 0, &sub);
129 unsigned int numActive = *
static_cast<unsigned int*
>(sub.pData);
156 D3D11_SHADER_RESOURCE_VIEW_DESC desc;
157 desc.Format = DXGI_FORMAT_UNKNOWN;
158 desc.ViewDimension = D3D11_SRV_DIMENSION_BUFFER;
159 desc.Buffer.FirstElement = sbuffer->
GetOffset();
162 HRESULT hr = device->CreateShaderResourceView(buffer, &desc, &
mSRView);
171 D3D11_UNORDERED_ACCESS_VIEW_DESC desc;
172 desc.Format = DXGI_FORMAT_UNKNOWN;
173 desc.ViewDimension = D3D11_UAV_DIMENSION_BUFFER;
174 desc.Buffer.FirstElement = sbuffer->
GetOffset();
178 HRESULT hr = device->CreateUnorderedAccessView(buffer, &desc, &
mUAView);
186 D3D11_BUFFER_DESC desc;
188 desc.Usage = D3D11_USAGE_STAGING;
190 desc.CPUAccessFlags = D3D11_CPU_ACCESS_READ;
201 D3D11_BUFFER_UAV_FLAG_APPEND,
202 D3D11_BUFFER_UAV_FLAG_COUNTER
StructuredBuffer * GetStructuredBuffer() const
void CreateSRView(ID3D11Device *device)
#define D3D11_BUFFER_UAV_FLAG_BASIC
unsigned int GetNumElements() const
CounterType GetCounterType() const
void CreateCounterStaging(ID3D11Device *device)
#define D3D11_RESOURCE_MISC_NONE
ID3D11Buffer * mCounterStaging
#define CHECK_HR_RETURN_NONE(msg)
unsigned int GetOffset() const
ID3D11Buffer * GetDXBuffer() const
HRESULT SetPrivateName(ID3D11DeviceChild *object, std::string const &name)
ID3D11UnorderedAccessView * mUAView
GraphicsObjectType GetType() const
GLuint const GLchar * name
ULONG FinalRelease(T *&object)
virtual void SetName(std::string const &name)
unsigned int GetElementSize() const
virtual bool CopyGpuToCpu(ID3D11DeviceContext *context)
GLsizei const GLchar *const * string
#define LogError(message)
ID3D11ShaderResourceView * mSRView
ID3D11DeviceChild * mDXObject
unsigned int GetNumBytes() const
void CreateStaging(ID3D11Device *device, D3D11_BUFFER_DESC const &bf)
char const * GetData() const
bool GetNumActiveElements(ID3D11DeviceContext *context)
GLsizeiptr const void GLenum usage
#define D3D11_CPU_ACCESS_NONE
void SetNumActiveElements(unsigned int numActiveElements)
void CreateUAView(ID3D11Device *device)
static unsigned int const msUAVFlag[]
CopyType GetCopyType() const
DX11StructuredBuffer(ID3D11Device *device, StructuredBuffer const *sbuffer)
#define CHECK_HR_RETURN(msg, value)
virtual bool CopyGpuToCpu(ID3D11DeviceContext *context) override
static std::shared_ptr< GEObject > Create(void *device, GraphicsObject const *object)
virtual void SetName(std::string const &name) override
virtual ~DX11StructuredBuffer()