Skip to content

Commit 17d10ab

Browse files
RayTracingReferenceD3D12: don't use auto where unnecessary
1 parent a47d343 commit 17d10ab

File tree

1 file changed

+38
-37
lines changed

1 file changed

+38
-37
lines changed

Tests/DiligentCoreAPITest/src/D3D12/RayTracingReferenceD3D12.cpp

Lines changed: 38 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2019-2022 Diligent Graphics LLC
2+
* Copyright 2019-2025 Diligent Graphics LLC
33
* Copyright 2015-2019 Egor Yusov
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -89,7 +89,7 @@ struct RTContext
8989
{
9090
pTestingSwapChainD3D12->TransitionRenderTarget(pCmdList, D3D12_RESOURCE_STATE_RENDER_TARGET);
9191

92-
auto RTVDescriptorHandle = pTestingSwapChainD3D12->GetRTVDescriptorHandle();
92+
D3D12_CPU_DESCRIPTOR_HANDLE RTVDescriptorHandle = pTestingSwapChainD3D12->GetRTVDescriptorHandle();
9393

9494
pCmdList->OMSetRenderTargets(1, &RTVDescriptorHandle, FALSE, nullptr);
9595

@@ -120,8 +120,8 @@ struct RTSubobjectsHelper
120120

121121
void SetDxilLibrary(Uint32 Index, const String& Source, const wchar_t* ExportName)
122122
{
123-
auto* pEnv = TestingEnvironmentD3D12::GetInstance();
124-
auto hr = pEnv->CompileDXILShader(Source, L"main", nullptr, 0, L"lib_6_3", &ShadersByteCode[Index]);
123+
TestingEnvironmentD3D12* pEnv = TestingEnvironmentD3D12::GetInstance();
124+
HRESULT hr = pEnv->CompileDXILShader(Source, L"main", nullptr, 0, L"lib_6_3", &ShadersByteCode[Index]);
125125
ASSERT_HRESULT_SUCCEEDED(hr) << "Failed to compile ray tracing shader";
126126

127127
D3D12_EXPORT_DESC& RGExportDesc = ExportDescs[Index];
@@ -162,10 +162,10 @@ struct RTSubobjectsHelper
162162
template <typename PSOCtorType, typename RootSigCtorType>
163163
void InitializeRTContext(RTContext& Ctx, ISwapChain* pSwapChain, Uint32 ShaderRecordSize, PSOCtorType&& PSOCtor, RootSigCtorType&& RootSigCtor)
164164
{
165-
auto* pEnv = TestingEnvironmentD3D12::GetInstance();
166-
auto* pTestingSwapChainD3D12 = ClassPtrCast<TestingSwapChainD3D12>(pSwapChain);
165+
TestingEnvironmentD3D12* pEnv = TestingEnvironmentD3D12::GetInstance();
166+
TestingSwapChainD3D12* pTestingSwapChainD3D12 = ClassPtrCast<TestingSwapChainD3D12>(pSwapChain);
167167

168-
auto hr = pEnv->GetD3D12Device()->QueryInterface(IID_PPV_ARGS(&Ctx.pDevice));
168+
HRESULT hr = pEnv->GetD3D12Device()->QueryInterface(IID_PPV_ARGS(&Ctx.pDevice));
169169
ASSERT_HRESULT_SUCCEEDED(hr) << "Failed to get ID3D12Device2";
170170

171171
Ctx.pRenderTarget = pTestingSwapChainD3D12->GetD3D12RenderTarget();
@@ -333,9 +333,10 @@ void CreateBLAS(RTContext& Ctx, D3D12_BUILD_RAYTRACING_ACCELERATION_STRUCTURE_IN
333333
ASDesc.Layout = D3D12_TEXTURE_LAYOUT_ROW_MAJOR;
334334
ASDesc.Flags = D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS;
335335

336-
auto hr = Ctx.pDevice->CreateCommittedResource(&HeapProps, D3D12_HEAP_FLAG_NONE,
337-
&ASDesc, D3D12_RESOURCE_STATE_RAYTRACING_ACCELERATION_STRUCTURE, nullptr,
338-
IID_PPV_ARGS(&Ctx.BLAS.pAS));
336+
HRESULT hr = Ctx.pDevice->CreateCommittedResource(
337+
&HeapProps, D3D12_HEAP_FLAG_NONE,
338+
&ASDesc, D3D12_RESOURCE_STATE_RAYTRACING_ACCELERATION_STRUCTURE, nullptr,
339+
IID_PPV_ARGS(&Ctx.BLAS.pAS));
339340
ASSERT_HRESULT_SUCCEEDED(hr) << "Failed to create acceleration structure";
340341

341342
Ctx.BLAS.BuildScratchSize = BottomLevelPrebuildInfo.ScratchDataSizeInBytes;
@@ -373,9 +374,9 @@ void CreateTLAS(RTContext& Ctx, D3D12_BUILD_RAYTRACING_ACCELERATION_STRUCTURE_IN
373374
ASDesc.Layout = D3D12_TEXTURE_LAYOUT_ROW_MAJOR;
374375
ASDesc.Flags = D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS;
375376

376-
auto hr = Ctx.pDevice->CreateCommittedResource(&HeapProps, D3D12_HEAP_FLAG_NONE,
377-
&ASDesc, D3D12_RESOURCE_STATE_RAYTRACING_ACCELERATION_STRUCTURE, nullptr,
378-
IID_PPV_ARGS(&Ctx.TLAS.pAS));
377+
HRESULT hr = Ctx.pDevice->CreateCommittedResource(&HeapProps, D3D12_HEAP_FLAG_NONE,
378+
&ASDesc, D3D12_RESOURCE_STATE_RAYTRACING_ACCELERATION_STRUCTURE, nullptr,
379+
IID_PPV_ARGS(&Ctx.TLAS.pAS));
379380
ASSERT_HRESULT_SUCCEEDED(hr) << "Failed to create acceleration structure";
380381

381382
Ctx.TLAS.BuildScratchSize = TopLevelPrebuildInfo.ScratchDataSizeInBytes;
@@ -420,9 +421,9 @@ void CreateRTBuffers(RTContext& Ctx, Uint32 VBSize, Uint32 IBSize, Uint32 Instan
420421
BuffDesc.Width = std::max(BuffDesc.Width, Ctx.TLAS.BuildScratchSize);
421422
BuffDesc.Width = std::max(BuffDesc.Width, Ctx.TLAS.UpdateScratchSize);
422423

423-
auto hr = Ctx.pDevice->CreateCommittedResource(&HeapProps, D3D12_HEAP_FLAG_NONE,
424-
&BuffDesc, D3D12_RESOURCE_STATE_UNORDERED_ACCESS, nullptr,
425-
IID_PPV_ARGS(&Ctx.pScratchBuffer));
424+
HRESULT hr = Ctx.pDevice->CreateCommittedResource(&HeapProps, D3D12_HEAP_FLAG_NONE,
425+
&BuffDesc, D3D12_RESOURCE_STATE_UNORDERED_ACCESS, nullptr,
426+
IID_PPV_ARGS(&Ctx.pScratchBuffer));
426427
ASSERT_HRESULT_SUCCEEDED(hr) << "Failed to create buffer";
427428

428429
if (VBSize > 0)
@@ -480,9 +481,11 @@ void CreateRTBuffers(RTContext& Ctx, Uint32 VBSize, Uint32 IBSize, Uint32 Instan
480481
if (UploadSize > 0)
481482
{
482483
BuffDesc.Width = UploadSize;
483-
hr = Ctx.pDevice->CreateCommittedResource(&HeapProps, D3D12_HEAP_FLAG_NONE,
484-
&BuffDesc, D3D12_RESOURCE_STATE_GENERIC_READ, nullptr,
485-
IID_PPV_ARGS(&Ctx.pUploadBuffer));
484+
485+
hr = Ctx.pDevice->CreateCommittedResource(
486+
&HeapProps, D3D12_HEAP_FLAG_NONE,
487+
&BuffDesc, D3D12_RESOURCE_STATE_GENERIC_READ, nullptr,
488+
IID_PPV_ARGS(&Ctx.pUploadBuffer));
486489
ASSERT_HRESULT_SUCCEEDED(hr) << "Failed to create buffer";
487490

488491
hr = Ctx.pUploadBuffer->Map(0, nullptr, &Ctx.MappedPtr);
@@ -561,10 +564,10 @@ void UAVBarrier(const RTContext& Ctx, ID3D12Resource* pResource)
561564

562565
void RayTracingTriangleClosestHitReferenceD3D12(ISwapChain* pSwapChain)
563566
{
564-
auto* pEnv = TestingEnvironmentD3D12::GetInstance();
565-
auto* pTestingSwapChainD3D12 = ClassPtrCast<TestingSwapChainD3D12>(pSwapChain);
567+
TestingEnvironmentD3D12* pEnv = TestingEnvironmentD3D12::GetInstance();
568+
TestingSwapChainD3D12* pTestingSwapChainD3D12 = ClassPtrCast<TestingSwapChainD3D12>(pSwapChain);
566569

567-
const auto& SCDesc = pSwapChain->GetDesc();
570+
const SwapChainDesc& SCDesc = pSwapChain->GetDesc();
568571

569572
RTContext Ctx = {};
570573
InitializeRTContext(Ctx, pSwapChain, 0,
@@ -695,10 +698,9 @@ void RayTracingTriangleClosestHitReferenceD3D12(ISwapChain* pSwapChain)
695698

696699
void RayTracingTriangleAnyHitReferenceD3D12(ISwapChain* pSwapChain)
697700
{
698-
auto* pEnv = TestingEnvironmentD3D12::GetInstance();
699-
auto* pTestingSwapChainD3D12 = ClassPtrCast<TestingSwapChainD3D12>(pSwapChain);
700-
701-
const auto& SCDesc = pSwapChain->GetDesc();
701+
TestingEnvironmentD3D12* pEnv = TestingEnvironmentD3D12::GetInstance();
702+
TestingSwapChainD3D12* pTestingSwapChainD3D12 = ClassPtrCast<TestingSwapChainD3D12>(pSwapChain);
703+
const SwapChainDesc& SCDesc = pSwapChain->GetDesc();
702704

703705
RTContext Ctx = {};
704706
InitializeRTContext(Ctx, pSwapChain, 0,
@@ -831,10 +833,9 @@ void RayTracingTriangleAnyHitReferenceD3D12(ISwapChain* pSwapChain)
831833

832834
void RayTracingProceduralIntersectionReferenceD3D12(ISwapChain* pSwapChain)
833835
{
834-
auto* pEnv = TestingEnvironmentD3D12::GetInstance();
835-
auto* pTestingSwapChainD3D12 = ClassPtrCast<TestingSwapChainD3D12>(pSwapChain);
836-
837-
const auto& SCDesc = pSwapChain->GetDesc();
836+
TestingEnvironmentD3D12* pEnv = TestingEnvironmentD3D12::GetInstance();
837+
TestingSwapChainD3D12* pTestingSwapChainD3D12 = ClassPtrCast<TestingSwapChainD3D12>(pSwapChain);
838+
const SwapChainDesc& SCDesc = pSwapChain->GetDesc();
838839

839840
RTContext Ctx = {};
840841
InitializeRTContext(Ctx, pSwapChain, 0,
@@ -966,10 +967,9 @@ void RayTracingMultiGeometryReferenceD3D12(ISwapChain* pSwapChain)
966967
static constexpr Uint32 GeometryCount = 3;
967968
static constexpr Uint32 HitGroupCount = InstanceCount * GeometryCount;
968969

969-
auto* pEnv = TestingEnvironmentD3D12::GetInstance();
970-
auto* pTestingSwapChainD3D12 = ClassPtrCast<TestingSwapChainD3D12>(pSwapChain);
971-
972-
const auto& SCDesc = pSwapChain->GetDesc();
970+
TestingEnvironmentD3D12* pEnv = TestingEnvironmentD3D12::GetInstance();
971+
TestingSwapChainD3D12* pTestingSwapChainD3D12 = ClassPtrCast<TestingSwapChainD3D12>(pSwapChain);
972+
const SwapChainDesc& SCDesc = pSwapChain->GetDesc();
973973

974974
RTContext Ctx = {};
975975
InitializeRTContext(
@@ -1146,9 +1146,10 @@ void RayTracingMultiGeometryReferenceD3D12(ISwapChain* pSwapChain)
11461146
HeapProps.CreationNodeMask = 1;
11471147
HeapProps.VisibleNodeMask = 1;
11481148

1149-
auto hr = Ctx.pDevice->CreateCommittedResource(&HeapProps, D3D12_HEAP_FLAG_NONE,
1150-
&BuffDesc, D3D12_RESOURCE_STATE_COPY_DEST, nullptr,
1151-
IID_PPV_ARGS(&pPerInstanceBuffer));
1149+
HRESULT hr = Ctx.pDevice->CreateCommittedResource(
1150+
&HeapProps, D3D12_HEAP_FLAG_NONE,
1151+
&BuffDesc, D3D12_RESOURCE_STATE_COPY_DEST, nullptr,
1152+
IID_PPV_ARGS(&pPerInstanceBuffer));
11521153
ASSERT_HRESULT_SUCCEEDED(hr) << "Failed to create per instance buffer";
11531154

11541155
BuffDesc.Width = sizeof(Primitives);

0 commit comments

Comments
 (0)