LiteFX 0.3.1.2022
Computer Graphics Engine
LiteFX::Rendering::Backends::DirectX12Buffer Class Reference

Implements a DirectX 12 IBuffer. More...

#include <buffer.h>

Inherits LiteFX::Rendering::Backends::IDirectX12Buffer, LiteFX::Resource< THandle >, and LiteFX::Rendering::StateResource.

Inherited by LiteFX::Rendering::Backends::DirectX12IndexBuffer, and LiteFX::Rendering::Backends::DirectX12VertexBuffer.

Classes

class  DirectX12BufferImpl
 

Public Member Functions

 DirectX12Buffer (ComPtr< ID3D12Resource > &&buffer, const BufferType &type, const UInt32 &elements, const size_t &elementSize, const size_t &alignment, const bool &writable, const ResourceState &initialState, AllocatorPtr allocator=nullptr, AllocationPtr &&allocation=nullptr, const String &name="")
 
 DirectX12Buffer (DirectX12Buffer &&)=delete
 
 DirectX12Buffer (const DirectX12Buffer &)=delete
 
virtual ~DirectX12Buffer () noexcept
 
virtual const BufferType & type () const noexcept override
 Returns the type of the buffer. More...
 
virtual const UInt32elements () const noexcept override
 Gets the number of sub-resources inside the memory chunk. More...
 
virtual size_t size () const noexcept override
 Gets the size (in bytes) of the aligned memory chunk. More...
 
virtual size_t elementSize () const noexcept override
 Returns the size of a single element within the buffer. If there is only one element, this is equal to size. More...
 
virtual size_t elementAlignment () const noexcept override
 Returns the alignment of a single element. More...
 
virtual size_t alignedElementSize () const noexcept override
 Returns the actual size of the element in device memory. More...
 
virtual const bool & writable () const noexcept override
 Returns true, if the resource can be bound to a read/write descriptor. More...
 
virtual const ResourceState & state (const UInt32 &subresource=0) const override
 Returns the current state of the resource. More...
 
virtual ResourceState & state (const UInt32 &subresource=0) override
 Returns a reference of the current state of the resource. More...
 
virtual void map (const void *const data, const size_t &size, const UInt32 &element=0) override
 Maps the memory at data to the internal memory of this object. More...
 
virtual void map (Span< const void *const > data, const size_t &elementSize, const UInt32 &firstElement=0) override
 Maps the memory blocks within data to the internal memory of an array. More...
 
- Public Member Functions inherited from LiteFX::Rendering::Backends::IDirectX12Buffer
virtual ~IDirectX12Buffer () noexcept=default
 
- Public Member Functions inherited from LiteFX::Rendering::IBuffer
virtual ~IBuffer () noexcept=default
 
virtual const BufferType & type () const noexcept=0
 Returns the type of the buffer. More...
 
- Public Member Functions inherited from LiteFX::Rendering::IDeviceMemory
virtual ~IDeviceMemory () noexcept=default
 
virtual const UInt32elements () const noexcept=0
 Gets the number of sub-resources inside the memory chunk. More...
 
virtual size_t size () const noexcept=0
 Gets the size (in bytes) of the aligned memory chunk. More...
 
virtual size_t elementSize () const noexcept=0
 Returns the size of a single element within the buffer. If there is only one element, this is equal to size. More...
 
virtual size_t elementAlignment () const noexcept=0
 Returns the alignment of a single element. More...
 
virtual size_t alignedElementSize () const noexcept=0
 Returns the actual size of the element in device memory. More...
 
virtual const bool & writable () const noexcept=0
 Returns true, if the resource can be bound to a read/write descriptor. More...
 
virtual const ResourceState & state (const UInt32 &subresource=0) const =0
 Returns the current state of the resource. More...
 
virtual ResourceState & state (const UInt32 &subresource=0)=0
 Returns a reference of the current state of the resource. More...
 
- Public Member Functions inherited from LiteFX::Rendering::IMappable
virtual ~IMappable () noexcept=default
 
virtual void map (const void *const data, const size_t &size, const UInt32 &element=0)=0
 Maps the memory at data to the internal memory of this object. More...
 
virtual void map (Span< const void *const > data, const size_t &elementSize, const UInt32 &firstElement=0)=0
 Maps the memory blocks within data to the internal memory of an array. More...
 
- Public Member Functions inherited from LiteFX::Rendering::IStateResource
virtual ~IStateResource () noexcept=default
 
virtual const Stringname () const noexcept=0
 Returns the name of the resource. More...
 
- Public Member Functions inherited from LiteFX::IResource< ComPtr< ID3D12Resource > >
virtual ~IResource () noexcept=default
 
virtual const ComPtr< ID3D12Resource > & handle () const noexcept=0
 Returns the resource managed by the class. More...
 
- Public Member Functions inherited from LiteFX::Resource< THandle >
 Resource (const Resource &)=delete
 
 Resource (Resource &&)=delete
 
virtual ~Resource () noexcept=default
 
const THandle & handle () const noexcept override
 Returns the resource managed by the class. More...
 
- Public Member Functions inherited from LiteFX::IResource< THandle >
virtual ~IResource () noexcept=default
 
virtual const THandle & handle () const noexcept=0
 Returns the resource managed by the class. More...
 
- Public Member Functions inherited from LiteFX::Rendering::StateResource
 StateResource (StringView name)
 Initializes a new state resource instance. More...
 
 StateResource (StateResource &&)=delete
 
 StateResource (const StateResource &)=delete
 
virtual ~StateResource () noexcept
 
virtual const Stringname () const noexcept override
 Returns the name of the resource. More...
 

Static Public Member Functions

static UniquePtr< IDirectX12Bufferallocate (AllocatorPtr allocator, const BufferType &type, const UInt32 &elements, const size_t &elementSize, const size_t &alignment, const bool &writable, const ResourceState &initialState, const D3D12_RESOURCE_DESC &resourceDesc, const D3D12MA::ALLOCATION_DESC &allocationDesc)
 
static UniquePtr< IDirectX12Bufferallocate (const String &name, AllocatorPtr allocator, const BufferType &type, const UInt32 &elements, const size_t &elementSize, const size_t &alignment, const bool &writable, const ResourceState &initialState, const D3D12_RESOURCE_DESC &resourceDesc, const D3D12MA::ALLOCATION_DESC &allocationDesc)
 

Protected Member Functions

virtual AllocatorPtr allocator () const noexcept
 
virtual const D3D12MA::Allocation * allocationInfo () const noexcept
 
- Protected Member Functions inherited from LiteFX::IResource< ComPtr< ID3D12Resource > >
virtual ComPtr< ID3D12Resource > & handle () noexcept=0
 Returns the resource managed by the class. More...
 
- Protected Member Functions inherited from LiteFX::Resource< THandle >
 Resource (const THandle handle) noexcept
 Initializes the managed resource. More...
 
THandle & handle () noexcept override
 Returns the resource managed by the class. More...
 
virtual THandle & handle () noexcept=0
 Returns the resource managed by the class. More...
 
- Protected Member Functions inherited from LiteFX::Rendering::StateResource
 StateResource () noexcept
 
Stringname () noexcept
 

Detailed Description

Implements a DirectX 12 IBuffer.

Constructor & Destructor Documentation

◆ DirectX12Buffer() [1/3]

DirectX12Buffer::DirectX12Buffer ( ComPtr< ID3D12Resource > &&  buffer,
const BufferType &  type,
const UInt32 elements,
const size_t &  elementSize,
const size_t &  alignment,
const bool &  writable,
const ResourceState &  initialState,
AllocatorPtr  allocator = nullptr,
AllocationPtr &&  allocation = nullptr,
const String name = "" 
)
explicit

◆ DirectX12Buffer() [2/3]

LiteFX::Rendering::Backends::DirectX12Buffer::DirectX12Buffer ( DirectX12Buffer &&  )
delete

◆ DirectX12Buffer() [3/3]

LiteFX::Rendering::Backends::DirectX12Buffer::DirectX12Buffer ( const DirectX12Buffer )
delete

◆ ~DirectX12Buffer()

DirectX12Buffer::~DirectX12Buffer ( )
virtualdefaultnoexcept

Member Function Documentation

◆ alignedElementSize()

size_t DirectX12Buffer::alignedElementSize ( ) const
overridevirtualnoexcept

Returns the actual size of the element in device memory.

Implements LiteFX::Rendering::IDeviceMemory.

◆ allocate() [1/2]

UniquePtr< IDirectX12Buffer > DirectX12Buffer::allocate ( AllocatorPtr  allocator,
const BufferType &  type,
const UInt32 elements,
const size_t &  elementSize,
const size_t &  alignment,
const bool &  writable,
const ResourceState &  initialState,
const D3D12_RESOURCE_DESC &  resourceDesc,
const D3D12MA::ALLOCATION_DESC &  allocationDesc 
)
static

◆ allocate() [2/2]

UniquePtr< IDirectX12Buffer > DirectX12Buffer::allocate ( const String name,
AllocatorPtr  allocator,
const BufferType &  type,
const UInt32 elements,
const size_t &  elementSize,
const size_t &  alignment,
const bool &  writable,
const ResourceState &  initialState,
const D3D12_RESOURCE_DESC &  resourceDesc,
const D3D12MA::ALLOCATION_DESC &  allocationDesc 
)
static

◆ allocationInfo()

const D3D12MA::Allocation * DirectX12Buffer::allocationInfo ( ) const
protectedvirtualnoexcept

◆ allocator()

AllocatorPtr DirectX12Buffer::allocator ( ) const
protectedvirtualnoexcept

◆ elementAlignment()

size_t DirectX12Buffer::elementAlignment ( ) const
overridevirtualnoexcept

Returns the alignment of a single element.

Implements LiteFX::Rendering::IDeviceMemory.

◆ elements()

const UInt32 & DirectX12Buffer::elements ( ) const
overridevirtualnoexcept

Gets the number of sub-resources inside the memory chunk.

Implements LiteFX::Rendering::IDeviceMemory.

◆ elementSize()

size_t DirectX12Buffer::elementSize ( ) const
overridevirtualnoexcept

Returns the size of a single element within the buffer. If there is only one element, this is equal to size.

Implements LiteFX::Rendering::IDeviceMemory.

◆ map() [1/2]

void DirectX12Buffer::map ( const void *const  data,
const size_t &  size,
const UInt32 element = 0 
)
overridevirtual

Maps the memory at data to the internal memory of this object.

Implements LiteFX::Rendering::IMappable.

◆ map() [2/2]

void DirectX12Buffer::map ( Span< const void *const >  data,
const size_t &  elementSize,
const UInt32 firstElement = 0 
)
overridevirtual

Maps the memory blocks within data to the internal memory of an array.

Implements LiteFX::Rendering::IMappable.

◆ size()

size_t DirectX12Buffer::size ( ) const
overridevirtualnoexcept

Gets the size (in bytes) of the aligned memory chunk.

Implements LiteFX::Rendering::IDeviceMemory.

◆ state() [1/2]

const ResourceState & DirectX12Buffer::state ( const UInt32 subresource = 0) const
overridevirtual

Returns the current state of the resource.

Implements LiteFX::Rendering::IDeviceMemory.

◆ state() [2/2]

ResourceState & DirectX12Buffer::state ( const UInt32 subresource = 0)
overridevirtual

Returns a reference of the current state of the resource.

Implements LiteFX::Rendering::IDeviceMemory.

◆ type()

const BufferType & DirectX12Buffer::type ( ) const
overridevirtualnoexcept

Returns the type of the buffer.

Implements LiteFX::Rendering::IBuffer.

◆ writable()

const bool & DirectX12Buffer::writable ( ) const
overridevirtualnoexcept

Returns true, if the resource can be bound to a read/write descriptor.

Implements LiteFX::Rendering::IDeviceMemory.