nCine::RHI::D3D11::D3D11BufferObject class

Buffer object of the Direct3D 11 backend (aliased as RHI::Buffer).

A vertex, index or uniform buffer keeps a resizable host byte store the pipeline maps and writes into. MapBufferRange() hands back a pointer into the store and BindBufferRange() forwards a sub-range to the device. Real ID3D11Buffer objects (with Map/Unmap for the streaming uniform ring) are created from this same surface.

Public static functions

static void SetBoundHandle(std::uint32_t target, std::uint32_t glHandle)
Records the buffer handle bound for a target (inert).
static auto BindHandle(std::uint32_t target, std::uint32_t glHandle) -> bool
Marks a buffer handle as bound for a target (inert).

Constructors, destructors, conversion operators

D3D11BufferObject(BufferTarget target) explicit
~D3D11BufferObject()
D3D11BufferObject(const D3D11BufferObject&) deleted

Public functions

auto operator=(const D3D11BufferObject&) -> D3D11BufferObject& deleted
auto GetD3DBuffer() const -> ID3D11Buffer*
Returns a GPU buffer (vertex/index) whose contents are refreshed from the host store when dirty.
auto GetGLHandle() const -> std::uint32_t
Returns a synthetic handle uniquely identifying the buffer (used by material sort keys).
auto GetTarget() const -> BufferTarget
Returns the binding target of the buffer.
auto GetSize() const -> std::size_t
Returns the size in bytes of the data store.
auto HostData() -> std::uint8_t*
Returns the base pointer of the host-side data store.
auto HostData() const -> const std::uint8_t*
Returns the base pointer of the host-side data store.
auto Bind() const -> bool
Marks the buffer as the currently bound one for its target (always issues the "bind").
auto Unbind() const -> bool
Marks no buffer as bound for this object's target.
void BufferData(std::size_t size, const void* data, BufferUsage usage)
(Re)creates the data store with the given size, optional initial data and usage hint
void BufferSubData(std::size_t offset, std::size_t size, const void* data)
Updates a subset of the data store starting at the given byte offset.
void BufferStorage(std::size_t size, const void* data, MapFlags flags)
(Re)creates the data store like BufferData(); there is no immutable storage, so the flags are ignored
void BindBufferBase(std::uint32_t index)
Binds the whole buffer to a uniform binding point index.
void BindBufferRange(std::uint32_t index, std::size_t offset, std::size_t size)
Binds a byte range of the buffer to a uniform binding point index (forwarded to the device).
auto MapBufferRange(std::size_t offset, std::size_t length, MapFlags access) -> void*
Returns a host pointer to a byte range of the store (there is no real mapping).
void FlushMappedBufferRange(std::size_t offset, std::size_t length)
Flushes a mapped range (a no-op, the store is host memory).
auto Unmap() -> bool
Unmaps the buffer (a no-op, the store is host memory).
void SetObjectLabel(StringView label)
Sets a debug label for the buffer (ignored).