summaryrefslogtreecommitdiffstats
path: root/Graphics/GraphicsEngineD3D12
diff options
context:
space:
mode:
authorassiduous <assiduous@diligentgraphics.com>2020-10-30 21:18:45 +0000
committerassiduous <assiduous@diligentgraphics.com>2020-10-30 21:18:45 +0000
commit076e2f20ce80ef9ea6ccb351c2bfdc3b99ac8015 (patch)
treec750936f9e5cb8a3bb2743d8497b287245e596b3 /Graphics/GraphicsEngineD3D12
parentAdded include tests for BLAS, TLAS and SBT headers, fixed few issues (diff)
downloadDiligentCore-076e2f20ce80ef9ea6ccb351c2bfdc3b99ac8015.tar.gz
DiligentCore-076e2f20ce80ef9ea6ccb351c2bfdc3b99ac8015.zip
A number of minor updates
Diffstat (limited to 'Graphics/GraphicsEngineD3D12')
-rw-r--r--Graphics/GraphicsEngineD3D12/src/CommandContext.cpp11
-rw-r--r--Graphics/GraphicsEngineD3D12/src/D3D12TypeConversions.cpp36
-rw-r--r--Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp134
-rw-r--r--Graphics/GraphicsEngineD3D12/src/ShaderBindingTableD3D12Impl.cpp2
-rw-r--r--Graphics/GraphicsEngineD3D12/src/ShaderResourceLayoutD3D12.cpp6
-rw-r--r--Graphics/GraphicsEngineD3D12/src/TopLevelASD3D12Impl.cpp58
6 files changed, 124 insertions, 123 deletions
diff --git a/Graphics/GraphicsEngineD3D12/src/CommandContext.cpp b/Graphics/GraphicsEngineD3D12/src/CommandContext.cpp
index 6bc55ac3..4285e11a 100644
--- a/Graphics/GraphicsEngineD3D12/src/CommandContext.cpp
+++ b/Graphics/GraphicsEngineD3D12/src/CommandContext.cpp
@@ -171,9 +171,9 @@ void CommandContext::TransitionResource(const StateTransitionDesc& Barrier)
RESOURCE_STATE OldState = RESOURCE_STATE_UNKNOWN;
ID3D12Resource* pd3d12Resource = nullptr;
RefCntAutoPtr<TextureD3D12Impl> pTextureD3D12Impl{Barrier.pResource, IID_TextureD3D12};
- RefCntAutoPtr<BufferD3D12Impl> pBufferD3D12Impl{Barrier.pResource, IID_BufferD3D12};
- RefCntAutoPtr<BottomLevelASD3D12Impl> pBLASD3D12Impl{Barrier.pResource, IID_BottomLevelASD3D12};
- RefCntAutoPtr<TopLevelASD3D12Impl> pTLASD3D12Impl{Barrier.pResource, IID_TopLevelASD3D12};
+ RefCntAutoPtr<BufferD3D12Impl> pBufferD3D12Impl{pTextureD3D12Impl ? nullptr : Barrier.pResource, IID_BufferD3D12};
+ RefCntAutoPtr<BottomLevelASD3D12Impl> pBLASD3D12Impl{pBufferD3D12Impl ? nullptr : Barrier.pResource, IID_BottomLevelASD3D12};
+ RefCntAutoPtr<TopLevelASD3D12Impl> pTLASD3D12Impl{pBLASD3D12Impl ? nullptr : Barrier.pResource, IID_TopLevelASD3D12};
if (pTextureD3D12Impl)
{
@@ -324,9 +324,8 @@ void CommandContext::TransitionResource(const StateTransitionDesc& Barrier)
}
}
- if ((OldState == RESOURCE_STATE_UNORDERED_ACCESS && Barrier.NewState == RESOURCE_STATE_UNORDERED_ACCESS) ||
- (OldState == RESOURCE_STATE_BUILD_AS_WRITE && Barrier.NewState == RESOURCE_STATE_BUILD_AS_WRITE) ||
- (OldState == RESOURCE_STATE_RAY_TRACING && Barrier.NewState == RESOURCE_STATE_RAY_TRACING))
+ if ((OldState == RESOURCE_STATE_UNORDERED_ACCESS || OldState == RESOURCE_STATE_BUILD_AS_WRITE) &&
+ (Barrier.NewState == RESOURCE_STATE_UNORDERED_ACCESS || Barrier.NewState == RESOURCE_STATE_BUILD_AS_WRITE))
{
DEV_CHECK_ERR(Barrier.TransitionType == STATE_TRANSITION_TYPE_IMMEDIATE, "UAV barriers must not be split");
InsertUAVBarrier(pd3d12Resource);
diff --git a/Graphics/GraphicsEngineD3D12/src/D3D12TypeConversions.cpp b/Graphics/GraphicsEngineD3D12/src/D3D12TypeConversions.cpp
index ddab5096..a6d6963e 100644
--- a/Graphics/GraphicsEngineD3D12/src/D3D12TypeConversions.cpp
+++ b/Graphics/GraphicsEngineD3D12/src/D3D12TypeConversions.cpp
@@ -612,22 +612,21 @@ D3D12_RAYTRACING_GEOMETRY_FLAGS GeometryFlagsToD3D12RTGeometryFlags(RAYTRACING_G
static_assert(RAYTRACING_GEOMETRY_FLAGS_LAST == RAYTRACING_GEOMETRY_NO_DUPLICATE_ANY_HIT_INVOCATION,
"Please update the switch below to handle the new ray tracing geometry flag");
- Uint32 Result = 0;
- for (Uint32 Bit = 1; Bit <= Flags; Bit <<= 1)
+ D3D12_RAYTRACING_GEOMETRY_FLAGS Result = D3D12_RAYTRACING_GEOMETRY_FLAG_NONE;
+ while (Flags != RAYTRACING_GEOMETRY_NONE)
{
- if ((Flags & Bit) != Bit)
- continue;
-
- switch (static_cast<RAYTRACING_GEOMETRY_FLAGS>(Bit))
+ auto FlagBit = static_cast<RAYTRACING_GEOMETRY_FLAGS>(1 << PlatformMisc::GetLSB(Uint32{Flags}));
+ switch (FlagBit)
{
// clang-format off
- case RAYTRACING_GEOMETRY_OPAQUE: Result |= D3D12_RAYTRACING_GEOMETRY_FLAG_OPAQUE; break;
+ case RAYTRACING_GEOMETRY_OPAQUE: Result |= D3D12_RAYTRACING_GEOMETRY_FLAG_OPAQUE; break;
case RAYTRACING_GEOMETRY_NO_DUPLICATE_ANY_HIT_INVOCATION: Result |= D3D12_RAYTRACING_GEOMETRY_FLAG_NO_DUPLICATE_ANYHIT_INVOCATION; break;
// clang-format on
default: UNEXPECTED("unknown geometry flag");
}
+ Flags &= ~FlagBit;
}
- return static_cast<D3D12_RAYTRACING_GEOMETRY_FLAGS>(Result);
+ return Result;
}
D3D12_RAYTRACING_INSTANCE_FLAGS InstanceFlagsToD3D12RTInstanceFlags(RAYTRACING_INSTANCE_FLAGS Flags)
@@ -635,24 +634,23 @@ D3D12_RAYTRACING_INSTANCE_FLAGS InstanceFlagsToD3D12RTInstanceFlags(RAYTRACING_I
static_assert(RAYTRACING_INSTANCE_FLAGS_LAST == RAYTRACING_INSTANCE_FORCE_NO_OPAQUE,
"Please update the switch below to handle the new ray tracing instance flag");
- Uint32 Result = 0;
- for (Uint32 Bit = 1; Bit <= Flags; Bit <<= 1)
+ D3D12_RAYTRACING_INSTANCE_FLAGS Result = D3D12_RAYTRACING_INSTANCE_FLAG_NONE;
+ while (Flags != RAYTRACING_INSTANCE_NONE)
{
- if ((Flags & Bit) != Bit)
- continue;
-
- switch (static_cast<RAYTRACING_INSTANCE_FLAGS>(Bit))
+ auto FlagBit = static_cast<RAYTRACING_INSTANCE_FLAGS>(1 << PlatformMisc::GetLSB(Uint32{Flags}));
+ switch (FlagBit)
{
// clang-format off
- case RAYTRACING_INSTANCE_TRIANGLE_FACING_CULL_DISABLE: Result |= D3D12_RAYTRACING_INSTANCE_FLAG_TRIANGLE_CULL_DISABLE ; break;
- case RAYTRACING_INSTANCE_TRIANGLE_FRONT_COUNTERCLOCKWISE: Result |= D3D12_RAYTRACING_INSTANCE_FLAG_TRIANGLE_FRONT_COUNTERCLOCKWISE ; break;
- case RAYTRACING_INSTANCE_FORCE_OPAQUE: Result |= D3D12_RAYTRACING_INSTANCE_FLAG_FORCE_OPAQUE ; break;
- case RAYTRACING_INSTANCE_FORCE_NO_OPAQUE: Result |= D3D12_RAYTRACING_INSTANCE_FLAG_FORCE_NON_OPAQUE ; break;
+ case RAYTRACING_INSTANCE_TRIANGLE_FACING_CULL_DISABLE: Result |= D3D12_RAYTRACING_INSTANCE_FLAG_TRIANGLE_CULL_DISABLE; break;
+ case RAYTRACING_INSTANCE_TRIANGLE_FRONT_COUNTERCLOCKWISE: Result |= D3D12_RAYTRACING_INSTANCE_FLAG_TRIANGLE_FRONT_COUNTERCLOCKWISE; break;
+ case RAYTRACING_INSTANCE_FORCE_OPAQUE: Result |= D3D12_RAYTRACING_INSTANCE_FLAG_FORCE_OPAQUE; break;
+ case RAYTRACING_INSTANCE_FORCE_NO_OPAQUE: Result |= D3D12_RAYTRACING_INSTANCE_FLAG_FORCE_NON_OPAQUE; break;
// clang-format on
default: UNEXPECTED("unknown instance flag");
}
+ Flags &= ~FlagBit;
}
- return static_cast<D3D12_RAYTRACING_INSTANCE_FLAGS>(Result);
+ return Result;
}
} // namespace Diligent
diff --git a/Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp b/Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp
index 95025c4c..3cd896ac 100644
--- a/Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp
+++ b/Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp
@@ -2279,9 +2279,9 @@ void DeviceContextD3D12Impl::BuildBLAS(const BLASBuildAttribs& Attribs)
if (!TDeviceContextBase::BuildBLAS(Attribs, 0))
return;
- auto* pBLASD12 = ValidatedCast<BottomLevelASD3D12Impl>(Attribs.pBLAS);
- auto* pScratchD12 = ValidatedCast<BufferD3D12Impl>(Attribs.pScratchBuffer);
- auto& BLASDesc = pBLASD12->GetDesc();
+ auto* const pBLASD12 = ValidatedCast<BottomLevelASD3D12Impl>(Attribs.pBLAS);
+ auto* const pScratchD12 = ValidatedCast<BufferD3D12Impl>(Attribs.pScratchBuffer);
+ const auto& BLASDesc = pBLASD12->GetDesc();
auto& CmdCtx = GetCmdContext();
const char* OpName = "Build BottomLevelAS (DeviceContextD3D12Impl::BuildBLAS)";
@@ -2298,54 +2298,54 @@ void DeviceContextD3D12Impl::BuildBLAS(const BLASBuildAttribs& Attribs)
for (Uint32 i = 0; i < Attribs.TriangleDataCount; ++i)
{
- auto& src = Attribs.pTriangleData[i];
- Uint32 j = pBLASD12->GetGeometryIndex(src.GeometryName);
- auto& dst = Geometries.data()[j];
- auto& tri = dst.Triangles;
+ const auto& SrcTris = Attribs.pTriangleData[i];
+ Uint32 GeoIdx = pBLASD12->GetGeometryIndex(SrcTris.GeometryName);
+ auto& d3d12Geo = Geometries[GeoIdx];
+ auto& d3d12Tris = d3d12Geo.Triangles;
- if (j >= Geometries.size())
+ if (GeoIdx >= Geometries.size())
{
UNEXPECTED("Failed to find geometry by name");
continue;
}
- dst.Type = D3D12_RAYTRACING_GEOMETRY_TYPE_TRIANGLES;
- dst.Flags = GeometryFlagsToD3D12RTGeometryFlags(src.Flags);
+ d3d12Geo.Type = D3D12_RAYTRACING_GEOMETRY_TYPE_TRIANGLES;
+ d3d12Geo.Flags = GeometryFlagsToD3D12RTGeometryFlags(SrcTris.Flags);
- auto* pVB = ValidatedCast<BufferD3D12Impl>(src.pVertexBuffer);
- tri.VertexFormat = TypeToDXGI_Format(src.VertexValueType, src.VertexComponentCount, src.VertexValueType < VT_FLOAT16);
- tri.VertexCount = src.VertexCount;
- tri.VertexBuffer.StartAddress = pVB->GetGPUAddress() + src.VertexOffset;
- tri.VertexBuffer.StrideInBytes = src.VertexStride;
+ auto* const pVB = ValidatedCast<BufferD3D12Impl>(SrcTris.pVertexBuffer);
+ d3d12Tris.VertexFormat = TypeToDXGI_Format(SrcTris.VertexValueType, SrcTris.VertexComponentCount, SrcTris.VertexValueType < VT_FLOAT16);
+ d3d12Tris.VertexCount = SrcTris.VertexCount;
+ d3d12Tris.VertexBuffer.StartAddress = pVB->GetGPUAddress() + SrcTris.VertexOffset;
+ d3d12Tris.VertexBuffer.StrideInBytes = SrcTris.VertexStride;
- if (src.pIndexBuffer)
+ if (SrcTris.pIndexBuffer)
{
- auto* pIB = ValidatedCast<BufferD3D12Impl>(src.pIndexBuffer);
- tri.IndexBuffer = pIB->GetGPUAddress() + src.IndexOffset;
- tri.IndexCount = src.IndexCount;
- tri.IndexFormat = ValueTypeToIndexType(src.IndexType);
+ auto* const pIB = ValidatedCast<BufferD3D12Impl>(SrcTris.pIndexBuffer);
+ d3d12Tris.IndexBuffer = pIB->GetGPUAddress() + SrcTris.IndexOffset;
+ d3d12Tris.IndexCount = SrcTris.IndexCount;
+ d3d12Tris.IndexFormat = ValueTypeToIndexType(SrcTris.IndexType);
TransitionOrVerifyBufferState(CmdCtx, *pIB, Attribs.GeometryTransitionMode, RESOURCE_STATE_BUILD_AS_READ, OpName);
}
else
{
- tri.IndexFormat = DXGI_FORMAT_UNKNOWN;
- tri.IndexBuffer = 0;
+ d3d12Tris.IndexFormat = DXGI_FORMAT_UNKNOWN;
+ d3d12Tris.IndexBuffer = 0;
}
- if (src.pTransformBuffer)
+ if (SrcTris.pTransformBuffer)
{
- VERIFY_EXPR(BLASDesc.pTriangles[j].AllowsTransforms);
+ VERIFY_EXPR(BLASDesc.pTriangles[GeoIdx].AllowsTransforms);
- auto* pTB = ValidatedCast<BufferD3D12Impl>(src.pTransformBuffer);
- tri.Transform3x4 = pTB->GetGPUAddress() + src.TransformBufferOffset;
+ auto* const pTB = ValidatedCast<BufferD3D12Impl>(SrcTris.pTransformBuffer);
+ d3d12Tris.Transform3x4 = pTB->GetGPUAddress() + SrcTris.TransformBufferOffset;
TransitionOrVerifyBufferState(CmdCtx, *pTB, Attribs.GeometryTransitionMode, RESOURCE_STATE_BUILD_AS_READ, OpName);
}
else
{
- VERIFY_EXPR(!BLASDesc.pTriangles[j].AllowsTransforms);
- tri.Transform3x4 = 0;
+ VERIFY_EXPR(!BLASDesc.pTriangles[GeoIdx].AllowsTransforms);
+ d3d12Tris.Transform3x4 = 0;
}
}
}
@@ -2355,24 +2355,24 @@ void DeviceContextD3D12Impl::BuildBLAS(const BLASBuildAttribs& Attribs)
for (Uint32 i = 0; i < Attribs.BoxDataCount; ++i)
{
- auto& src = Attribs.pBoxData[i];
- Uint32 j = pBLASD12->GetGeometryIndex(src.GeometryName);
- auto& dst = Geometries.data()[j];
- auto& box = dst.AABBs;
+ const auto& SrcBoxes = Attribs.pBoxData[i];
+ Uint32 GeoIdx = pBLASD12->GetGeometryIndex(SrcBoxes.GeometryName);
+ auto& d3d12Geo = Geometries[GeoIdx];
+ auto& d3d12AABs = d3d12Geo.AABBs;
- if (j >= Geometries.size())
+ if (GeoIdx >= Geometries.size())
{
UNEXPECTED("Failed to find geometry by name");
continue;
}
- dst.Type = D3D12_RAYTRACING_GEOMETRY_TYPE_PROCEDURAL_PRIMITIVE_AABBS;
- dst.Flags = GeometryFlagsToD3D12RTGeometryFlags(src.Flags);
+ d3d12Geo.Type = D3D12_RAYTRACING_GEOMETRY_TYPE_PROCEDURAL_PRIMITIVE_AABBS;
+ d3d12Geo.Flags = GeometryFlagsToD3D12RTGeometryFlags(SrcBoxes.Flags);
- auto* pBB = ValidatedCast<BufferD3D12Impl>(src.pBoxBuffer);
- box.AABBCount = src.BoxCount;
- box.AABBs.StartAddress = pBB->GetGPUAddress() + src.BoxOffset;
- box.AABBs.StrideInBytes = src.BoxStride;
+ auto* pBB = ValidatedCast<BufferD3D12Impl>(SrcBoxes.pBoxBuffer);
+ d3d12AABs.AABBCount = SrcBoxes.BoxCount;
+ d3d12AABs.AABBs.StartAddress = pBB->GetGPUAddress() + SrcBoxes.BoxOffset;
+ d3d12AABs.AABBs.StrideInBytes = SrcBoxes.BoxStride;
TransitionOrVerifyBufferState(CmdCtx, *pBB, Attribs.GeometryTransitionMode, RESOURCE_STATE_BUILD_AS_READ, OpName);
}
@@ -2418,18 +2418,18 @@ void DeviceContextD3D12Impl::BuildTLAS(const TLASBuildAttribs& Attribs)
for (Uint32 i = 0; i < Attribs.InstanceCount; ++i)
{
- auto& src = Attribs.pInstances[i];
- auto& dst = static_cast<D3D12_RAYTRACING_INSTANCE_DESC*>(pMappedInstances)[i];
- auto* pBLASD12 = ValidatedCast<BottomLevelASD3D12Impl>(src.pBLAS);
+ const auto& Inst = Attribs.pInstances[i];
+ auto& d3d12Inst = static_cast<D3D12_RAYTRACING_INSTANCE_DESC*>(pMappedInstances)[i];
+ auto* const pBLASD12 = ValidatedCast<BottomLevelASD3D12Impl>(Inst.pBLAS);
- static_assert(sizeof(dst.Transform) == sizeof(src.Transform), "size mismatch");
- std::memcpy(&dst.Transform, src.Transform, sizeof(dst.Transform));
+ static_assert(sizeof(d3d12Inst.Transform) == sizeof(Inst.Transform), "size mismatch");
+ std::memcpy(&d3d12Inst.Transform, Inst.Transform, sizeof(d3d12Inst.Transform));
- dst.InstanceID = src.CustomId;
- dst.InstanceContributionToHitGroupIndex = pTLASD12->GetInstanceDesc(src.InstanceName).ContributionToHitGroupIndex; // AZ TODO: optimize
- dst.InstanceMask = src.Mask;
- dst.Flags = InstanceFlagsToD3D12RTInstanceFlags(src.Flags);
- dst.AccelerationStructure = pBLASD12->GetGPUAddress();
+ d3d12Inst.InstanceID = Inst.CustomId;
+ d3d12Inst.InstanceContributionToHitGroupIndex = pTLASD12->GetInstanceDesc(Inst.InstanceName).ContributionToHitGroupIndex; // AZ TODO: optimize
+ d3d12Inst.InstanceMask = Inst.Mask;
+ d3d12Inst.Flags = InstanceFlagsToD3D12RTInstanceFlags(Inst.Flags);
+ d3d12Inst.AccelerationStructure = pBLASD12->GetGPUAddress();
TransitionOrVerifyBLASState(CmdCtx, *pBLASD12, Attribs.BLASTransitionMode, RESOURCE_STATE_BUILD_AS_READ, OpName);
}
@@ -2437,19 +2437,19 @@ void DeviceContextD3D12Impl::BuildTLAS(const TLASBuildAttribs& Attribs)
}
TransitionOrVerifyBufferState(CmdCtx, *pInstancesD12, Attribs.InstanceBufferTransitionMode, RESOURCE_STATE_BUILD_AS_READ, OpName);
- D3D12_BUILD_RAYTRACING_ACCELERATION_STRUCTURE_DESC Desc = {};
- D3D12_BUILD_RAYTRACING_ACCELERATION_STRUCTURE_INPUTS& Inputs = Desc.Inputs;
+ D3D12_BUILD_RAYTRACING_ACCELERATION_STRUCTURE_DESC d3d12BuildASDesc = {};
+ D3D12_BUILD_RAYTRACING_ACCELERATION_STRUCTURE_INPUTS& d3d12BuildASInputs = d3d12BuildASDesc.Inputs;
- Inputs.Type = D3D12_RAYTRACING_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL;
- Inputs.DescsLayout = D3D12_ELEMENTS_LAYOUT_ARRAY;
- Inputs.NumDescs = Attribs.InstanceCount;
- Inputs.InstanceDescs = pInstancesD12->GetGPUAddress();
+ d3d12BuildASInputs.Type = D3D12_RAYTRACING_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL;
+ d3d12BuildASInputs.DescsLayout = D3D12_ELEMENTS_LAYOUT_ARRAY;
+ d3d12BuildASInputs.NumDescs = Attribs.InstanceCount;
+ d3d12BuildASInputs.InstanceDescs = pInstancesD12->GetGPUAddress();
- Desc.DestAccelerationStructureData = pTLASD12->GetGPUAddress();
- Desc.ScratchAccelerationStructureData = pScratchD12->GetGPUAddress();
- Desc.SourceAccelerationStructureData = 0;
+ d3d12BuildASDesc.DestAccelerationStructureData = pTLASD12->GetGPUAddress();
+ d3d12BuildASDesc.ScratchAccelerationStructureData = pScratchD12->GetGPUAddress();
+ d3d12BuildASDesc.SourceAccelerationStructureData = 0;
- CmdCtx.AsGraphicsContext4().BuildRaytracingAccelerationStructure(Desc, 0, nullptr);
+ CmdCtx.AsGraphicsContext4().BuildRaytracingAccelerationStructure(d3d12BuildASDesc, 0, nullptr);
++m_State.NumCommands;
}
@@ -2474,19 +2474,23 @@ void DeviceContextD3D12Impl::TraceRays(const TraceRaysAttribs& Attribs)
if (!TDeviceContextBase::TraceRays(Attribs, 0))
return;
- D3D12_DISPATCH_RAYS_DESC Desc = {};
+ D3D12_DISPATCH_RAYS_DESC d3d12DispatchDesc = {};
- Desc.Width = Attribs.DimensionX;
- Desc.Height = Attribs.DimensionY;
- Desc.Depth = Attribs.DimensionZ;
+ d3d12DispatchDesc.Width = Attribs.DimensionX;
+ d3d12DispatchDesc.Height = Attribs.DimensionY;
+ d3d12DispatchDesc.Depth = Attribs.DimensionZ;
auto* pSBTD12 = ValidatedCast<ShaderBindingTableD3D12Impl>(Attribs.pSBT);
- pSBTD12->GetD3D12AddressRangeAndStride(this, Attribs.TransitionMode, Desc.RayGenerationShaderRecord, Desc.MissShaderTable, Desc.HitGroupTable, Desc.CallableShaderTable);
+ pSBTD12->GetD3D12AddressRangeAndStride(this, Attribs.TransitionMode,
+ d3d12DispatchDesc.RayGenerationShaderRecord,
+ d3d12DispatchDesc.MissShaderTable,
+ d3d12DispatchDesc.HitGroupTable,
+ d3d12DispatchDesc.CallableShaderTable);
auto& CmdCtx = GetCmdContext().AsGraphicsContext4();
PrepareForDispatchRays(CmdCtx);
- CmdCtx.DispatchRays(Desc);
+ CmdCtx.DispatchRays(d3d12DispatchDesc);
++m_State.NumCommands;
}
diff --git a/Graphics/GraphicsEngineD3D12/src/ShaderBindingTableD3D12Impl.cpp b/Graphics/GraphicsEngineD3D12/src/ShaderBindingTableD3D12Impl.cpp
index 3727913f..d352caf0 100644
--- a/Graphics/GraphicsEngineD3D12/src/ShaderBindingTableD3D12Impl.cpp
+++ b/Graphics/GraphicsEngineD3D12/src/ShaderBindingTableD3D12Impl.cpp
@@ -110,7 +110,7 @@ void ShaderBindingTableD3D12Impl::GetD3D12AddressRangeAndStride(IDeviceContextD3
D3D12_GPU_VIRTUAL_ADDRESS_RANGE_AND_STRIDE& CallableShaderBindingTable)
{
const auto AlignToLarger = [](size_t offset) -> Uint32 {
- return Align(static_cast<Uint32>(offset), static_cast<Uint32>(D3D12_RAYTRACING_SHADER_TABLE_BYTE_ALIGNMENT));
+ return Align(static_cast<Uint32>(offset), Uint32{D3D12_RAYTRACING_SHADER_TABLE_BYTE_ALIGNMENT});
};
const Uint32 RayGenOffset = 0;
diff --git a/Graphics/GraphicsEngineD3D12/src/ShaderResourceLayoutD3D12.cpp b/Graphics/GraphicsEngineD3D12/src/ShaderResourceLayoutD3D12.cpp
index 6dbdb97f..bfc8693a 100644
--- a/Graphics/GraphicsEngineD3D12/src/ShaderResourceLayoutD3D12.cpp
+++ b/Graphics/GraphicsEngineD3D12/src/ShaderResourceLayoutD3D12.cpp
@@ -456,7 +456,7 @@ void ShaderResourceLayoutD3D12::D3D12Resource::CacheCB(IDeviceObject*
// We cannot use ValidatedCast<> here as the resource retrieved from the
// resource mapping can be of wrong type
- RefCntAutoPtr<BufferD3D12Impl> pBuffD3D12(pBuffer, IID_BufferD3D12);
+ RefCntAutoPtr<BufferD3D12Impl> pBuffD3D12{pBuffer, IID_BufferD3D12};
#ifdef DILIGENT_DEVELOPMENT
VerifyConstantBufferBinding(Attribs, GetVariableType(), ArrayInd, pBuffer, pBuffD3D12.RawPtr(), DstRes.pObject.RawPtr(), ParentResLayout.GetShaderName());
#endif
@@ -576,7 +576,7 @@ void ShaderResourceLayoutD3D12::D3D12Resource::CacheSampler(IDeviceObject*
VERIFY(Attribs.IsValidBindPoint(), "Invalid bind point");
VERIFY_EXPR(ArrayIndex < Attribs.BindCount);
- RefCntAutoPtr<ISamplerD3D12> pSamplerD3D12(pSampler, IID_SamplerD3D12);
+ RefCntAutoPtr<ISamplerD3D12> pSamplerD3D12{pSampler, IID_SamplerD3D12};
if (pSamplerD3D12)
{
if (GetVariableType() != SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC && DstSam.pObject != nullptr)
@@ -626,7 +626,7 @@ void ShaderResourceLayoutD3D12::D3D12Resource::CacheAccelStruct(IDeviceObject*
VERIFY(Attribs.IsValidBindPoint(), "Invalid bind point");
VERIFY_EXPR(ArrayIndex < Attribs.BindCount);
- RefCntAutoPtr<ITopLevelASD3D12> pTLASD3D12(pTLAS, IID_TopLevelASD3D12);
+ RefCntAutoPtr<ITopLevelASD3D12> pTLASD3D12{pTLAS, IID_TopLevelASD3D12};
if (pTLASD3D12)
{
if (GetVariableType() != SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC && DstRes.pObject != nullptr)
diff --git a/Graphics/GraphicsEngineD3D12/src/TopLevelASD3D12Impl.cpp b/Graphics/GraphicsEngineD3D12/src/TopLevelASD3D12Impl.cpp
index 5f411640..3bbf3308 100644
--- a/Graphics/GraphicsEngineD3D12/src/TopLevelASD3D12Impl.cpp
+++ b/Graphics/GraphicsEngineD3D12/src/TopLevelASD3D12Impl.cpp
@@ -44,20 +44,20 @@ TopLevelASD3D12Impl::TopLevelASD3D12Impl(IReferenceCounters* pRefCounte
bool bIsDeviceInternal) :
TTopLevelASBase{pRefCounters, pDeviceD3D12, Desc, bIsDeviceInternal}
{
- D3D12_RAYTRACING_ACCELERATION_STRUCTURE_PREBUILD_INFO TopLevelPrebuildInfo = {};
- D3D12_BUILD_RAYTRACING_ACCELERATION_STRUCTURE_INPUTS TopLevelInputs = {};
+ D3D12_RAYTRACING_ACCELERATION_STRUCTURE_PREBUILD_INFO d3d12TopLevelPrebuildInfo = {};
+ D3D12_BUILD_RAYTRACING_ACCELERATION_STRUCTURE_INPUTS d3d12TopLevelInputs = {};
- TopLevelInputs.Type = D3D12_RAYTRACING_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL;
- TopLevelInputs.Flags = D3D12_RAYTRACING_ACCELERATION_STRUCTURE_BUILD_FLAG_NONE;
- TopLevelInputs.DescsLayout = D3D12_ELEMENTS_LAYOUT_ARRAY;
- TopLevelInputs.NumDescs = Desc.MaxInstanceCount;
+ d3d12TopLevelInputs.Type = D3D12_RAYTRACING_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL;
+ d3d12TopLevelInputs.Flags = D3D12_RAYTRACING_ACCELERATION_STRUCTURE_BUILD_FLAG_NONE;
+ d3d12TopLevelInputs.DescsLayout = D3D12_ELEMENTS_LAYOUT_ARRAY;
+ d3d12TopLevelInputs.NumDescs = Desc.MaxInstanceCount;
VERIFY_EXPR(Desc.MaxInstanceCount <= D3D12_RAYTRACING_MAX_INSTANCES_PER_TOP_LEVEL_ACCELERATION_STRUCTURE);
auto* pd3d12Device = pDeviceD3D12->GetD3D12Device5();
- pd3d12Device->GetRaytracingAccelerationStructurePrebuildInfo(&TopLevelInputs, &TopLevelPrebuildInfo);
- if (TopLevelPrebuildInfo.ResultDataMaxSizeInBytes == 0)
+ pd3d12Device->GetRaytracingAccelerationStructurePrebuildInfo(&d3d12TopLevelInputs, &d3d12TopLevelPrebuildInfo);
+ if (d3d12TopLevelPrebuildInfo.ResultDataMaxSizeInBytes == 0)
LOG_ERROR_AND_THROW("Failed to get ray tracing acceleration structure prebuild info");
D3D12_HEAP_PROPERTIES HeapProps;
@@ -67,21 +67,21 @@ TopLevelASD3D12Impl::TopLevelASD3D12Impl(IReferenceCounters* pRefCounte
HeapProps.CreationNodeMask = 1;
HeapProps.VisibleNodeMask = 1;
- D3D12_RESOURCE_DESC ASDesc = {};
- ASDesc.Dimension = D3D12_RESOURCE_DIMENSION_BUFFER;
- ASDesc.Alignment = 0;
- ASDesc.Width = TopLevelPrebuildInfo.ResultDataMaxSizeInBytes;
- ASDesc.Height = 1;
- ASDesc.DepthOrArraySize = 1;
- ASDesc.MipLevels = 1;
- ASDesc.Format = DXGI_FORMAT_UNKNOWN;
- ASDesc.SampleDesc.Count = 1;
- ASDesc.SampleDesc.Quality = 0;
- ASDesc.Layout = D3D12_TEXTURE_LAYOUT_ROW_MAJOR;
- ASDesc.Flags = D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS;
+ D3D12_RESOURCE_DESC d3d12ASDesc = {};
+ d3d12ASDesc.Dimension = D3D12_RESOURCE_DIMENSION_BUFFER;
+ d3d12ASDesc.Alignment = 0;
+ d3d12ASDesc.Width = d3d12TopLevelPrebuildInfo.ResultDataMaxSizeInBytes;
+ d3d12ASDesc.Height = 1;
+ d3d12ASDesc.DepthOrArraySize = 1;
+ d3d12ASDesc.MipLevels = 1;
+ d3d12ASDesc.Format = DXGI_FORMAT_UNKNOWN;
+ d3d12ASDesc.SampleDesc.Count = 1;
+ d3d12ASDesc.SampleDesc.Quality = 0;
+ d3d12ASDesc.Layout = D3D12_TEXTURE_LAYOUT_ROW_MAJOR;
+ d3d12ASDesc.Flags = D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS;
auto hr = pd3d12Device->CreateCommittedResource(&HeapProps, D3D12_HEAP_FLAG_NONE,
- &ASDesc, D3D12_RESOURCE_STATE_RAYTRACING_ACCELERATION_STRUCTURE, nullptr,
+ &d3d12ASDesc, D3D12_RESOURCE_STATE_RAYTRACING_ACCELERATION_STRUCTURE, nullptr,
__uuidof(m_pd3d12Resource),
reinterpret_cast<void**>(static_cast<ID3D12Resource**>(&m_pd3d12Resource)));
if (FAILED(hr))
@@ -90,17 +90,17 @@ TopLevelASD3D12Impl::TopLevelASD3D12Impl(IReferenceCounters* pRefCounte
if (*m_Desc.Name != 0)
m_pd3d12Resource->SetName(WidenString(m_Desc.Name).c_str());
- m_ScratchSize.Build = static_cast<Uint32>(TopLevelPrebuildInfo.ScratchDataSizeInBytes);
- m_ScratchSize.Update = static_cast<Uint32>(TopLevelPrebuildInfo.UpdateScratchDataSizeInBytes);
+ m_ScratchSize.Build = static_cast<Uint32>(d3d12TopLevelPrebuildInfo.ScratchDataSizeInBytes);
+ m_ScratchSize.Update = static_cast<Uint32>(d3d12TopLevelPrebuildInfo.UpdateScratchDataSizeInBytes);
m_DescriptorHandle = pDeviceD3D12->AllocateDescriptor(D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV);
- D3D12_SHADER_RESOURCE_VIEW_DESC SRVDesc;
- SRVDesc.ViewDimension = D3D12_SRV_DIMENSION_RAYTRACING_ACCELERATION_STRUCTURE;
- SRVDesc.Shader4ComponentMapping = D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING;
- SRVDesc.Format = DXGI_FORMAT_UNKNOWN;
- SRVDesc.RaytracingAccelerationStructure.Location = GetGPUAddress();
- pd3d12Device->CreateShaderResourceView(nullptr, &SRVDesc, m_DescriptorHandle.GetCpuHandle());
+ D3D12_SHADER_RESOURCE_VIEW_DESC d3d12SRVDesc;
+ d3d12SRVDesc.ViewDimension = D3D12_SRV_DIMENSION_RAYTRACING_ACCELERATION_STRUCTURE;
+ d3d12SRVDesc.Shader4ComponentMapping = D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING;
+ d3d12SRVDesc.Format = DXGI_FORMAT_UNKNOWN;
+ d3d12SRVDesc.RaytracingAccelerationStructure.Location = GetGPUAddress();
+ pd3d12Device->CreateShaderResourceView(nullptr, &d3d12SRVDesc, m_DescriptorHandle.GetCpuHandle());
}
TopLevelASD3D12Impl::~TopLevelASD3D12Impl()