Ocular Engine
Ocular::Graphics::D3D11StructuredBuffer Class Reference

#include <D3D11StructuredBuffer.hpp>

Inheritance diagram for Ocular::Graphics::D3D11StructuredBuffer:
Ocular::Graphics::GPUBuffer

Public Member Functions

 D3D11StructuredBuffer (GPUBufferDescriptor const &descriptor)
 
virtual void bind () override
 
virtual void unbind () override
 
virtual bool build (void const *source) override
 
virtual bool read (void *destination, uint32_t start, uint32_t size) override
 
virtual bool write (void const *source, uint32_t start, uint32_t size) override
 
ID3D11Buffer * getD3DBuffer ()
 
ID3D11ShaderResourceView * getD3DShaderResource ()
 
- Public Member Functions inherited from Ocular::Graphics::GPUBuffer
 GPUBuffer (GPUBufferDescriptor const &descriptor)
 
GPUBufferDescriptor const & getDescriptor () const
 

Protected Member Functions

bool getDevices ()
 
void releaseResources ()
 

Protected Attributes

ID3D11Device * m_D3DDevice
 
ID3D11DeviceContext * m_D3DDeviceContext
 
ID3D11Buffer * m_D3DBuffer
 
ID3D11ShaderResourceView * m_D3DSRV
 
- Protected Attributes inherited from Ocular::Graphics::GPUBuffer
GPUBufferDescriptor m_Descriptor
 

Detailed Description

Implementation of GPUBuffer to be used with HLSL StructuredBuffers. Buffers of this type are bound to the t# registers.

A structured buffer is created by the driver when the following conditions are met by the buffer descriptor:

- CPU Access (None, Read, and/or Write)
- GPU Access (Read Only)
- Element size is non-zero

For best performance, data in a StructuredBuffer should be 16-byte aligned (float4).

Member Function Documentation

void Ocular::Graphics::D3D11StructuredBuffer::bind ( )
overridevirtual

Binds the buffer to shader stage and slot specified in the descriptor.

Reimplemented from Ocular::Graphics::GPUBuffer.

bool Ocular::Graphics::D3D11StructuredBuffer::build ( void const *  source)
overridevirtual

Attempts to (re)build the buffer. For buffers built without CPU write access, this is the only way to provide data.

Parameters
[in]sourceOptional source data. If NULL, buffer will be populated with 0.

Reimplemented from Ocular::Graphics::GPUBuffer.

bool Ocular::Graphics::D3D11StructuredBuffer::read ( void *  destination,
uint32_t  start,
uint32_t  size 
)
overridevirtual

Attempts to read data from the buffer. Only available to buffers created with Read CPU Access.

Parameters
[out]destinationDestination to copy buffer data into.
[in]startStarting offset into the GPU buffer to start reading from.
[in]sizeSize of data to be read.
Returns
May return FALSE if: buffer does not have read cpu access, start + size exceeds gpu buffer size, destination is NULL, or API failure during reading.

Reimplemented from Ocular::Graphics::GPUBuffer.

void Ocular::Graphics::D3D11StructuredBuffer::unbind ( )
overridevirtual

Unbinds the buffer in the stage and slot specified by the descriptor.

Reimplemented from Ocular::Graphics::GPUBuffer.

bool Ocular::Graphics::D3D11StructuredBuffer::write ( void const *  source,
uint32_t  start,
uint32_t  size 
)
overridevirtual

Attempts to write data to the buffer. Only available to buffers created with Write CPU Access.

Parameters
[in]sourceSource of data to place into buffer. If source is NULL, buffer will be filled with 0.
[in]startStarting offset into the GPU buffer to start writing to.
[in]sizeSize of the data to write.
Returns
May return FALSE if: buffer does not have write cpu access, start + size exceeds gpu buffer size, or API failure during reading.

Reimplemented from Ocular::Graphics::GPUBuffer.


The documentation for this class was generated from the following files: