29 #include "BufferD3D12.h" 30 #include "RenderDeviceD3D12.h" 31 #include "BufferBase.h" 32 #include "BufferViewD3D12Impl.h" 33 #include "D3D12ResourceBase.h" 34 #include "DynamicUploadHeap.h" 39 class FixedBlockMemoryAllocator;
55 ID3D12Resource *pd3d12Buffer);
58 virtual void QueryInterface(
const Diligent::INTERFACE_ID &IID, IObject **ppInterface )
override;
66 void DbgVerifyDynamicAllocation(Uint32 ContextId);
69 virtual ID3D12Resource *
GetD3D12Buffer(
size_t &DataStartByteOffset, Uint32 ContextId)
override final 71 auto *pd3d12Resource = GetD3D12Resource();
72 if(pd3d12Resource !=
nullptr)
75 DataStartByteOffset = 0;
76 return pd3d12Resource;
83 DbgVerifyDynamicAllocation(ContextId);
85 DataStartByteOffset = m_DynamicData[ContextId].Offset;
86 return m_DynamicData[ContextId].pBuffer;
92 VERIFY(GetD3D12Resource() !=
nullptr,
"The buffer is dynamic and has no pointer to D3D12 resource");
93 size_t DataStartByteOffset = 0;
95 VERIFY(DataStartByteOffset == 0,
"0 offset expected");
101 D3D12_GPU_VIRTUAL_ADDRESS GetGPUAddress(Uint32 ContextId)
106 DbgVerifyDynamicAllocation(ContextId);
108 return m_DynamicData[ContextId].GPUAddress;
112 return GetD3D12Resource()->GetGPUVirtualAddress();
116 D3D12_CPU_DESCRIPTOR_HANDLE GetCBVHandle(){
return m_CBVDescriptorAllocation.GetCpuHandle();}
119 virtual void CreateViewInternal(
const struct BufferViewDesc &ViewDesc, IBufferView **ppView,
bool bIsDefaultView )
override;
121 void CreateUAV(
struct BufferViewDesc &UAVDesc, D3D12_CPU_DESCRIPTOR_HANDLE UAVDescriptor );
122 void CreateSRV(
struct BufferViewDesc &SRVDesc, D3D12_CPU_DESCRIPTOR_HANDLE SRVDescriptor );
123 void CreateCBV( D3D12_CPU_DESCRIPTOR_HANDLE CBVDescriptor );
124 DescriptorHeapAllocation m_CBVDescriptorAllocation;
127 std::vector< std::pair<MAP_TYPE, Uint32>, STDAllocatorRawMem<std::pair<MAP_TYPE, Uint32>> > m_DbgMapType;
130 friend class DeviceContextD3D12Impl;
132 std::vector<DynamicAllocation, STDAllocatorRawMem<DynamicAllocation> > m_DynamicData;
Describes the buffer initial data.
Definition: Buffer.h:176
virtual ID3D12Resource * GetD3D12Buffer(size_t &DataStartByteOffset, Uint32 ContextId) override final
Returns a pointer to the ID3D12Resource interface of the internal Direct3D12 object.
Definition: BufferD3D12Impl.h:69
Implementation of the Diligent::IBufferD3D12 interface.
Definition: BufferD3D12Impl.h:42
A buffer or a texture can be bound as a shader resource.
Definition: GraphicsTypes.h:68
Namespace for the OpenGL implementation of the graphics engine.
Definition: BufferD3D11Impl.h:34
Base implementation of a D3D12 resource.
Definition: D3D12ResourceBase.h:33
virtual void QueryInterface(const Diligent::INTERFACE_ID &IID, IObject **ppInterface) override
Queries the specific interface, see IObject::QueryInterface() for details.
USAGE Usage
Buffer usage, see Diligent::USAGE for details.
Definition: Buffer.h:71
virtual void UpdateData(IDeviceContext *pContext, Uint32 Offset, Uint32 Size, const PVoid pData) override
Base implementation of IBuffer::UpdateData(); validates input parameters.
Definition: BufferD3D12Impl.cpp:272
Template class implementing base functionality for a buffer object.
Definition: BufferBase.h:46
Buffer interface.
Definition: Buffer.h:200
Device context interface.
Definition: DeviceContext.h:443
virtual void * GetNativeHandle() override final
Returns native buffer handle specific to the underlying graphics API.
Definition: BufferD3D12Impl.h:90
Buffer description.
Definition: Buffer.h:57
Memory allocator that allocates memory in a fixed-size chunks.
Definition: FixedBlockMemoryAllocator.h:50
virtual void Map(IDeviceContext *pContext, MAP_TYPE MapType, Uint32 MapFlags, PVoid &pMappedData) override
Base implementation of IBuffer::Map(); validates input parameters.
Definition: BufferD3D12Impl.cpp:289
BufferDesc m_Desc
Object description.
Definition: DeviceObjectBase.h:138
virtual void CopyData(IDeviceContext *pContext, IBuffer *pSrcBuffer, Uint32 SrcOffset, Uint32 DstOffset, Uint32 Size) override
Base implementation of IBuffer::CopyData(); validates input parameters.
Definition: BufferD3D12Impl.cpp:282
A buffer or a texture can be bound as an unordered access view.
Definition: GraphicsTypes.h:73
Uint32 BindFlags
Buffer bind flags, see Diligent::BIND_FLAGS for details.
Definition: Buffer.h:68
virtual void SetD3D12ResourceState(D3D12_RESOURCE_STATES state) override final
Sets the buffer usage state.
Definition: BufferD3D12Impl.h:99
virtual void Unmap(IDeviceContext *pContext, MAP_TYPE MapType, Uint32 MapFlags) override
Base implementation of IBuffer::Unmap()
Definition: BufferD3D12Impl.cpp:344
MAP_TYPE
Resource mapping type.
Definition: GraphicsTypes.h:125
A resource that can be read by the GPU and written at least once per frame by the CPU...
Definition: GraphicsTypes.h:99
Implementation of the Diligent::IRenderDeviceD3D12 interface.
Definition: RenderDeviceD3D12Impl.h:43