Skip to content

Project 5 - Taylor Nelms #38

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 27 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
c70558d
README update initial
taylornelms15 Oct 15, 2019
12cb448
First attempt at not fucking up the code
taylornelms15 Oct 15, 2019
6dbfdbc
I think I got through 2.3 who knows though since I cannot debug
taylornelms15 Oct 16, 2019
05a7a39
geometry todos through 2.5
taylornelms15 Oct 16, 2019
1601303
some progress on acceleration structures
taylornelms15 Oct 17, 2019
d692ddf
fixed the damn numbering a hair
taylornelms15 Oct 17, 2019
cdd0949
acceleration structures progress I guess
taylornelms15 Oct 17, 2019
4a0565e
Merge branch 'master' of github.com:taylornelms15/Project5-DirectX-Pr…
taylornelms15 Oct 17, 2019
4d5ea42
Fixed one bug, so close to CPU section working
taylornelms15 Oct 17, 2019
486c56c
fixed some bugs, ran into all kinds of fun new ones
taylornelms15 Oct 18, 2019
96f4873
Update README.md
taylornelms15 Oct 18, 2019
324a48f
Update README.md
taylornelms15 Oct 18, 2019
506faa6
added conceptual-3 image
taylornelms15 Oct 18, 2019
79fb666
Merge branch 'master' of github.com:taylornelms15/Project5-DirectX-Pr…
taylornelms15 Oct 18, 2019
8af1880
Update README.md
taylornelms15 Oct 18, 2019
f0b0b1c
CPU CODE LEADS ME TO BLACK SCREEN FINALLY
taylornelms15 Oct 21, 2019
686e47b
I got literally anything on the screen
taylornelms15 Oct 21, 2019
99bb1d0
some geometry debug, a pinch of albedo
taylornelms15 Oct 22, 2019
f0101cd
metaballs function, to a degree
taylornelms15 Oct 26, 2019
80d412c
things don't work, but they don't work in style at least
taylornelms15 Oct 27, 2019
96d8eca
Working shadows
taylornelms15 Oct 27, 2019
0475f2b
Update README.md
taylornelms15 Oct 27, 2019
e4f3726
ray depth image
taylornelms15 Oct 27, 2019
015dc6c
Merge branch 'master' of github.com:taylornelms15/Project5-DirectX-Pr…
taylornelms15 Oct 27, 2019
654bcda
Update README.md
taylornelms15 Oct 27, 2019
7c4b1ba
better chart
taylornelms15 Oct 27, 2019
0fd919e
better image
taylornelms15 Oct 27, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion INSTRUCTIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,8 @@ In DXR, building the Acceleration Structure requires multiple steps:
* The geometry descriptors you built will be passed in as acceleration structure inputs
* You then query the *pre-build* info for these bottom-level AS. This will output 2 things: scratch size, and result data max size. Scratch size is like extra memory the driver needs to build the AS, and result data max is an upper bound for the size of the AS. You need to allocate 2 buffers for both of these.
* Finally, you tell the command list that you want to build the acceleration structure using the scratch and result data allocated.
3. Create a function that builds **instances** of your BLAS. An instance of a BLAS is basically a BLAS but with a specific world-space transform. If you were to spawn multiple boxes in your scene, you would not create multiple box BLAS - you would create only one, but 4. Build the top-level acceleration structure. This is very similar to step (2) except now your inputs to the AS is the bottom-level AS. You will need to additionally call the function you created in step (3) to describe the instances that will be held by your TLAS.
3. Create a function that builds **instances** of your BLAS. An instance of a BLAS is basically a BLAS but with a specific world-space transform. If you were to spawn multiple boxes in your scene, you would not create multiple box BLAS - you would create only one, but
4. Build the top-level acceleration structure. This is very similar to step (2) except now your inputs to the AS is the bottom-level AS. You will need to additionally call the function you created in step (3) to describe the instances that will be held by your TLAS.

Files to checkout:
* DXR-AccelerationStructure.cpp
Expand Down
19 changes: 13 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
**University of Pennsylvania, CIS 565: GPU Programming and Architecture,
Project 5 - DirectX Procedural Raytracing**

* (TODO) YOUR NAME HERE
* (TODO) [LinkedIn](), [personal website](), [twitter](), etc.
* Tested on: (TODO) Windows 22, i7-2222 @ 2.22GHz 22GB, GTX 222 222MB (Moore 2222 Lab)
* Taylor Nelms
* [LinkedIn](https://www.linkedin.com/in/taylor-k-7b2110191/), [twitter](https://twitter.com/nelms_taylor)
* Tested on: Windows 10, Intel i3 Coffee Lake 4-core 3.6GHz processor, 16GB RAM, NVidia GeForce GTX1650 4GB

### (TODO: Your README)
![Ray Tracer Output](img/working_raytracer.png)

Include screenshots, analysis, etc. (Remember, this is public, so don't put
anything here that you don't want to share with the world.)
### DXR Ray Tracer

In this engine implementation, we make use of DirectX's ray tracing utilities to render a hardcoded scene of procedural geometries. By making use of the built-in acceleration structures for geometry traversal, we are able to render a fully ray-traced image at real-time speeds, a feat that is impossible with CPU-based implementations.

### Performance

With only a few geometries to work with, we can look at how the depth of the render engine affects performance overall. It turns out, it does not take too deep of a traversal to slow the performance down to a screeching halt.

![Effect of Ray Depth on FPS](img/raydepthchart.png)
Binary file added img/Proj5Conceptual3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/raydepthchart.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/working_raytracer.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
144 changes: 108 additions & 36 deletions src/D3D12RaytracingProceduralGeometry/DXR-AccelerationStructure.cpp

Large diffs are not rendered by default.

11 changes: 9 additions & 2 deletions src/D3D12RaytracingProceduralGeometry/DXR-Common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,19 @@ void DXProceduralProject::AllocateUAVBuffer(ID3D12Device* pDevice, UINT64 buffer
UINT DXProceduralProject::AllocateDescriptor(D3D12_CPU_DESCRIPTOR_HANDLE* cpuDescriptor, UINT descriptorIndexToUse)
{
auto descriptorHeapCpuBase = m_descriptorHeap->GetCPUDescriptorHandleForHeapStart();
if (descriptorIndexToUse >= m_descriptorHeap->GetDesc().NumDescriptors)
auto descHeapDesc = m_descriptorHeap->GetDesc();
UINT numDescriptors = descHeapDesc.NumDescriptors;
if (descriptorIndexToUse >= numDescriptors)
// if (descriptorIndexToUse >= m_descriptorHeap->GetDesc().NumDescriptors)
{
ThrowIfFalse(m_descriptorsAllocated < m_descriptorHeap->GetDesc().NumDescriptors, L"Ran out of descriptors on the heap!");
ThrowIfFalse(m_descriptorsAllocated < numDescriptors, L"Ran out of descriptors on the heap!\n");
// ThrowIfFalse(m_descriptorsAllocated < m_descriptorHeap->GetDesc().NumDescriptors, L"Ran out of descriptors on the heap!\n");
descriptorIndexToUse = m_descriptorsAllocated++;
}
*cpuDescriptor = CD3DX12_CPU_DESCRIPTOR_HANDLE(descriptorHeapCpuBase, descriptorIndexToUse, m_descriptorSize);
//char buffer[50];
//sprintf_s(buffer, "Allocated for index %d\n", descriptorIndexToUse);
//OutputDebugStringA(buffer);
return descriptorIndexToUse;
}

Expand Down
31 changes: 21 additions & 10 deletions src/D3D12RaytracingProceduralGeometry/DXR-DoRaytracing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ void DXProceduralProject::DoRaytracing()
m_sceneCB.CopyStagingToGpu(frameIndex);
commandList->SetComputeRootConstantBufferView(GlobalRootSignature::Slot::SceneConstant, m_sceneCB.GpuVirtualAddress(frameIndex));

// TODO-2.8: do a very similar operation for the m_aabbPrimitiveAttributeBuffer

// TDO-2.8: do a very similar operation for the m_aabbPrimitiveAttributeBuffer
m_aabbPrimitiveAttributeBuffer.CopyStagingToGpu(frameIndex);
//commandList->SetComputeRootShaderResourceView(GlobalRootSignature::Slot::AABBattributeBuffer, m_aabbPrimitiveAttributeBuffer.GpuVirtualAddress(frameIndex));
commandList->SetComputeRootShaderResourceView(GlobalRootSignature::Slot::AABBattributeBuffer, m_aabbPrimitiveAttributeBuffer.GpuVirtualAddress());

// Bind the descriptor heaps.
if (m_raytracingAPI == RaytracingAPI::FallbackLayer)
Expand All @@ -45,27 +47,36 @@ void DXProceduralProject::DoRaytracing()
commandList->SetComputeRootShaderResourceView(GlobalRootSignature::Slot::AccelerationStructure, m_topLevelAS->GetGPUVirtualAddress());
}

// TODO-2.8: Bind the Index/Vertex buffer (basically m_indexBuffer. Think about why this isn't m_vertexBuffer too. Hint: CreateRootSignatures() in DXR-Pipeline.cpp.)
// TDO-2.8: Bind the Index/Vertex buffer (basically m_indexBuffer. Think about why this isn't m_vertexBuffer too. Hint: CreateRootSignatures() in DXR-Pipeline.cpp.)
// This should be done by telling the commandList to SetComputeRoot*(). You just have to figure out what * is.
// Example: in the case of GlobalRootSignature::Slot::SceneConstant above, we used SetComputeRootConstantBufferView()
// Hint: look at CreateRootSignatures() in DXR-Pipeline.cpp.
commandList->SetComputeRootDescriptorTable(GlobalRootSignature::Slot::VertexBuffers, m_indexBuffer.gpuDescriptorHandle);


// TODO-2.8: Bind the OutputView (basically m_raytracingOutputResourceUAVGpuDescriptor). Very similar to the Index/Vertex buffer.

// TDO-2.8: Bind the OutputView (basically m_raytracingOutputResourceUAVGpuDescriptor). Very similar to the Index/Vertex buffer.
commandList->SetComputeRootDescriptorTable(GlobalRootSignature::Slot::OutputView, m_raytracingOutputResourceUAVGpuDescriptor);

// This will define a `DispatchRays` function that takes in a command list, a pipeline state, and a descriptor
// This will set the hooks using the shader tables built before and call DispatchRays on the command list
auto DispatchRays = [&](auto* raytracingCommandList, auto* stateObject, auto* dispatchDesc)
{
// You will fill in a D3D12_DISPATCH_RAYS_DESC (which is dispatchDesc).
// TODO-2.8: fill in dispatchDesc->HitGroupTable. Look up the struct D3D12_GPU_VIRTUAL_ADDRESS_RANGE_AND_STRIDE


// TODO-2.8: now fill in dispatchDesc->MissShaderTable
// TDO-2.8: fill in dispatchDesc->HitGroupTable. Look up the struct D3D12_GPU_VIRTUAL_ADDRESS_RANGE_AND_STRIDE
//dispatchDesc->HitGroupTable = { m_hitGroupShaderTable->GetGPUVirtualAddress(), m_hitGroupShaderTableStrideInBytes };
dispatchDesc->HitGroupTable = { m_hitGroupShaderTable->GetGPUVirtualAddress(),
m_hitGroupShaderTable->GetDesc().Width,
m_hitGroupShaderTableStrideInBytes};

// TDO-2.8: now fill in dispatchDesc->MissShaderTable
dispatchDesc->MissShaderTable = { m_missShaderTable->GetGPUVirtualAddress(),
m_missShaderTable->GetDesc().Width,
m_missShaderTableStrideInBytes };


// TODO-2.8: now fill in dispatchDesc->RayGenerationShaderRecord
// TDO-2.8: now fill in dispatchDesc->RayGenerationShaderRecord
dispatchDesc->RayGenerationShaderRecord = { m_rayGenShaderTable->GetGPUVirtualAddress(),
m_rayGenShaderTable->GetDesc().Width };


// We do this for you. This will define how many threads will be dispatched. Basically like a blockDims in CUDA!
Expand Down
8 changes: 8 additions & 0 deletions src/D3D12RaytracingProceduralGeometry/DXR-DynamicBuffers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,10 @@ void DXProceduralProject::CreateConstantBuffers()
// structured buffers are for structs that have dynamic data (e.g lights in a scene, or AABBs in this case)
void DXProceduralProject::CreateAABBPrimitiveAttributesBuffers()
{
auto device = m_deviceResources->GetD3DDevice();
auto num_objects = m_aabbs.size();

m_aabbPrimitiveAttributeBuffer.Create(device, num_objects, 1, L"AABB Primitive Attribute Buffer");
}

// LOOKAT-2.1: Update camera matrices stored in m_sceneCB.
Expand Down Expand Up @@ -164,6 +167,11 @@ void DXProceduralProject::UpdateAABBPrimitiveAttributes(float animationTime)
// You can infer what the bottom level AS space to local space transform should be.
// The intersection shader tests in this project work with local space, but the geometries are provided in bottom level
// AS space. So this data will be used to convert back and forth from these spaces.
auto transformMatrix = XMMatrixMultiply(mScale, mRotation);
transformMatrix = XMMatrixMultiply(transformMatrix, mTranslation);
auto invTransformMatrix = XMMatrixInverse(nullptr, transformMatrix);
m_aabbPrimitiveAttributeBuffer[primitiveIndex].localSpaceToBottomLevelAS = transformMatrix;
m_aabbPrimitiveAttributeBuffer[primitiveIndex].bottomLevelASToLocalSpace = invTransformMatrix;
};

UINT offset = 0;
Expand Down
48 changes: 35 additions & 13 deletions src/D3D12RaytracingProceduralGeometry/DXR-Geometry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,13 @@ void DXProceduralProject::BuildPlaneGeometry()
ThrowIfFalse(descriptorIndexVB == descriptorIndexIB + 1, L"Vertex Buffer descriptor index must follow that of Index Buffer descriptor index");
}

// TODO-2.5: Build AABBs for procedural geometry that will be used within the acceleration structure.
// TDO-2.5: Build AABBs for procedural geometry that will be used within the acceleration structure.
void DXProceduralProject::BuildProceduralGeometryAABBs()
{
auto device = m_deviceResources->GetD3DDevice();

// Set up AABBs on a grid.
// But fucking why though? It seems *super* arbitrary
{
// 9x3 slots = 9 slots. Note that one procedural geometry can take up multiple slots.
// You could have a small sphere that takes up 1 slot, and another that is giant and takes up 4 slots.
Expand All @@ -71,51 +72,72 @@ void DXProceduralProject::BuildProceduralGeometryAABBs()
// The division by 2 centers the grid. The base position is still at the -x,-z corner.
const XMFLOAT3 basePosition =
{
-(aabbGrid.x * c_aabbWidth + (aabbGrid.x - 1) * c_aabbDistance) / 2.0f,
-(aabbGrid.y * c_aabbWidth + (aabbGrid.y - 1) * c_aabbDistance) / 2.0f,
-(aabbGrid.z * c_aabbWidth + (aabbGrid.z - 1) * c_aabbDistance) / 2.0f,
-(aabbGrid.x * c_aabbWidth + (aabbGrid.x - 1) * c_aabbDistance) / 2.0f,//-(6+4)/2=-5
-(aabbGrid.y * c_aabbWidth + (aabbGrid.y - 1) * c_aabbDistance) / 2.0f,//-(2+0)/2=-1
-(aabbGrid.z * c_aabbWidth + (aabbGrid.z - 1) * c_aabbDistance) / 2.0f,//-(6+4)/2=-5
};

// The stride is "how much to move" for the next slot. This is basically the size of a slot + it's separation from its direct
// neighbor
XMFLOAT3 stride = XMFLOAT3(c_aabbWidth + c_aabbDistance, c_aabbWidth + c_aabbDistance, c_aabbWidth + c_aabbDistance);
XMFLOAT3 stride = XMFLOAT3(c_aabbWidth + c_aabbDistance, c_aabbWidth + c_aabbDistance, c_aabbWidth + c_aabbDistance);//(4, 4, 4)

// TODO-2.5: Lookup the DXR API for the D3D12_RAYTRACING_AABB struct and fill up this lamda function that creates
// TDO-2.5: Lookup the DXR API for the D3D12_RAYTRACING_AABB struct and fill up this lamda function that creates
// and returns an D3D12_RAYTRACING_AABB for you.
// Note that you are only filling an axis-aligned bounding box.
// This should take into account the basePosition and the stride defined above.
auto InitializeAABB = [&](auto& offsetIndex, auto& size)
auto InitializeAABB = [&](XMFLOAT3& offsetIndex, auto& size)
{
D3D12_RAYTRACING_AABB aabb{};
//center coordinate for our (0, 0) index point
XMFLOAT3 baseCenter = { basePosition.x + c_aabbWidth / 2.0f,
basePosition.y + c_aabbWidth / 2.0f,
basePosition.z + c_aabbWidth / 2.0f};
XMFLOAT3 myCenter = baseCenter;// + offsetIndex * stride
myCenter.x += stride.x * ((aabbGrid.x - 1) / 2.0f + offsetIndex.x);
myCenter.y += stride.y * ((aabbGrid.y - 1) / 2.0f + offsetIndex.y);
myCenter.z += stride.z * ((aabbGrid.z - 1) / 2.0f + offsetIndex.z);
aabb.MaxX = myCenter.x + size.x / 2.0f;
aabb.MaxY = myCenter.y + size.y / 2.0f;
aabb.MaxZ = myCenter.z + size.z / 2.0f;
aabb.MinX = myCenter.x - size.x / 2.0f;
aabb.MinY = myCenter.y - size.y / 2.0f;
aabb.MinZ = myCenter.z - size.z / 2.0f;
char buffer[300];
sprintf_s(buffer, "AABB:\tX[%f,%f]\tY[%f,%f]\tZ[%f,%f]\n", aabb.MinX, aabb.MaxX, aabb.MinY, aabb.MaxY, aabb.MinZ, aabb.MaxZ);
OutputDebugStringA(buffer);

return aabb;
};
m_aabbs.resize(IntersectionShaderType::TotalPrimitiveCount);
UINT offset = 0;

//THIS IS WHERE WE ARE HARDCODING SOME GEOMETRY BECAUSE WHY WOULDN'T WE I GUESS
// Analytic primitives.
{
using namespace AnalyticPrimitive;
m_aabbs[offset + AABB] = InitializeAABB(XMFLOAT3(0.5f, 0.0f, 0.0f), XMFLOAT3(2.0f, 3.0f, 2.0f));
m_aabbs[offset + Spheres] = InitializeAABB(XMFLOAT3(1.0f, 0.75f, -0.5f), XMFLOAT3(3, 3, 3));
m_aabbs[offset + Spheres] = InitializeAABB(XMFLOAT3(1.0f, 0.5f, -0.5f), XMFLOAT3(3.0f, 3.0f, 3.0f));
offset += AnalyticPrimitive::Count;
}

// Volumetric primitives.
{
using namespace VolumetricPrimitive;
m_aabbs[offset + Metaballs] = InitializeAABB(XMINT3(-1, 0, 0), XMFLOAT3(6, 6, 6));
m_aabbs[offset + Metaballs] = InitializeAABB(XMFLOAT3(-1.0f, 0.5f, 1.0f), XMFLOAT3(6.0f, 6.0f, 6.0f));
offset += VolumetricPrimitive::Count;
}

// TODO-2.5: Allocate an upload buffer for this AABB data.
// TDO-2.5: Allocate an upload buffer for this AABB data.
// The base data lives in m_aabbs.data() (the stuff you filled in!), but the allocationg should be pointed
// towards m_aabbBuffer.resource (the actual D3D12 resource that will hold all of our AABB data as a contiguous buffer).

AllocateUploadBuffer(device, m_aabbs.data(), m_aabbs.size() * sizeof(m_aabbs[0]), &m_aabbBuffer.resource);

}
}

// TODO-2.5: Build geometry used in the project. As easy as calling both functions above :)
// TDO-2.5: Build geometry used in the project. As easy as calling both functions above :)
void DXProceduralProject::BuildGeometry()
{

BuildPlaneGeometry();
BuildProceduralGeometryAABBs();
}
35 changes: 29 additions & 6 deletions src/D3D12RaytracingProceduralGeometry/DXR-HitGroup.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#include "stdafx.h"
#include "stdafx.h"
#include "DXProceduralProject.h"
#include "CompiledShaders\Raytracing.hlsl.h"

// LOOKAT-2.3, TODO-2.3: Create the hitgroup pipeline subobject.
// LOOKAT-2.3, TDO-2.3: Create the hitgroup pipeline subobject.
// A hitgroup specifies closest hit (mandatory), any hit (optional) and intersection shaders (mandatory but not for triangles).
// They are executed when a ray intersects the geometry.
// See how we do it for 1 triangle, and apply that logic to an AABB.
Expand All @@ -27,13 +27,28 @@ void DXProceduralProject::CreateHitGroupSubobjects(CD3D12_STATE_OBJECT_DESC* ray
}
}

// TODO-2.3: AABB geometry hit groups. Very similar to triangles, except now you have to *also* loop over the primitive types.
// TDO-2.3: AABB geometry hit groups. Very similar to triangles, except now you have to *also* loop over the primitive types.
{
for (UINT rayType = 0; rayType < RayType::Count; rayType++)
{
for (UINT primitiveType = 0; primitiveType < IntersectionShaderType::Count; primitiveType++) {
auto hitGroup = raytracingPipeline->CreateSubobject<CD3D12_HIT_GROUP_SUBOBJECT>();
if (rayType == RayType::Radiance)
{
hitGroup->SetClosestHitShaderImport(c_closestHitShaderNames[GeometryType::AABB]);
// We import the closest hit shader name
}
hitGroup->SetIntersectionShaderImport(c_intersectionShaderNames[primitiveType]);
// We tell the hitgroup that it should export into the correct shader hit group name, with the correct type
hitGroup->SetHitGroupExport(c_hitGroupNames_AABBGeometry[primitiveType][rayType]);
hitGroup->SetHitGroupType(D3D12_HIT_GROUP_TYPE_PROCEDURAL_PRIMITIVE);
}

}
}
}

// TODO-2.3: Local root signature and shader association (linking)
// TDO-2.3: Local root signature and shader association (linking)
void DXProceduralProject::CreateLocalRootSignatureSubobjects(CD3D12_STATE_OBJECT_DESC* raytracingPipeline)
{
// Ray gen and miss shaders in this project are not using a local root signature and thus one is not associated with them.
Expand All @@ -51,9 +66,17 @@ void DXProceduralProject::CreateLocalRootSignatureSubobjects(CD3D12_STATE_OBJECT
rootSignatureAssociation->AddExports(c_hitGroupNames_TriangleGeometry);
}

// TODO-2.3: AABB geometry hitgroup/local root signature association.
// TDO-2.3: AABB geometry hitgroup/local root signature association.
// Very similar to triangles, except now one for each primitive type.
{

auto localRootSignature = raytracingPipeline->CreateSubobject<CD3D12_LOCAL_ROOT_SIGNATURE_SUBOBJECT>();
localRootSignature->SetRootSignature(m_raytracingLocalRootSignature[LocalRootSignature::Type::AABB].Get());

auto rootSignatureAssociation = raytracingPipeline->CreateSubobject<CD3D12_SUBOBJECT_TO_EXPORTS_ASSOCIATION_SUBOBJECT>();
rootSignatureAssociation->SetSubobjectToAssociate(*localRootSignature);
rootSignatureAssociation->AddExports(c_hitGroupNames_AABBGeometry[IntersectionShaderType::AnalyticPrimitive]);
rootSignatureAssociation->AddExports(c_hitGroupNames_AABBGeometry[IntersectionShaderType::VolumetricPrimitive]);


}
}
16 changes: 16 additions & 0 deletions src/D3D12RaytracingProceduralGeometry/DXR-Other.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@
#include "DXProceduralProject.h"
#include "CompiledShaders\Raytracing.hlsl.h"

#ifndef CAPTURING
#define CAPTURING 0
#endif

#if CAPTURING
#include <DXProgrammableCapture.h>
#endif

// LOOKAT-1.8.3: This file contains pretty much everything else we decided was not too important. Feel free to explore what's going on here though.

using namespace std;
Expand Down Expand Up @@ -55,6 +63,11 @@ void DXProceduralProject::EnableDirectXRaytracing(IDXGIAdapter1* adapter)
// Create resources that depend on the device.
void DXProceduralProject::CreateDeviceDependentResources()
{
#if CAPTURING
ComPtr<IDXGraphicsAnalysis> ga;
HRESULT hr = DXGIGetDebugInterface1(0, IID_PPV_ARGS(&ga));
ga->BeginCapture();
#endif
CreateAuxilaryDeviceResources();

// Create raytracing interfaces: raytracing device and commandlist.
Expand Down Expand Up @@ -86,6 +99,9 @@ void DXProceduralProject::CreateDeviceDependentResources()

// Create an output 2D texture to store the raytracing result to.
CreateRaytracingOutputResource();
#if CAPTURING
ga->EndCapture();
#endif
}

// Selects the RTX API to use and tells the device to create a root signature given the descriptor.
Expand Down
Loading