summaryrefslogtreecommitdiffstats
path: root/Graphics/GraphicsEngineD3D12
diff options
context:
space:
mode:
authorazhirnov <zh1dron@gmail.com>2020-11-07 19:34:49 +0000
committerassiduous <assiduous@diligentgraphics.com>2020-11-10 03:43:28 +0000
commit0f35896a60c4de02ccfc91ace18bcef4450fa4d9 (patch)
tree86a772a36c6c2258949231b756970a621b69f82b /Graphics/GraphicsEngineD3D12
parentCorrected ray rtacing vertex format handling in D3D12 (diff)
downloadDiligentCore-0f35896a60c4de02ccfc91ace18bcef4450fa4d9.tar.gz
DiligentCore-0f35896a60c4de02ccfc91ace18bcef4450fa4d9.zip
Added ability to update AS.
Diffstat (limited to 'Graphics/GraphicsEngineD3D12')
-rw-r--r--Graphics/GraphicsEngineD3D12/include/BottomLevelASD3D12Impl.hpp6
-rw-r--r--Graphics/GraphicsEngineD3D12/include/RenderDeviceD3D12Impl.hpp14
-rw-r--r--Graphics/GraphicsEngineD3D12/include/ShaderBindingTableD3D12Impl.hpp9
-rw-r--r--Graphics/GraphicsEngineD3D12/include/ShaderResourceLayoutD3D12.hpp2
-rw-r--r--Graphics/GraphicsEngineD3D12/include/TopLevelASD3D12Impl.hpp6
-rw-r--r--Graphics/GraphicsEngineD3D12/interface/PipelineStateD3D12.h1
-rw-r--r--Graphics/GraphicsEngineD3D12/interface/RenderDeviceD3D12.h34
-rw-r--r--Graphics/GraphicsEngineD3D12/src/BottomLevelASD3D12Impl.cpp26
-rw-r--r--Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp114
-rw-r--r--Graphics/GraphicsEngineD3D12/src/PipelineStateD3D12Impl.cpp20
-rw-r--r--Graphics/GraphicsEngineD3D12/src/RenderDeviceD3D12Impl.cpp45
-rw-r--r--Graphics/GraphicsEngineD3D12/src/RootSignature.cpp4
-rw-r--r--Graphics/GraphicsEngineD3D12/src/ShaderBindingTableD3D12Impl.cpp10
-rw-r--r--Graphics/GraphicsEngineD3D12/src/ShaderResourceLayoutD3D12.cpp17
-rw-r--r--Graphics/GraphicsEngineD3D12/src/TopLevelASD3D12Impl.cpp16
15 files changed, 233 insertions, 91 deletions
diff --git a/Graphics/GraphicsEngineD3D12/include/BottomLevelASD3D12Impl.hpp b/Graphics/GraphicsEngineD3D12/include/BottomLevelASD3D12Impl.hpp
index c16d8473..12118e18 100644
--- a/Graphics/GraphicsEngineD3D12/include/BottomLevelASD3D12Impl.hpp
+++ b/Graphics/GraphicsEngineD3D12/include/BottomLevelASD3D12Impl.hpp
@@ -47,8 +47,12 @@ public:
BottomLevelASD3D12Impl(IReferenceCounters* pRefCounters,
class RenderDeviceD3D12Impl* pDeviceD3D12,
+ const BottomLevelASDesc& Desc);
+ BottomLevelASD3D12Impl(IReferenceCounters* pRefCounters,
+ class RenderDeviceD3D12Impl* pDeviceD3D12,
const BottomLevelASDesc& Desc,
- bool bIsDeviceInternal = false);
+ RESOURCE_STATE InitialState,
+ ID3D12Resource* pd3d12BLAS);
~BottomLevelASD3D12Impl();
IMPLEMENT_QUERY_INTERFACE_IN_PLACE(IID_BottomLevelASD3D12, TBottomLevelASBase);
diff --git a/Graphics/GraphicsEngineD3D12/include/RenderDeviceD3D12Impl.hpp b/Graphics/GraphicsEngineD3D12/include/RenderDeviceD3D12Impl.hpp
index ad48b876..5c4ad160 100644
--- a/Graphics/GraphicsEngineD3D12/include/RenderDeviceD3D12Impl.hpp
+++ b/Graphics/GraphicsEngineD3D12/include/RenderDeviceD3D12Impl.hpp
@@ -133,6 +133,18 @@ public:
RESOURCE_STATE InitialState,
IBuffer** ppBuffer) override final;
+ /// Implementation of IRenderDeviceD3D12::CreateBLASFromD3DResource().
+ virtual void DILIGENT_CALL_TYPE CreateBLASFromD3DResource(ID3D12Resource* pd3d12BLAS,
+ const BottomLevelASDesc& Desc,
+ RESOURCE_STATE InitialState,
+ IBottomLevelAS** ppBLAS) override final;
+
+ /// Implementation of IRenderDeviceD3D12::CreateTLASFromD3DResource().
+ virtual void DILIGENT_CALL_TYPE CreateTLASFromD3DResource(ID3D12Resource* pd3d12TLAS,
+ const TopLevelASDesc& Desc,
+ RESOURCE_STATE InitialState,
+ ITopLevelAS** ppTLAS) override final;
+
DescriptorHeapAllocation AllocateDescriptor(D3D12_DESCRIPTOR_HEAP_TYPE Type, UINT Count = 1);
DescriptorHeapAllocation AllocateGPUDescriptors(D3D12_DESCRIPTOR_HEAP_TYPE Type, UINT Count = 1);
@@ -180,7 +192,7 @@ public:
const Uint32 ShaderGroupHandleSize = D3D12_SHADER_IDENTIFIER_SIZE_IN_BYTES;
const Uint32 MaxShaderRecordStride = D3D12_RAYTRACING_MAX_SHADER_RECORD_STRIDE;
const Uint32 ShaderGroupBaseAlignment = D3D12_RAYTRACING_SHADER_TABLE_BYTE_ALIGNMENT;
- const Uint32 MaxDrawMeshTasksCount = 64000;
+ const Uint32 MaxDrawMeshTasksCount = 64000; // from specs: https://microsoft.github.io/DirectX-Specs/d3d/MeshShader.html#dispatchmesh-api
ShaderVersion MaxShaderVersion;
};
diff --git a/Graphics/GraphicsEngineD3D12/include/ShaderBindingTableD3D12Impl.hpp b/Graphics/GraphicsEngineD3D12/include/ShaderBindingTableD3D12Impl.hpp
index 537f240a..ca1442c5 100644
--- a/Graphics/GraphicsEngineD3D12/include/ShaderBindingTableD3D12Impl.hpp
+++ b/Graphics/GraphicsEngineD3D12/include/ShaderBindingTableD3D12Impl.hpp
@@ -33,6 +33,7 @@
#include "ShaderBindingTableD3D12.h"
#include "RenderDeviceD3D12.h"
#include "ShaderBindingTableBase.hpp"
+#include "TopLevelASD3D12Impl.hpp"
#include "D3D12ResourceBase.hpp"
#include "RenderDeviceD3D12Impl.hpp"
#include "PipelineStateD3D12Impl.hpp"
@@ -41,10 +42,10 @@ namespace Diligent
{
/// Shader binding table object implementation in Direct3D12 backend.
-class ShaderBindingTableD3D12Impl final : public ShaderBindingTableBase<IShaderBindingTableD3D12, PipelineStateD3D12Impl, RenderDeviceD3D12Impl>, public D3D12ResourceBase
+class ShaderBindingTableD3D12Impl final : public ShaderBindingTableBase<IShaderBindingTableD3D12, PipelineStateD3D12Impl, TopLevelASD3D12Impl, RenderDeviceD3D12Impl>, public D3D12ResourceBase
{
public:
- using TShaderBindingTableBase = ShaderBindingTableBase<IShaderBindingTableD3D12, PipelineStateD3D12Impl, RenderDeviceD3D12Impl>;
+ using TShaderBindingTableBase = ShaderBindingTableBase<IShaderBindingTableD3D12, PipelineStateD3D12Impl, TopLevelASD3D12Impl, RenderDeviceD3D12Impl>;
ShaderBindingTableD3D12Impl(IReferenceCounters* pRefCounters,
class RenderDeviceD3D12Impl* pDeviceD3D12,
@@ -53,10 +54,6 @@ public:
~ShaderBindingTableD3D12Impl();
virtual void DILIGENT_CALL_TYPE QueryInterface(const INTERFACE_ID& IID, IObject** ppInterface) override final;
-
- virtual void DILIGENT_CALL_TYPE ResetHitGroups(Uint32 HitShadersPerInstance) override;
-
- virtual void DILIGENT_CALL_TYPE BindAll(const BindAllAttribs& Attribs) override;
};
} // namespace Diligent
diff --git a/Graphics/GraphicsEngineD3D12/include/ShaderResourceLayoutD3D12.hpp b/Graphics/GraphicsEngineD3D12/include/ShaderResourceLayoutD3D12.hpp
index fe161157..58a8141d 100644
--- a/Graphics/GraphicsEngineD3D12/include/ShaderResourceLayoutD3D12.hpp
+++ b/Graphics/GraphicsEngineD3D12/include/ShaderResourceLayoutD3D12.hpp
@@ -297,6 +297,8 @@ public:
SHADER_TYPE GetShaderType() const { return m_ShaderType; }
+ bool IsCompatibleWith(const ShaderResourceLayoutD3D12& ResLayout) const;
+
private:
const D3D12Resource& GetAssignedSampler(const D3D12Resource& TexSrv) const;
D3D12Resource& GetAssignedSampler(const D3D12Resource& TexSrv);
diff --git a/Graphics/GraphicsEngineD3D12/include/TopLevelASD3D12Impl.hpp b/Graphics/GraphicsEngineD3D12/include/TopLevelASD3D12Impl.hpp
index 3fa15e5e..522fd426 100644
--- a/Graphics/GraphicsEngineD3D12/include/TopLevelASD3D12Impl.hpp
+++ b/Graphics/GraphicsEngineD3D12/include/TopLevelASD3D12Impl.hpp
@@ -48,8 +48,12 @@ public:
TopLevelASD3D12Impl(IReferenceCounters* pRefCounters,
class RenderDeviceD3D12Impl* pDeviceD3D12,
+ const TopLevelASDesc& Desc);
+ TopLevelASD3D12Impl(IReferenceCounters* pRefCounters,
+ class RenderDeviceD3D12Impl* pDeviceD3D12,
const TopLevelASDesc& Desc,
- bool bIsDeviceInternal = false);
+ RESOURCE_STATE InitialState,
+ ID3D12Resource* pd3d12TLAS);
~TopLevelASD3D12Impl();
IMPLEMENT_QUERY_INTERFACE_IN_PLACE(IID_TopLevelASD3D12, TTopLevelASBase);
diff --git a/Graphics/GraphicsEngineD3D12/interface/PipelineStateD3D12.h b/Graphics/GraphicsEngineD3D12/interface/PipelineStateD3D12.h
index cd315d3e..bec8d338 100644
--- a/Graphics/GraphicsEngineD3D12/interface/PipelineStateD3D12.h
+++ b/Graphics/GraphicsEngineD3D12/interface/PipelineStateD3D12.h
@@ -75,6 +75,7 @@ DILIGENT_END_INTERFACE
// clang-format off
# define IPipelineStateD3D12_GetD3D12PipelineState(This) CALL_IFACE_METHOD(PipelineStateD3D12, GetD3D12PipelineState, This)
+# define IPipelineStateD3D12_GetD3D12StateObject(This) CALL_IFACE_METHOD(PipelineStateD3D12, GetD3D12StateObject, This)
# define IPipelineStateD3D12_GetD3D12RootSignature(This) CALL_IFACE_METHOD(PipelineStateD3D12, GetD3D12RootSignature, This)
// clang-format on
diff --git a/Graphics/GraphicsEngineD3D12/interface/RenderDeviceD3D12.h b/Graphics/GraphicsEngineD3D12/interface/RenderDeviceD3D12.h
index 136f7307..8d8d1fba 100644
--- a/Graphics/GraphicsEngineD3D12/interface/RenderDeviceD3D12.h
+++ b/Graphics/GraphicsEngineD3D12/interface/RenderDeviceD3D12.h
@@ -99,6 +99,38 @@ DILIGENT_BEGIN_INTERFACE(IRenderDeviceD3D12, IRenderDevice)
const BufferDesc REF BuffDesc,
RESOURCE_STATE InitialState,
IBuffer** ppBuffer) PURE;
+
+ /// Creates a bottom-level AS object from native d3d12 resoruce
+
+ /// \param [in] pd3d12BLAS - Pointer to the native d3d12 acceleration structure resource
+ /// \param [in] Desc - Bottom-level AS description.
+ /// \param [in] InitialState - Initial BLAS state. Can be RESOURCE_STATE_UNKNOWN, RESOURCE_STATE_BUILD_AS_READ, RESOURCE_STATE_BUILD_AS_WRITE.
+ /// See Diligent::RESOURCE_STATE.
+ /// \param [out] ppBLAS - Address of the memory location where the pointer to the
+ /// bottom-level AS interface will be stored.
+ /// The function calls AddRef(), so that the new object will contain
+ /// one reference.
+ VIRTUAL void METHOD(CreateBLASFromD3DResource)(THIS_
+ ID3D12Resource* pd3d12BLAS,
+ const BottomLevelASDesc REF Desc,
+ RESOURCE_STATE InitialState,
+ IBottomLevelAS** ppBLAS) PURE;
+
+ /// Creates a top-level AS object from native d3d12 resoruce
+
+ /// \param [in] pd3d12TLAS - Pointer to the native d3d12 acceleration structure resource
+ /// \param [in] Desc - Top-level AS description.
+ /// \param [in] InitialState - Initial TLAS state. Can be RESOURCE_STATE_UNKNOWN, RESOURCE_STATE_BUILD_AS_READ, RESOURCE_STATE_BUILD_AS_WRITE, RESOURCE_STATE_RAY_TRACING.
+ /// See Diligent::RESOURCE_STATE.
+ /// \param [out] ppTLAS - Address of the memory location where the pointer to the
+ /// top-level AS interface will be stored.
+ /// The function calls AddRef(), so that the new object will contain
+ /// one reference.
+ VIRTUAL void METHOD(CreateTLASFromD3DResource)(THIS_
+ ID3D12Resource* pd3d12TLAS,
+ const TopLevelASDesc REF Desc,
+ RESOURCE_STATE InitialState,
+ ITopLevelAS** ppTLAS) PURE;
};
DILIGENT_END_INTERFACE
@@ -114,6 +146,8 @@ DILIGENT_END_INTERFACE
# define IRenderDeviceD3D12_IsFenceSignaled(This, ...) CALL_IFACE_METHOD(RenderDeviceD3D12, IsFenceSignaled, This, __VA_ARGS__)
# define IRenderDeviceD3D12_CreateTextureFromD3DResource(This, ...) CALL_IFACE_METHOD(RenderDeviceD3D12, CreateTextureFromD3DResource, This, __VA_ARGS__)
# define IRenderDeviceD3D12_CreateBufferFromD3DResource(This, ...) CALL_IFACE_METHOD(RenderDeviceD3D12, CreateBufferFromD3DResource, This, __VA_ARGS__)
+# define IRenderDeviceD3D12_CreateBLASFromD3DResource(This, ...) CALL_IFACE_METHOD(RenderDeviceD3D12, CreateBLASFromD3DResource, This, __VA_ARGS__)
+# define IRenderDeviceD3D12_CreateTLASFromD3DResource(This, ...) CALL_IFACE_METHOD(RenderDeviceD3D12, CreateTLASFromD3DResource, This, __VA_ARGS__)
// clang-format on
diff --git a/Graphics/GraphicsEngineD3D12/src/BottomLevelASD3D12Impl.cpp b/Graphics/GraphicsEngineD3D12/src/BottomLevelASD3D12Impl.cpp
index fa82ee9a..d2e119b3 100644
--- a/Graphics/GraphicsEngineD3D12/src/BottomLevelASD3D12Impl.cpp
+++ b/Graphics/GraphicsEngineD3D12/src/BottomLevelASD3D12Impl.cpp
@@ -38,9 +38,8 @@ namespace Diligent
BottomLevelASD3D12Impl::BottomLevelASD3D12Impl(IReferenceCounters* pRefCounters,
class RenderDeviceD3D12Impl* pDeviceD3D12,
- const BottomLevelASDesc& Desc,
- bool bIsDeviceInternal) :
- TBottomLevelASBase{pRefCounters, pDeviceD3D12, Desc, bIsDeviceInternal}
+ const BottomLevelASDesc& Desc) :
+ TBottomLevelASBase{pRefCounters, pDeviceD3D12, Desc}
{
auto* pd3d12Device = pDeviceD3D12->GetD3D12Device5();
UINT64 ResultDataMaxSizeInBytes = 0;
@@ -66,15 +65,15 @@ BottomLevelASD3D12Impl::BottomLevelASD3D12Impl(IReferenceCounters* pRef
dst.Type = D3D12_RAYTRACING_GEOMETRY_TYPE_TRIANGLES;
dst.Flags = D3D12_RAYTRACING_GEOMETRY_FLAG_NONE;
+ dst.Triangles.IndexCount = src.IndexType == VT_UNDEFINED ? 0 : src.MaxPrimitiveCount * 3;
+ dst.Triangles.IndexFormat = ValueTypeToIndexType(src.IndexType);
+ dst.Triangles.IndexBuffer = 0;
+ dst.Triangles.Transform3x4 = 0;
dst.Triangles.VertexBuffer.StartAddress = 0;
dst.Triangles.VertexBuffer.StrideInBytes = 0;
+ dst.Triangles.VertexCount = src.MaxVertexCount;
dst.Triangles.VertexFormat = TypeToRayTracingVertexFormat(src.VertexValueType, src.VertexComponentCount);
VERIFY(dst.Triangles.VertexFormat != DXGI_FORMAT_UNKNOWN, "Unsupported combination of vertex value type and component count");
- dst.Triangles.VertexCount = src.MaxVertexCount;
- dst.Triangles.IndexCount = src.IndexType == VT_UNDEFINED ? 0 : src.MaxPrimitiveCount * 3;
- dst.Triangles.IndexFormat = ValueTypeToIndexType(src.IndexType);
- dst.Triangles.IndexBuffer = 0;
- dst.Triangles.Transform3x4 = 0;
MaxPrimitiveCount += src.MaxPrimitiveCount;
}
@@ -157,6 +156,17 @@ BottomLevelASD3D12Impl::BottomLevelASD3D12Impl(IReferenceCounters* pRef
SetState(RESOURCE_STATE_BUILD_AS_READ);
}
+BottomLevelASD3D12Impl::BottomLevelASD3D12Impl(IReferenceCounters* pRefCounters,
+ class RenderDeviceD3D12Impl* pDeviceD3D12,
+ const BottomLevelASDesc& Desc,
+ RESOURCE_STATE InitialState,
+ ID3D12Resource* pd3d12BLAS) :
+ TBottomLevelASBase{pRefCounters, pDeviceD3D12, Desc}
+{
+ m_pd3d12Resource = pd3d12BLAS;
+ SetState(InitialState);
+}
+
BottomLevelASD3D12Impl::~BottomLevelASD3D12Impl()
{
// D3D12 object can only be destroyed when it is no longer used by the GPU
diff --git a/Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp b/Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp
index c78976ea..3d1c836f 100644
--- a/Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp
+++ b/Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp
@@ -2277,14 +2277,14 @@ void DeviceContextD3D12Impl::BuildBLAS(const BuildBLASAttribs& Attribs)
if (!TDeviceContextBase::BuildBLAS(Attribs, 0))
return;
- auto* const pBLASD12 = ValidatedCast<BottomLevelASD3D12Impl>(Attribs.pBLAS);
- auto* const pScratchD12 = ValidatedCast<BufferD3D12Impl>(Attribs.pScratchBuffer);
- const auto& BLASDesc = pBLASD12->GetDesc();
+ auto* const pBLASD3D12 = ValidatedCast<BottomLevelASD3D12Impl>(Attribs.pBLAS);
+ auto* const pScratchD3D12 = ValidatedCast<BufferD3D12Impl>(Attribs.pScratchBuffer);
+ const auto& BLASDesc = pBLASD3D12->GetDesc();
auto& CmdCtx = GetCmdContext();
const char* OpName = "Build BottomLevelAS (DeviceContextD3D12Impl::BuildBLAS)";
- TransitionOrVerifyBLASState(CmdCtx, *pBLASD12, Attribs.BLASTransitionMode, RESOURCE_STATE_BUILD_AS_WRITE, OpName);
- TransitionOrVerifyBufferState(CmdCtx, *pScratchD12, Attribs.ScratchBufferTransitionMode, RESOURCE_STATE_BUILD_AS_WRITE, OpName);
+ TransitionOrVerifyBLASState(CmdCtx, *pBLASD3D12, Attribs.BLASTransitionMode, RESOURCE_STATE_BUILD_AS_WRITE, OpName);
+ TransitionOrVerifyBufferState(CmdCtx, *pScratchD3D12, Attribs.ScratchBufferTransitionMode, RESOURCE_STATE_BUILD_AS_WRITE, OpName);
D3D12_BUILD_RAYTRACING_ACCELERATION_STRUCTURE_DESC d3d12BuildASDesc = {};
D3D12_BUILD_RAYTRACING_ACCELERATION_STRUCTURE_INPUTS& d3d12BuildASInputs = d3d12BuildASDesc.Inputs;
@@ -2293,19 +2293,21 @@ void DeviceContextD3D12Impl::BuildBLAS(const BuildBLASAttribs& Attribs)
if (Attribs.pTriangleData != nullptr)
{
Geometries.resize(Attribs.TriangleDataCount);
+ pBLASD3D12->SetActualGeometryCount(Attribs.TriangleDataCount);
for (Uint32 i = 0; i < Attribs.TriangleDataCount; ++i)
{
const auto& SrcTris = Attribs.pTriangleData[i];
- Uint32 GeoIdx = pBLASD12->GetGeometryIndex(SrcTris.GeometryName);
+ Uint32 Idx = i;
+ Uint32 GeoIdx = pBLASD3D12->UpdateGeometryIndex(SrcTris.GeometryName, Idx, Attribs.Update);
- if (GeoIdx >= Geometries.size())
+ if (GeoIdx == INVALID_INDEX || Idx == INVALID_INDEX)
{
UNEXPECTED("Failed to find geometry by name");
continue;
}
- auto& d3d12Geo = Geometries[GeoIdx];
+ auto& d3d12Geo = Geometries[Idx];
auto& d3d12Tris = d3d12Geo.Triangles;
const auto& TriDesc = BLASDesc.pTriangles[GeoIdx];
@@ -2315,11 +2317,11 @@ void DeviceContextD3D12Impl::BuildBLAS(const BuildBLASAttribs& Attribs)
auto* const pVB = ValidatedCast<BufferD3D12Impl>(SrcTris.pVertexBuffer);
// vertex format in SrcTris may be undefined, so use vertex format from description
- d3d12Tris.VertexFormat = TypeToRayTracingVertexFormat(TriDesc.VertexValueType, TriDesc.VertexComponentCount);
- VERIFY(d3d12Tris.VertexFormat != DXGI_FORMAT_UNKNOWN, "Unsupported combination of vertex value type and component count");
- d3d12Tris.VertexCount = SrcTris.VertexCount;
d3d12Tris.VertexBuffer.StartAddress = pVB->GetGPUAddress() + SrcTris.VertexOffset;
d3d12Tris.VertexBuffer.StrideInBytes = SrcTris.VertexStride;
+ d3d12Tris.VertexCount = SrcTris.VertexCount;
+ d3d12Tris.VertexFormat = TypeToRayTracingVertexFormat(TriDesc.VertexValueType, TriDesc.VertexComponentCount);
+ VERIFY(d3d12Tris.VertexFormat != DXGI_FORMAT_UNKNOWN, "Unsupported combination of vertex value type and component count");
TransitionOrVerifyBufferState(CmdCtx, *pVB, Attribs.GeometryTransitionMode, RESOURCE_STATE_BUILD_AS_READ, OpName);
@@ -2358,19 +2360,21 @@ void DeviceContextD3D12Impl::BuildBLAS(const BuildBLASAttribs& Attribs)
else if (Attribs.pBoxData != nullptr)
{
Geometries.resize(Attribs.BoxDataCount);
+ pBLASD3D12->SetActualGeometryCount(Attribs.BoxDataCount);
for (Uint32 i = 0; i < Attribs.BoxDataCount; ++i)
{
const auto& SrcBoxes = Attribs.pBoxData[i];
- Uint32 GeoIdx = pBLASD12->GetGeometryIndex(SrcBoxes.GeometryName);
+ Uint32 Idx = i;
+ Uint32 GeoIdx = pBLASD3D12->UpdateGeometryIndex(SrcBoxes.GeometryName, Idx, Attribs.Update);
- if (GeoIdx >= Geometries.size())
+ if (GeoIdx == INVALID_INDEX || Idx == INVALID_INDEX)
{
UNEXPECTED("Failed to find geometry by name");
continue;
}
- auto& d3d12Geo = Geometries[GeoIdx];
+ auto& d3d12Geo = Geometries[Idx];
auto& d3d12AABs = d3d12Geo.AABBs;
d3d12Geo.Type = D3D12_RAYTRACING_GEOMETRY_TYPE_PROCEDURAL_PRIMITIVE_AABBS;
@@ -2393,10 +2397,16 @@ void DeviceContextD3D12Impl::BuildBLAS(const BuildBLASAttribs& Attribs)
d3d12BuildASInputs.NumDescs = static_cast<UINT>(Geometries.size());
d3d12BuildASInputs.pGeometryDescs = Geometries.data();
- d3d12BuildASDesc.DestAccelerationStructureData = pBLASD12->GetGPUAddress();
- d3d12BuildASDesc.ScratchAccelerationStructureData = pScratchD12->GetGPUAddress() + Attribs.ScratchBufferOffset;
+ d3d12BuildASDesc.DestAccelerationStructureData = pBLASD3D12->GetGPUAddress();
+ d3d12BuildASDesc.ScratchAccelerationStructureData = pScratchD3D12->GetGPUAddress() + Attribs.ScratchBufferOffset;
d3d12BuildASDesc.SourceAccelerationStructureData = 0;
+ if (Attribs.Update)
+ {
+ d3d12BuildASInputs.Flags |= D3D12_RAYTRACING_ACCELERATION_STRUCTURE_BUILD_FLAG_PERFORM_UPDATE;
+ d3d12BuildASDesc.SourceAccelerationStructureData = d3d12BuildASDesc.DestAccelerationStructureData;
+ }
+
DEV_CHECK_ERR(d3d12BuildASDesc.ScratchAccelerationStructureData % D3D12_RAYTRACING_ACCELERATION_STRUCTURE_BYTE_ALIGNMENT == 0,
"Scratch data address is not properly aligned");
@@ -2404,7 +2414,7 @@ void DeviceContextD3D12Impl::BuildBLAS(const BuildBLASAttribs& Attribs)
++m_State.NumCommands;
#ifdef DILIGENT_DEVELOPMENT
- pBLASD12->UpdateVersion();
+ pBLASD3D12->UpdateVersion();
#endif
}
@@ -2415,16 +2425,25 @@ void DeviceContextD3D12Impl::BuildTLAS(const BuildTLASAttribs& Attribs)
static_assert(TLAS_INSTANCE_DATA_SIZE == sizeof(D3D12_RAYTRACING_INSTANCE_DESC), "Value in TLAS_INSTANCE_DATA_SIZE doesn't match the actual instance description size");
- auto* pTLASD12 = ValidatedCast<TopLevelASD3D12Impl>(Attribs.pTLAS);
- auto* pScratchD12 = ValidatedCast<BufferD3D12Impl>(Attribs.pScratchBuffer);
- auto* pInstancesD12 = ValidatedCast<BufferD3D12Impl>(Attribs.pInstanceBuffer);
+ auto* pTLASD3D12 = ValidatedCast<TopLevelASD3D12Impl>(Attribs.pTLAS);
+ auto* pScratchD3D12 = ValidatedCast<BufferD3D12Impl>(Attribs.pScratchBuffer);
+ auto* pInstancesD3D12 = ValidatedCast<BufferD3D12Impl>(Attribs.pInstanceBuffer);
auto& CmdCtx = GetCmdContext();
const char* OpName = "Build TopLevelAS (DeviceContextD3D12Impl::BuildTLAS)";
- TransitionOrVerifyTLASState(CmdCtx, *pTLASD12, Attribs.TLASTransitionMode, RESOURCE_STATE_BUILD_AS_WRITE, OpName);
- TransitionOrVerifyBufferState(CmdCtx, *pScratchD12, Attribs.ScratchBufferTransitionMode, RESOURCE_STATE_BUILD_AS_WRITE, OpName);
+ TransitionOrVerifyTLASState(CmdCtx, *pTLASD3D12, Attribs.TLASTransitionMode, RESOURCE_STATE_BUILD_AS_WRITE, OpName);
+ TransitionOrVerifyBufferState(CmdCtx, *pScratchD3D12, Attribs.ScratchBufferTransitionMode, RESOURCE_STATE_BUILD_AS_WRITE, OpName);
- pTLASD12->SetInstanceData(Attribs.pInstances, Attribs.InstanceCount, Attribs.HitShadersPerInstance);
+ if (Attribs.Update)
+ {
+ if (!pTLASD3D12->UpdateInstances(Attribs.pInstances, Attribs.InstanceCount, Attribs.BaseContributionToHitGroupIndex, Attribs.HitShadersPerInstance, Attribs.BindingMode))
+ return;
+ }
+ else
+ {
+ if (!pTLASD3D12->SetInstanceData(Attribs.pInstances, Attribs.InstanceCount, Attribs.BaseContributionToHitGroupIndex, Attribs.HitShadersPerInstance, Attribs.BindingMode))
+ return;
+ }
// copy instance data into instance buffer
{
@@ -2433,38 +2452,52 @@ void DeviceContextD3D12Impl::BuildTLAS(const BuildTLASAttribs& Attribs)
for (Uint32 i = 0; i < Attribs.InstanceCount; ++i)
{
- const auto& Inst = Attribs.pInstances[i];
- auto& d3d12Inst = static_cast<D3D12_RAYTRACING_INSTANCE_DESC*>(TmpSpace.CPUAddress)[i];
- auto* const pBLASD12 = ValidatedCast<BottomLevelASD3D12Impl>(Inst.pBLAS);
+ const auto& Inst = Attribs.pInstances[i];
+ const auto InstDesc = pTLASD3D12->GetInstanceDesc(Inst.InstanceName);
+
+ if (InstDesc.InstanceIndex >= Attribs.InstanceCount)
+ {
+ UNEXPECTED("Failed to find instance by name");
+ return;
+ }
+
+ auto& d3d12Inst = static_cast<D3D12_RAYTRACING_INSTANCE_DESC*>(TmpSpace.CPUAddress)[InstDesc.InstanceIndex];
+ auto* pBLASD3D12 = ValidatedCast<BottomLevelASD3D12Impl>(Inst.pBLAS);
static_assert(sizeof(d3d12Inst.Transform) == sizeof(Inst.Transform), "size mismatch");
std::memcpy(&d3d12Inst.Transform, Inst.Transform.data, sizeof(d3d12Inst.Transform));
d3d12Inst.InstanceID = Inst.CustomId;
- d3d12Inst.InstanceContributionToHitGroupIndex = pTLASD12->GetInstanceDesc(Inst.InstanceName).ContributionToHitGroupIndex;
+ d3d12Inst.InstanceContributionToHitGroupIndex = InstDesc.ContributionToHitGroupIndex;
d3d12Inst.InstanceMask = Inst.Mask;
d3d12Inst.Flags = InstanceFlagsToD3D12RTInstanceFlags(Inst.Flags);
- d3d12Inst.AccelerationStructure = pBLASD12->GetGPUAddress();
+ d3d12Inst.AccelerationStructure = pBLASD3D12->GetGPUAddress();
- TransitionOrVerifyBLASState(CmdCtx, *pBLASD12, Attribs.BLASTransitionMode, RESOURCE_STATE_BUILD_AS_READ, OpName);
+ TransitionOrVerifyBLASState(CmdCtx, *pBLASD3D12, Attribs.BLASTransitionMode, RESOURCE_STATE_BUILD_AS_READ, OpName);
}
- UpdateBufferRegion(pInstancesD12, TmpSpace, Attribs.InstanceBufferOffset, Size, Attribs.InstanceBufferTransitionMode);
+ UpdateBufferRegion(pInstancesD3D12, TmpSpace, Attribs.InstanceBufferOffset, Size, Attribs.InstanceBufferTransitionMode);
}
- TransitionOrVerifyBufferState(CmdCtx, *pInstancesD12, Attribs.InstanceBufferTransitionMode, RESOURCE_STATE_BUILD_AS_READ, OpName);
+ TransitionOrVerifyBufferState(CmdCtx, *pInstancesD3D12, Attribs.InstanceBufferTransitionMode, RESOURCE_STATE_BUILD_AS_READ, OpName);
D3D12_BUILD_RAYTRACING_ACCELERATION_STRUCTURE_DESC d3d12BuildASDesc = {};
D3D12_BUILD_RAYTRACING_ACCELERATION_STRUCTURE_INPUTS& d3d12BuildASInputs = d3d12BuildASDesc.Inputs;
d3d12BuildASInputs.Type = D3D12_RAYTRACING_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL;
- d3d12BuildASInputs.Flags = BuildASFlagsToD3D12ASBuildFlags(pTLASD12->GetDesc().Flags);
+ d3d12BuildASInputs.Flags = BuildASFlagsToD3D12ASBuildFlags(pTLASD3D12->GetDesc().Flags);
d3d12BuildASInputs.DescsLayout = D3D12_ELEMENTS_LAYOUT_ARRAY;
d3d12BuildASInputs.NumDescs = Attribs.InstanceCount;
- d3d12BuildASInputs.InstanceDescs = pInstancesD12->GetGPUAddress() + Attribs.InstanceBufferOffset;
+ d3d12BuildASInputs.InstanceDescs = pInstancesD3D12->GetGPUAddress() + Attribs.InstanceBufferOffset;
- d3d12BuildASDesc.DestAccelerationStructureData = pTLASD12->GetGPUAddress();
- d3d12BuildASDesc.ScratchAccelerationStructureData = pScratchD12->GetGPUAddress() + Attribs.ScratchBufferOffset;
+ d3d12BuildASDesc.DestAccelerationStructureData = pTLASD3D12->GetGPUAddress();
+ d3d12BuildASDesc.ScratchAccelerationStructureData = pScratchD3D12->GetGPUAddress() + Attribs.ScratchBufferOffset;
d3d12BuildASDesc.SourceAccelerationStructureData = 0;
+ if (Attribs.Update)
+ {
+ d3d12BuildASInputs.Flags |= D3D12_RAYTRACING_ACCELERATION_STRUCTURE_BUILD_FLAG_PERFORM_UPDATE;
+ d3d12BuildASDesc.SourceAccelerationStructureData = d3d12BuildASDesc.DestAccelerationStructureData;
+ }
+
DEV_CHECK_ERR(d3d12BuildASInputs.InstanceDescs % D3D12_RAYTRACING_INSTANCE_DESCS_BYTE_ALIGNMENT == 0,
"Instance data address is not properly aligned");
DEV_CHECK_ERR(d3d12BuildASDesc.ScratchAccelerationStructureData % D3D12_RAYTRACING_ACCELERATION_STRUCTURE_BYTE_ALIGNMENT == 0,
@@ -2486,7 +2519,8 @@ void DeviceContextD3D12Impl::CopyBLAS(const CopyBLASAttribs& Attribs)
// Dst BLAS description has specified CompactedSize, but doesn't have specified pTriangles and pBoxes.
// We should copy geometries because it required for SBT to map geometry name to hit group.
- pDstD3D12->CopyDescription(*pSrcD3D12);
+ pDstD3D12->CopyGeometryDescription(*pSrcD3D12);
+ pDstD3D12->SetActualGeometryCount(pSrcD3D12->GetActualGeometryCount());
const char* OpName = "Copy BottomLevelAS (DeviceContextD3D12Impl::CopyBLAS)";
TransitionOrVerifyBLASState(CmdCtx, *pSrcD3D12, Attribs.SrcTransitionMode, RESOURCE_STATE_BUILD_AS_READ, OpName);
@@ -2579,16 +2613,16 @@ void DeviceContextD3D12Impl::TraceRays(const TraceRaysAttribs& Attribs)
VERIFY_EXPR((Attribs.DimensionX * Attribs.DimensionY * Attribs.DimensionZ) <= D3D12_RAYTRACING_MAX_RAY_GENERATION_SHADER_THREADS);
- auto& CmdCtx = GetCmdContext().AsGraphicsContext4();
- auto* pSBTD12 = ValidatedCast<ShaderBindingTableD3D12Impl>(Attribs.pSBT);
- IBuffer* pBuffer = nullptr;
+ auto& CmdCtx = GetCmdContext().AsGraphicsContext4();
+ auto* pSBTD3D12 = ValidatedCast<ShaderBindingTableD3D12Impl>(Attribs.pSBT);
+ IBuffer* pBuffer = nullptr;
ShaderBindingTableD3D12Impl::BindingTable RayGenShaderRecord = {};
ShaderBindingTableD3D12Impl::BindingTable MissShaderTable = {};
ShaderBindingTableD3D12Impl::BindingTable HitGroupTable = {};
ShaderBindingTableD3D12Impl::BindingTable CallableShaderTable = {};
- pSBTD12->GetData(pBuffer, RayGenShaderRecord, MissShaderTable, HitGroupTable, CallableShaderTable);
+ pSBTD3D12->GetData(pBuffer, RayGenShaderRecord, MissShaderTable, HitGroupTable, CallableShaderTable);
auto* pBufferD3D12 = ValidatedCast<BufferD3D12Impl>(pBuffer);
diff --git a/Graphics/GraphicsEngineD3D12/src/PipelineStateD3D12Impl.cpp b/Graphics/GraphicsEngineD3D12/src/PipelineStateD3D12Impl.cpp
index 1a12f25b..be30c978 100644
--- a/Graphics/GraphicsEngineD3D12/src/PipelineStateD3D12Impl.cpp
+++ b/Graphics/GraphicsEngineD3D12/src/PipelineStateD3D12Impl.cpp
@@ -729,16 +729,17 @@ void PipelineStateD3D12Impl::InitResourceLayouts(const PipelineStateCreateInfo&
auto pd3d12Device = GetDevice()->GetD3D12Device();
const auto& ResourceLayout = m_Desc.ResourceLayout;
- // AZ TODO
-#if 0 //def DILIGENT_DEVELOPMENT
+#ifdef DILIGENT_DEVELOPMENT
{
- const ShaderResources* pResources[MAX_SHADERS_IN_PIPELINE] = {};
+ std::vector<const ShaderResources*> Resources;
for (size_t s = 0; s < ShaderStages.size(); ++s)
{
- const auto* pShader = ShaderStages[s].Shaders[0];
- pResources[s] = &(*pShader->GetShaderResources());
+ for (auto* pShader : ShaderStages[s].Shaders)
+ {
+ Resources.push_back(&(*pShader->GetShaderResources()));
+ }
}
- ShaderResources::DvpVerifyResourceLayout(ResourceLayout, pResources, GetNumShaderStages(),
+ ShaderResources::DvpVerifyResourceLayout(ResourceLayout, Resources.data(), static_cast<Uint32>(Resources.size()),
(CreateInfo.Flags & PSO_CREATE_FLAG_IGNORE_MISSING_VARIABLES) == 0,
(CreateInfo.Flags & PSO_CREATE_FLAG_IGNORE_MISSING_IMMUTABLE_SAMPLERS) == 0);
}
@@ -832,8 +833,7 @@ bool PipelineStateD3D12Impl::IsCompatibleWith(const IPipelineState* pPSO) const
auto IsSameRootSignature = m_RootSig.IsSameAs(pPSOD3D12->m_RootSig);
- // AZ TODO
-#if 0 //def DILIGENT_DEBUG
+#ifdef DILIGENT_DEBUG
{
bool IsCompatibleShaders = true;
if (GetNumShaderStages() != pPSOD3D12->GetNumShaderStages())
@@ -849,8 +849,8 @@ bool PipelineStateD3D12Impl::IsCompatibleWith(const IPipelineState* pPSO) const
break;
}
- const auto& Res0 = GetShaderResLayout(s).GetResources();
- const auto& Res1 = pPSOD3D12->GetShaderResLayout(s).GetResources();
+ const auto& Res0 = GetShaderResLayout(s);
+ const auto& Res1 = pPSOD3D12->GetShaderResLayout(s);
if (!Res0.IsCompatibleWith(Res1))
{
IsCompatibleShaders = false;
diff --git a/Graphics/GraphicsEngineD3D12/src/RenderDeviceD3D12Impl.cpp b/Graphics/GraphicsEngineD3D12/src/RenderDeviceD3D12Impl.cpp
index 9ea84f06..76bf71c4 100644
--- a/Graphics/GraphicsEngineD3D12/src/RenderDeviceD3D12Impl.cpp
+++ b/Graphics/GraphicsEngineD3D12/src/RenderDeviceD3D12Impl.cpp
@@ -724,6 +724,19 @@ void RenderDeviceD3D12Impl::CreateFramebuffer(const FramebufferDesc& Desc, IFram
});
}
+void RenderDeviceD3D12Impl::CreateBLASFromD3DResource(ID3D12Resource* pd3d12BLAS,
+ const BottomLevelASDesc& Desc,
+ RESOURCE_STATE InitialState,
+ IBottomLevelAS** ppBLAS)
+{
+ CreateDeviceObject("buffer", Desc, ppBLAS,
+ [&]() //
+ {
+ BottomLevelASD3D12Impl* pBottomLevelASD3D12{NEW_RC_OBJ(m_BLASAllocator, "BottomLevelASD3D12Impl instance", BottomLevelASD3D12Impl)(this, Desc, InitialState, pd3d12BLAS)};
+ pBottomLevelASD3D12->QueryInterface(IID_BottomLevelAS, reinterpret_cast<IObject**>(ppBLAS));
+ OnCreateDeviceObject(pBottomLevelASD3D12);
+ });
+}
void RenderDeviceD3D12Impl::CreateBLAS(const BottomLevelASDesc& Desc,
IBottomLevelAS** ppBLAS)
@@ -731,9 +744,23 @@ void RenderDeviceD3D12Impl::CreateBLAS(const BottomLevelASDesc& Desc,
CreateDeviceObject("BottomLevelAS", Desc, ppBLAS,
[&]() //
{
- BottomLevelASD3D12Impl* pBottomLevelASVk(NEW_RC_OBJ(m_BLASAllocator, "BottomLevelASD3D12Impl instance", BottomLevelASD3D12Impl)(this, Desc));
- pBottomLevelASVk->QueryInterface(IID_BottomLevelAS, reinterpret_cast<IObject**>(ppBLAS));
- OnCreateDeviceObject(pBottomLevelASVk);
+ BottomLevelASD3D12Impl* pBottomLevelASD3D12(NEW_RC_OBJ(m_BLASAllocator, "BottomLevelASD3D12Impl instance", BottomLevelASD3D12Impl)(this, Desc));
+ pBottomLevelASD3D12->QueryInterface(IID_BottomLevelAS, reinterpret_cast<IObject**>(ppBLAS));
+ OnCreateDeviceObject(pBottomLevelASD3D12);
+ });
+}
+
+void RenderDeviceD3D12Impl::CreateTLASFromD3DResource(ID3D12Resource* pd3d12TLAS,
+ const TopLevelASDesc& Desc,
+ RESOURCE_STATE InitialState,
+ ITopLevelAS** ppTLAS)
+{
+ CreateDeviceObject("TopLevelAS", Desc, ppTLAS,
+ [&]() //
+ {
+ TopLevelASD3D12Impl* pTopLevelASD3D12{NEW_RC_OBJ(m_TLASAllocator, "TopLevelASD3D12Impl instance", TopLevelASD3D12Impl)(this, Desc, InitialState, pd3d12TLAS)};
+ pTopLevelASD3D12->QueryInterface(IID_TopLevelAS, reinterpret_cast<IObject**>(ppTLAS));
+ OnCreateDeviceObject(pTopLevelASD3D12);
});
}
@@ -743,9 +770,9 @@ void RenderDeviceD3D12Impl::CreateTLAS(const TopLevelASDesc& Desc,
CreateDeviceObject("TopLevelAS", Desc, ppTLAS,
[&]() //
{
- TopLevelASD3D12Impl* pTopLevelASVk(NEW_RC_OBJ(m_TLASAllocator, "TopLevelASD3D12Impl instance", TopLevelASD3D12Impl)(this, Desc));
- pTopLevelASVk->QueryInterface(IID_TopLevelAS, reinterpret_cast<IObject**>(ppTLAS));
- OnCreateDeviceObject(pTopLevelASVk);
+ TopLevelASD3D12Impl* pTopLevelASD3D12(NEW_RC_OBJ(m_TLASAllocator, "TopLevelASD3D12Impl instance", TopLevelASD3D12Impl)(this, Desc));
+ pTopLevelASD3D12->QueryInterface(IID_TopLevelAS, reinterpret_cast<IObject**>(ppTLAS));
+ OnCreateDeviceObject(pTopLevelASD3D12);
});
}
@@ -755,9 +782,9 @@ void RenderDeviceD3D12Impl::CreateSBT(const ShaderBindingTableDesc& Desc,
CreateDeviceObject("ShaderBindingTable", Desc, ppSBT,
[&]() //
{
- ShaderBindingTableD3D12Impl* pSBTVk(NEW_RC_OBJ(m_SBTAllocator, "ShaderBindingTableD3D12Impl instance", ShaderBindingTableD3D12Impl)(this, Desc));
- pSBTVk->QueryInterface(IID_ShaderBindingTable, reinterpret_cast<IObject**>(ppSBT));
- OnCreateDeviceObject(pSBTVk);
+ ShaderBindingTableD3D12Impl* pSBTD3D12(NEW_RC_OBJ(m_SBTAllocator, "ShaderBindingTableD3D12Impl instance", ShaderBindingTableD3D12Impl)(this, Desc));
+ pSBTD3D12->QueryInterface(IID_ShaderBindingTable, reinterpret_cast<IObject**>(ppSBT));
+ OnCreateDeviceObject(pSBTD3D12);
});
}
diff --git a/Graphics/GraphicsEngineD3D12/src/RootSignature.cpp b/Graphics/GraphicsEngineD3D12/src/RootSignature.cpp
index 8a8bfd4d..2ac15372 100644
--- a/Graphics/GraphicsEngineD3D12/src/RootSignature.cpp
+++ b/Graphics/GraphicsEngineD3D12/src/RootSignature.cpp
@@ -1154,10 +1154,10 @@ ID3D12RootSignature* LocalRootSignature::Create(ID3D12Device* pDevice)
CComPtr<ID3DBlob> signature;
auto hr = D3D12SerializeRootSignature(&d3d12RootSignatureDesc, D3D_ROOT_SIGNATURE_VERSION_1, &signature, nullptr);
- CHECK_D3D_RESULT_THROW(hr, "Failed to serialize root signature");
+ CHECK_D3D_RESULT_THROW(hr, "Failed to serialize local root signature");
hr = pDevice->CreateRootSignature(0, signature->GetBufferPointer(), signature->GetBufferSize(), IID_PPV_ARGS(&m_pd3d12RootSignature));
- CHECK_D3D_RESULT_THROW(hr, "Failed to create D3D12 root signature");
+ CHECK_D3D_RESULT_THROW(hr, "Failed to create D3D12 local root signature");
return m_pd3d12RootSignature;
}
diff --git a/Graphics/GraphicsEngineD3D12/src/ShaderBindingTableD3D12Impl.cpp b/Graphics/GraphicsEngineD3D12/src/ShaderBindingTableD3D12Impl.cpp
index ac67ba57..0e15bd4f 100644
--- a/Graphics/GraphicsEngineD3D12/src/ShaderBindingTableD3D12Impl.cpp
+++ b/Graphics/GraphicsEngineD3D12/src/ShaderBindingTableD3D12Impl.cpp
@@ -52,14 +52,4 @@ ShaderBindingTableD3D12Impl::~ShaderBindingTableD3D12Impl()
IMPLEMENT_QUERY_INTERFACE(ShaderBindingTableD3D12Impl, IID_ShaderBindingTableD3D12, TShaderBindingTableBase)
-void ShaderBindingTableD3D12Impl::ResetHitGroups(Uint32 HitShadersPerInstance)
-{
- // AZ TODO
-}
-
-void ShaderBindingTableD3D12Impl::BindAll(const BindAllAttribs& Attribs)
-{
- // AZ TODO
-}
-
} // namespace Diligent
diff --git a/Graphics/GraphicsEngineD3D12/src/ShaderResourceLayoutD3D12.cpp b/Graphics/GraphicsEngineD3D12/src/ShaderResourceLayoutD3D12.cpp
index 6218fbd3..5923797c 100644
--- a/Graphics/GraphicsEngineD3D12/src/ShaderResourceLayoutD3D12.cpp
+++ b/Graphics/GraphicsEngineD3D12/src/ShaderResourceLayoutD3D12.cpp
@@ -1104,4 +1104,21 @@ bool ShaderResourceLayoutD3D12::dvpVerifyBindings(const ShaderResourceCacheD3D12
}
#endif
+bool ShaderResourceLayoutD3D12::IsCompatibleWith(const ShaderResourceLayoutD3D12& ResLayout) const
+{
+ if (GetTotalResourceCount() != ResLayout.GetTotalResourceCount())
+ return false;
+
+ for (Uint32 i = 0; i < GetTotalResourceCount(); ++i)
+ {
+ const auto& lRes = GetResource(i);
+ const auto& rRes = ResLayout.GetResource(i);
+
+ if (!lRes.Attribs.IsCompatibleWith(rRes.Attribs))
+ return false;
+ }
+
+ return true;
+}
+
} // namespace Diligent
diff --git a/Graphics/GraphicsEngineD3D12/src/TopLevelASD3D12Impl.cpp b/Graphics/GraphicsEngineD3D12/src/TopLevelASD3D12Impl.cpp
index 51dadde1..dff2dcfb 100644
--- a/Graphics/GraphicsEngineD3D12/src/TopLevelASD3D12Impl.cpp
+++ b/Graphics/GraphicsEngineD3D12/src/TopLevelASD3D12Impl.cpp
@@ -38,9 +38,8 @@ namespace Diligent
TopLevelASD3D12Impl::TopLevelASD3D12Impl(IReferenceCounters* pRefCounters,
class RenderDeviceD3D12Impl* pDeviceD3D12,
- const TopLevelASDesc& Desc,
- bool bIsDeviceInternal) :
- TTopLevelASBase{pRefCounters, pDeviceD3D12, Desc, bIsDeviceInternal}
+ const TopLevelASDesc& Desc) :
+ TTopLevelASBase{pRefCounters, pDeviceD3D12, Desc}
{
auto* pd3d12Device = pDeviceD3D12->GetD3D12Device5();
UINT64 ResultDataMaxSizeInBytes = 0;
@@ -115,6 +114,17 @@ TopLevelASD3D12Impl::TopLevelASD3D12Impl(IReferenceCounters* pRefCounte
SetState(RESOURCE_STATE_BUILD_AS_READ);
}
+TopLevelASD3D12Impl::TopLevelASD3D12Impl(IReferenceCounters* pRefCounters,
+ class RenderDeviceD3D12Impl* pDeviceD3D12,
+ const TopLevelASDesc& Desc,
+ RESOURCE_STATE InitialState,
+ ID3D12Resource* pd3d12TLAS) :
+ TTopLevelASBase{pRefCounters, pDeviceD3D12, Desc}
+{
+ m_pd3d12Resource = pd3d12TLAS;
+ SetState(InitialState);
+}
+
TopLevelASD3D12Impl::~TopLevelASD3D12Impl()
{
// D3D12 object can only be destroyed when it is no longer used by the GPU