Diligent Engine
 
Loading...
Searching...
No Matches
Diligent::IBuffer Struct Referenceabstract

Buffer interface. More...

#include <Buffer.h>

Inheritance diagram for Diligent::IBuffer:
Diligent::IDeviceObject Diligent.IObject Diligent::IBufferD3D11 Diligent::IBufferD3D12 Diligent::IBufferGL Diligent::IBufferMtl Diligent::IBufferVk Diligent::IBufferWebGPU

Public Member Functions

virtual const BufferDesc &DILIGENT_CALL_TYPE GetDesc () const override=0
 Returns the buffer description used to create the object.
 
virtual void DILIGENT_CALL_TYPE CreateView (const BufferViewDesc &ViewDesc, IBufferView **ppView)=0
 Creates a new buffer view.
 
virtual IBufferView *DILIGENT_CALL_TYPE GetDefaultView (BUFFER_VIEW_TYPE ViewType)=0
 Returns the pointer to the default view.
 
virtual Uint64 DILIGENT_CALL_TYPE GetNativeHandle ()=0
 Returns native buffer handle specific to the underlying graphics API.
 
virtual void DILIGENT_CALL_TYPE SetState (RESOURCE_STATE State)=0
 Sets the buffer usage state.
 
virtual RESOURCE_STATE DILIGENT_CALL_TYPE GetState () const =0
 Returns the internal buffer state.
 
virtual MEMORY_PROPERTIES DILIGENT_CALL_TYPE GetMemoryProperties () const =0
 Returns the buffer memory properties, see Diligent::MEMORY_PROPERTIES.
 
virtual void DILIGENT_CALL_TYPE FlushMappedRange (Uint64 StartOffset, Uint64 Size)=0
 
virtual void DILIGENT_CALL_TYPE InvalidateMappedRange (Uint64 StartOffset, Uint64 Size)=0
 
virtual SparseBufferProperties DILIGENT_CALL_TYPE GetSparseProperties () const =0
 Returns the sparse buffer memory properties.
 
- Public Member Functions inherited from Diligent::IDeviceObject
virtual Int32 DILIGENT_CALL_TYPE GetUniqueID () const =0
 Returns unique identifier assigned to an object.
 
virtual void DILIGENT_CALL_TYPE SetUserData (IObject *pUserData)=0
 Stores a pointer to the user-provided data object.
 
virtual IObject *DILIGENT_CALL_TYPE GetUserData () const =0
 Returns a pointer to the user data object previously set with SetUserData() method.
 
- Public Member Functions inherited from Diligent.IObject
virtual void DILIGENT_CALL_TYPE QueryInterface (const INTERFACE_ID &IID, IObject **ppInterface)=0
 Queries the specific interface.
 
virtual ReferenceCounterValueType DILIGENT_CALL_TYPE AddRef ()=0
 Increments the number of strong references by 1.
 
virtual ReferenceCounterValueType DILIGENT_CALL_TYPE Release ()=0
 
virtual IReferenceCounters *DILIGENT_CALL_TYPE GetReferenceCounters () const =0
 

Detailed Description

Buffer interface.

Defines the methods to manipulate a buffer object

Member Function Documentation

◆ CreateView()

virtual void DILIGENT_CALL_TYPE Diligent::IBuffer::CreateView ( const BufferViewDesc & ViewDesc,
IBufferView ** ppView )
pure virtual

Creates a new buffer view.

Parameters
[in]ViewDesc- View description. See Diligent::BufferViewDesc for details.
[out]ppView- Address of the memory location where the pointer to the view interface will be written to.
Remarks
To create a view addressing the entire buffer, set only BufferViewDesc::ViewType member of the ViewDesc structure and leave all other members in their default values.
Buffer view will contain strong reference to the buffer, so the buffer will not be destroyed until all views are released.
The function calls AddRef() for the created interface, so it must be released by a call to Release() when it is no longer needed.

◆ FlushMappedRange()

virtual void DILIGENT_CALL_TYPE Diligent::IBuffer::FlushMappedRange ( Uint64 StartOffset,
Uint64 Size )
pure virtual

Flushes the specified range of non-coherent memory from the host cache to make it available to the GPU.

Parameters
[in]StartOffset- Offset, in bytes, from the beginning of the buffer to the start of the memory range to flush.
[in]Size- Size, in bytes, of the memory range to flush.

This method should only be used for persistently-mapped buffers that do not report MEMORY_PROPERTY_HOST_COHERENT property. After an application modifies a mapped memory range on the CPU, it must flush the range to make it available to the GPU.

Note
This method must never be used for USAGE_DYNAMIC buffers.

When a mapped buffer is unmapped it is automatically flushed by the engine if necessary.

◆ GetDefaultView()

virtual IBufferView *DILIGENT_CALL_TYPE Diligent::IBuffer::GetDefaultView ( BUFFER_VIEW_TYPE ViewType)
pure virtual

Returns the pointer to the default view.

Parameters
[in]ViewType- Type of the requested view. See Diligent::BUFFER_VIEW_TYPE.
Returns
Pointer to the interface
Remarks
Default views are only created for structured and raw buffers. As for formatted buffers the view format is unknown at buffer initialization time, no default views are created.
Note
The function does not increase the reference counter for the returned interface, so Release() must NOT be called.

◆ GetMemoryProperties()

virtual MEMORY_PROPERTIES DILIGENT_CALL_TYPE Diligent::IBuffer::GetMemoryProperties ( ) const
pure virtual

Returns the buffer memory properties, see Diligent::MEMORY_PROPERTIES.

The memory properties are only relevant for persistently mapped buffers. In particular, if the memory is not coherent, an application must call IBuffer::FlushMappedRange() to make writes by the CPU available to the GPU, and call IBuffer::InvalidateMappedRange() to make writes by the GPU visible to the CPU.

◆ GetNativeHandle()

virtual Uint64 DILIGENT_CALL_TYPE Diligent::IBuffer::GetNativeHandle ( )
pure virtual

Returns native buffer handle specific to the underlying graphics API.

Returns
A pointer to ID3D11Resource interface, for D3D11 implementation
A pointer to ID3D12Resource interface, for D3D12 implementation
VkBuffer handle, for Vulkan implementation
GL buffer name, for OpenGL implementation
MtlBuffer, for Metal implementation
WGPUBuffer, for WGPU implementation

◆ InvalidateMappedRange()

virtual void DILIGENT_CALL_TYPE Diligent::IBuffer::InvalidateMappedRange ( Uint64 StartOffset,
Uint64 Size )
pure virtual

Invalidates the specified range of non-coherent memory modified by the GPU to make it visible to the CPU.

Parameters
[in]StartOffset- Offset, in bytes, from the beginning of the buffer to the start of the memory range to invalidate.
[in]Size- Size, in bytes, of the memory range to invalidate.

This method should only be used for persistently-mapped buffers that do not report MEMORY_PROPERTY_HOST_COHERENT property. After an application modifies a mapped memory range on the GPU, it must invalidate the range to make it visible to the CPU.

Note
This method must never be used for USAGE_DYNAMIC buffers.

When a mapped buffer is unmapped, it is automatically invalidated by the engine if necessary.

◆ SetState()

virtual void DILIGENT_CALL_TYPE Diligent::IBuffer::SetState ( RESOURCE_STATE State)
pure virtual

Sets the buffer usage state.

Note
This method does not perform state transition, but resets the internal buffer state to the given value. This method should be used after the application finished manually managing the buffer state and wants to hand over state management back to the engine.