Go to the documentation of this file.
58 template <
typename EngineImplTraits>
59 class BufferBase :
public DeviceObjectBase<typename EngineImplTraits::BufferInterface, typename EngineImplTraits::RenderDeviceImplType, BufferDesc>
87 bool bIsDeviceInternal) :
90 m_dbgBuffViewAllocator{BuffViewObjAllocator},
92 m_pDefaultUAV{
nullptr, STDDeleter<BufferViewImplType, TBuffViewObjAllocator>(BuffViewObjAllocator)},
93 m_pDefaultSRV{
nullptr, STDDeleter<BufferViewImplType, TBuffViewObjAllocator>(BuffViewObjAllocator)}
97 Uint64 DeviceQueuesMask = pDevice->GetCommandQueueMask();
98 DEV_CHECK_ERR((this->
m_Desc.
CommandQueueMask & DeviceQueuesMask) != 0,
"No bits in the command queue mask (0x", std::hex, this->m_Desc.CommandQueueMask,
") correspond to one of ", pDevice->GetCommandQueueCount(),
" available device command queues");
127 default:
UNEXPECTED(
"Unknown view type");
return nullptr;
149 std::string ViewName;
153 ViewName =
"Default UAV of buffer '";
157 ViewName =
"Default SRV of buffer '";
166 ViewDesc.
Name = ViewName.c_str();
170 VERIFY(pView !=
nullptr,
"Failed to create default view for buffer '", this->
m_Desc.
Name,
"'");
204 DEV_CHECK_ERR((State & (State - 1)) == 0,
"Single state is expected");
206 return (this->
m_State & State) == State;
213 #ifdef DILIGENT_DEBUG
220 std::unique_ptr<BufferViewImplType, STDDeleter<BufferViewImplType, TBuffViewObjAllocator>>
m_pDefaultUAV;
223 std::unique_ptr<BufferViewImplType, STDDeleter<BufferViewImplType, TBuffViewObjAllocator>>
m_pDefaultSRV;
Buffer view description.
Definition: BufferView.h:88
virtual void CreateView(const struct BufferViewDesc &ViewDesc, IBufferView **ppView) override
Implementation of IBuffer::CreateView(); calls CreateViewInternal() virtual function that creates buf...
Definition: BufferBase.hpp:106
Base interface for a reference counter object that stores the number of strong and weak references an...
Definition: ReferenceCounters.h:44
virtual void CreateViewInternal(const struct BufferViewDesc &ViewDesc, IBufferView **ppView, bool bIsDefaultView)=0
Pure virtual function that creates buffer view for the specific engine implementation.
bool IsInKnownState() const
Definition: BufferBase.hpp:197
@ BIND_UNORDERED_ACCESS
A buffer or a texture can be bound as an unordered access view.
Definition: GraphicsTypes.h:127
void ValidateAndCorrectBufferViewDesc(const BufferDesc &BuffDesc, BufferViewDesc &ViewDesc) noexcept(false)
Validates and corrects buffer view description; throws an exception in case of an error.
Definition: BufferBase.cpp:145
typename EngineGLImplTraits ::BuffViewObjAllocatorType TBuffViewObjAllocator
Definition: BufferBase.hpp:72
uint64_t Uint64
64-bit unsigned integer
Definition: BasicTypes.h:50
struct DeviceCaps DeviceCaps
Definition: GraphicsTypes.h:1925
typename EngineGLImplTraits ::BufferInterface BaseInterface
Definition: BufferBase.hpp:63
#define UNEXPECTED(...)
Definition: DebugUtilities.hpp:77
void ValidateBufferInitData(const BufferDesc &Desc, const BufferData *pBuffData) noexcept(false)
Validates initial buffer data parameters and throws an exception in case of an error.
Definition: BufferBase.cpp:117
BIND_FLAGS BindFlags
Buffer bind flags, see Diligent::BIND_FLAGS for details.
Definition: Buffer.h:85
BufferDesc m_Desc
Object description.
Definition: DeviceObjectBase.hpp:182
virtual void SetState(RESOURCE_STATE State) override final
Definition: BufferBase.hpp:187
#define DEV_CHECK_ERR(...)
Definition: DebugUtilities.hpp:90
Template class implementing base functionality of the buffer object.
Definition: BufferBase.hpp:59
void CreateDefaultViews()
Creates default buffer views.
Definition: BufferBase.hpp:139
BufferBase(IReferenceCounters *pRefCounters, TBuffViewObjAllocator &BuffViewObjAllocator, RenderDeviceImplType *pDevice, const BufferDesc &BuffDesc, bool bIsDeviceInternal)
Definition: BufferBase.hpp:83
virtual const BufferViewDesc &METHOD() GetDesc() const override=0
Returns the buffer view description used to create the object.
std::unique_ptr< BufferViewImplType, STDDeleter< BufferViewImplType, TBuffViewObjAllocator > > m_pDefaultUAV
Default UAV addressing the entire buffer.
Definition: BufferBase.hpp:220
virtual IBufferView * GetDefaultView(BUFFER_VIEW_TYPE ViewType) override
Implementation of IBuffer::GetDefaultView().
Definition: BufferBase.hpp:121
struct BufferDesc BufferDesc
Definition: Buffer.h:152
#define IMPLEMENT_QUERY_INTERFACE_IN_PLACE(InterfaceID, ParentClassName)
Definition: ObjectBase.hpp:59
#define DILIGENT_CALL_TYPE
Definition: CommonDefinitions.h:45
typename EngineGLImplTraits ::BufferViewImplType BufferViewImplType
Definition: BufferBase.hpp:69
void ValidateBufferDesc(const BufferDesc &Desc, const DeviceCaps &deviceCaps) noexcept(false)
Validates buffer description and throws an exception in case of an error.
Definition: BufferBase.cpp:45
DeviceObjectBase< BaseInterface, RenderDeviceImplType, BufferDesc > TDeviceObjectBase
Definition: BufferBase.hpp:74
@ RESOURCE_STATE_UNKNOWN
The resource state is not known to the engine and is managed by the application.
Definition: GraphicsTypes.h:2817
struct BufferData BufferData
Definition: Buffer.h:175
@ BUFFER_VIEW_SHADER_RESOURCE
A buffer view will define a shader resource view that will be used as the source for the shader read ...
Definition: GraphicsTypes.h:310
Buffer description.
Definition: Buffer.h:74
@ BUFFER_VIEW_UNORDERED_ACCESS
A buffer view will define an unordered access view that will be used for unordered read/write operati...
Definition: GraphicsTypes.h:314
std::unique_ptr< BufferViewImplType, STDDeleter< BufferViewImplType, TBuffViewObjAllocator > > m_pDefaultSRV
Default SRV addressing the entire buffer.
Definition: BufferBase.hpp:223
bool CheckState(RESOURCE_STATE State) const
Definition: BufferBase.hpp:202
virtual RESOURCE_STATE GetState() const override final
Definition: BufferBase.hpp:192
struct BufferViewDesc BufferViewDesc
Definition: BufferView.h:140
Uint64 CommandQueueMask
Defines which command queues this buffer can be used with.
Definition: Buffer.h:107
@ BUFFER_VIEW_UNDEFINED
Undefined view type.
Definition: GraphicsTypes.h:306
BUFFER_VIEW_TYPE ViewType
View type. See Diligent::BUFFER_VIEW_TYPE for details.
Definition: BufferView.h:91
@ BUFFER_MODE_STRUCTURED
Structured buffer. In this mode, ElementByteStride member of BufferDesc defines the structure stride.
Definition: Buffer.h:60
#define VERIFY(...)
Definition: DebugUtilities.hpp:76
@ BUFFER_MODE_RAW
Raw buffer. In this mode, the buffer is accessed as raw bytes. Formatted views of a raw buffer can al...
Definition: Buffer.h:67
RESOURCE_STATE
Resource usage state.
Definition: GraphicsTypes.h:2814
Buffer view interface.
Definition: BufferView.h:155
BUFFER_VIEW_TYPE
Buffer view type.
Definition: GraphicsTypes.h:303
RESOURCE_STATE m_State
Definition: BufferBase.hpp:217
typename EngineGLImplTraits ::RenderDeviceImplType RenderDeviceImplType
Definition: BufferBase.hpp:66
const Char * Name
Object name.
Definition: GraphicsTypes.h:1199
Template class implementing base functionality of the device object.
Definition: DeviceObjectBase.hpp:45
The library uses Direct3D-style math:
Definition: AdvancedMath.hpp:37
@ BIND_SHADER_RESOURCE
A buffer or a texture can be bound as a shader resource.
Definition: GraphicsTypes.h:122