|
1 | 1 | /* |
2 | | - * Copyright 2019-2022 Diligent Graphics LLC |
| 2 | + * Copyright 2019-2025 Diligent Graphics LLC |
3 | 3 | * Copyright 2015-2019 Egor Yusov |
4 | 4 | * |
5 | 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -89,7 +89,7 @@ struct RTContext |
89 | 89 | { |
90 | 90 | pTestingSwapChainD3D12->TransitionRenderTarget(pCmdList, D3D12_RESOURCE_STATE_RENDER_TARGET); |
91 | 91 |
|
92 | | - auto RTVDescriptorHandle = pTestingSwapChainD3D12->GetRTVDescriptorHandle(); |
| 92 | + D3D12_CPU_DESCRIPTOR_HANDLE RTVDescriptorHandle = pTestingSwapChainD3D12->GetRTVDescriptorHandle(); |
93 | 93 |
|
94 | 94 | pCmdList->OMSetRenderTargets(1, &RTVDescriptorHandle, FALSE, nullptr); |
95 | 95 |
|
@@ -120,8 +120,8 @@ struct RTSubobjectsHelper |
120 | 120 |
|
121 | 121 | void SetDxilLibrary(Uint32 Index, const String& Source, const wchar_t* ExportName) |
122 | 122 | { |
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]); |
125 | 125 | ASSERT_HRESULT_SUCCEEDED(hr) << "Failed to compile ray tracing shader"; |
126 | 126 |
|
127 | 127 | D3D12_EXPORT_DESC& RGExportDesc = ExportDescs[Index]; |
@@ -162,10 +162,10 @@ struct RTSubobjectsHelper |
162 | 162 | template <typename PSOCtorType, typename RootSigCtorType> |
163 | 163 | void InitializeRTContext(RTContext& Ctx, ISwapChain* pSwapChain, Uint32 ShaderRecordSize, PSOCtorType&& PSOCtor, RootSigCtorType&& RootSigCtor) |
164 | 164 | { |
165 | | - auto* pEnv = TestingEnvironmentD3D12::GetInstance(); |
166 | | - auto* pTestingSwapChainD3D12 = ClassPtrCast<TestingSwapChainD3D12>(pSwapChain); |
| 165 | + TestingEnvironmentD3D12* pEnv = TestingEnvironmentD3D12::GetInstance(); |
| 166 | + TestingSwapChainD3D12* pTestingSwapChainD3D12 = ClassPtrCast<TestingSwapChainD3D12>(pSwapChain); |
167 | 167 |
|
168 | | - auto hr = pEnv->GetD3D12Device()->QueryInterface(IID_PPV_ARGS(&Ctx.pDevice)); |
| 168 | + HRESULT hr = pEnv->GetD3D12Device()->QueryInterface(IID_PPV_ARGS(&Ctx.pDevice)); |
169 | 169 | ASSERT_HRESULT_SUCCEEDED(hr) << "Failed to get ID3D12Device2"; |
170 | 170 |
|
171 | 171 | Ctx.pRenderTarget = pTestingSwapChainD3D12->GetD3D12RenderTarget(); |
@@ -333,9 +333,10 @@ void CreateBLAS(RTContext& Ctx, D3D12_BUILD_RAYTRACING_ACCELERATION_STRUCTURE_IN |
333 | 333 | ASDesc.Layout = D3D12_TEXTURE_LAYOUT_ROW_MAJOR; |
334 | 334 | ASDesc.Flags = D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS; |
335 | 335 |
|
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)); |
339 | 340 | ASSERT_HRESULT_SUCCEEDED(hr) << "Failed to create acceleration structure"; |
340 | 341 |
|
341 | 342 | Ctx.BLAS.BuildScratchSize = BottomLevelPrebuildInfo.ScratchDataSizeInBytes; |
@@ -373,9 +374,9 @@ void CreateTLAS(RTContext& Ctx, D3D12_BUILD_RAYTRACING_ACCELERATION_STRUCTURE_IN |
373 | 374 | ASDesc.Layout = D3D12_TEXTURE_LAYOUT_ROW_MAJOR; |
374 | 375 | ASDesc.Flags = D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS; |
375 | 376 |
|
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)); |
379 | 380 | ASSERT_HRESULT_SUCCEEDED(hr) << "Failed to create acceleration structure"; |
380 | 381 |
|
381 | 382 | Ctx.TLAS.BuildScratchSize = TopLevelPrebuildInfo.ScratchDataSizeInBytes; |
@@ -420,9 +421,9 @@ void CreateRTBuffers(RTContext& Ctx, Uint32 VBSize, Uint32 IBSize, Uint32 Instan |
420 | 421 | BuffDesc.Width = std::max(BuffDesc.Width, Ctx.TLAS.BuildScratchSize); |
421 | 422 | BuffDesc.Width = std::max(BuffDesc.Width, Ctx.TLAS.UpdateScratchSize); |
422 | 423 |
|
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)); |
426 | 427 | ASSERT_HRESULT_SUCCEEDED(hr) << "Failed to create buffer"; |
427 | 428 |
|
428 | 429 | if (VBSize > 0) |
@@ -480,9 +481,11 @@ void CreateRTBuffers(RTContext& Ctx, Uint32 VBSize, Uint32 IBSize, Uint32 Instan |
480 | 481 | if (UploadSize > 0) |
481 | 482 | { |
482 | 483 | 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)); |
486 | 489 | ASSERT_HRESULT_SUCCEEDED(hr) << "Failed to create buffer"; |
487 | 490 |
|
488 | 491 | hr = Ctx.pUploadBuffer->Map(0, nullptr, &Ctx.MappedPtr); |
@@ -561,10 +564,10 @@ void UAVBarrier(const RTContext& Ctx, ID3D12Resource* pResource) |
561 | 564 |
|
562 | 565 | void RayTracingTriangleClosestHitReferenceD3D12(ISwapChain* pSwapChain) |
563 | 566 | { |
564 | | - auto* pEnv = TestingEnvironmentD3D12::GetInstance(); |
565 | | - auto* pTestingSwapChainD3D12 = ClassPtrCast<TestingSwapChainD3D12>(pSwapChain); |
| 567 | + TestingEnvironmentD3D12* pEnv = TestingEnvironmentD3D12::GetInstance(); |
| 568 | + TestingSwapChainD3D12* pTestingSwapChainD3D12 = ClassPtrCast<TestingSwapChainD3D12>(pSwapChain); |
566 | 569 |
|
567 | | - const auto& SCDesc = pSwapChain->GetDesc(); |
| 570 | + const SwapChainDesc& SCDesc = pSwapChain->GetDesc(); |
568 | 571 |
|
569 | 572 | RTContext Ctx = {}; |
570 | 573 | InitializeRTContext(Ctx, pSwapChain, 0, |
@@ -695,10 +698,9 @@ void RayTracingTriangleClosestHitReferenceD3D12(ISwapChain* pSwapChain) |
695 | 698 |
|
696 | 699 | void RayTracingTriangleAnyHitReferenceD3D12(ISwapChain* pSwapChain) |
697 | 700 | { |
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(); |
702 | 704 |
|
703 | 705 | RTContext Ctx = {}; |
704 | 706 | InitializeRTContext(Ctx, pSwapChain, 0, |
@@ -831,10 +833,9 @@ void RayTracingTriangleAnyHitReferenceD3D12(ISwapChain* pSwapChain) |
831 | 833 |
|
832 | 834 | void RayTracingProceduralIntersectionReferenceD3D12(ISwapChain* pSwapChain) |
833 | 835 | { |
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(); |
838 | 839 |
|
839 | 840 | RTContext Ctx = {}; |
840 | 841 | InitializeRTContext(Ctx, pSwapChain, 0, |
@@ -966,10 +967,9 @@ void RayTracingMultiGeometryReferenceD3D12(ISwapChain* pSwapChain) |
966 | 967 | static constexpr Uint32 GeometryCount = 3; |
967 | 968 | static constexpr Uint32 HitGroupCount = InstanceCount * GeometryCount; |
968 | 969 |
|
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(); |
973 | 973 |
|
974 | 974 | RTContext Ctx = {}; |
975 | 975 | InitializeRTContext( |
@@ -1146,9 +1146,10 @@ void RayTracingMultiGeometryReferenceD3D12(ISwapChain* pSwapChain) |
1146 | 1146 | HeapProps.CreationNodeMask = 1; |
1147 | 1147 | HeapProps.VisibleNodeMask = 1; |
1148 | 1148 |
|
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)); |
1152 | 1153 | ASSERT_HRESULT_SUCCEEDED(hr) << "Failed to create per instance buffer"; |
1153 | 1154 |
|
1154 | 1155 | BuffDesc.Width = sizeof(Primitives); |
|
0 commit comments