Skip to content

Project 5: Vaibhav Arcot #44

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 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
43 changes: 37 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,42 @@
**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)
* Name: Vaibhav Arcot
* [LinkedIn] (https://www.linkedin.com/in/vaibhav-arcot-129829167/)
* Tested on: Windows 10, i7-7700HQ @ 2.8GHz (3.8 Boost) 32GB, External GTX 1080Ti, 11G (My personal laptop)
![Banner](./images/camera_light.gif)

### (TODO: Your README)
## Overview

This repo contains a toy ray tracer using DirectX API. This differs from path tracing (can be found [here]( https://github.com/Black-Phoenix/Project3-CUDA-Path-Tracer )) in the sense that each ray has a deterministic way it bounces, so we don't need to sample multiple rays per pixel to generate a cohesive picture.

## Approach
A general overview of ray tracing is well summarized in the following picture. We first generate rays for each pixel into the scene. Once we have the rays, we then find the intersection with the ray to objects in the scene. Once we hit an object we spawn 2 types of rays, a shadow ray and depending on the material, another view ray.
![](./images/raytrace.jpg)
The DXR pipeline follows a very similar pipeline, shown below.

![](./images/pipeline.png)

## Results

To showcase the final output, below are a few gifs of the output. The first one is with just the metaballs & spheres moving

![simple](./images/simple.gif)

Below is a gif of the light moving around the objects in the scene (and a pause to the animation in the middle)

![light](./images/light.gif)

Finally below is a gif of the camera moving around the stationary objects

![](./images/camera_fixed.gif)

## Analysis
Performance metrics were collected to showcase the effects of depth on various metrics

| Metric | Graph |
| ----------------------- | --------------------------------------- |
| FPS | ![FPS](./images/depth_vs_fps.png) |
| Dispatch ray function | ![](./images/depth_vs_dispatchRay.png) |
| Primary rays per second | ![](./images/depth_vs_primary_rays.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.)
Binary file added images/camera_fixed.gif
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 images/camera_light.gif
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 images/data.xlsx
Binary file not shown.
Binary file added images/depth_vs_dispatchRay.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 images/depth_vs_fps.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 images/depth_vs_primary_rays.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 images/light.gif
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 images/simple.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
30 changes: 21 additions & 9 deletions src/D3D12RaytracingProceduralGeometry/AnalyticPrimitives.hlsli
Original file line number Diff line number Diff line change
Expand Up @@ -166,18 +166,30 @@ bool RaySolidSphereIntersectionTest(in Ray ray, out float thit, out float tmax,
bool RayMultipleSpheresIntersectionTest(in Ray ray, out float thit, out ProceduralPrimitiveAttributes attr)
{
// Define the spheres in local space (within the aabb)
float3 center = float3(-0.2, 0, -0.2);
float radius = 0.7f;

float3 centers[3] =
{
float3(-0.2, 0, -0.2),
float3(0.4, 0.1, 0.2),
float3(0.3, 0.2, 0.1)
};
float radius[3] = { 0.7f, 0.3f, 0.6f };
thit = RayTCurrent();
bool hit = false;
for (int i = 0; i < 3; i++) {
float tmax;
float thit_tmp;
ProceduralPrimitiveAttributes attr_tmp;
if (RaySphereIntersectionTest(ray, thit_tmp, tmax, attr_tmp, centers[i], radius[i]))
{
if (thit_tmp < thit) {
thit = thit_tmp;
attr = attr_tmp;
hit = true;
}
}

float tmax;
if (RaySphereIntersectionTest(ray, thit, tmax, attr, center, radius))
{
return true;
}

return false;
return hit;
}

#endif // ANALYTICPRIMITIVES_H
74 changes: 59 additions & 15 deletions src/D3D12RaytracingProceduralGeometry/DXR-AccelerationStructure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,19 @@ void DXProceduralProject::BuildGeometryDescsForBottomLevelAS(array<vector<D3D12_
// TODO-2.6: Fill the triangle geometry desc.
// * Remember to use m_indexBuffer and m_vertexBuffer to get pointers to the data.
// * GPUVirtualAddresses can be accessed from a D3D12Resource using GetGPUVirtualAddress() (e.g m_vertexBuffer.resource->GetGPUVirtualAddress())
// * The *total size* of the buffer can be accessed from GetDesc().Width (e.g m_indexBuffer.resource->GetDesc().Width)
// * The *total size* of the buffer can be accessed from GetDesc().Width (e.g m_indexBuffer.resource->GetDesc().Width) (in bytes)
// * We filled in the format of the buffers to avoid confusion.
auto& geometryDesc = geometryDescs[BottomLevelASType::Triangle][0];
geometryDesc = {};
geometryDesc.Type = D3D12_RAYTRACING_GEOMETRY_TYPE_TRIANGLES;
geometryDesc.Triangles.IndexBuffer = m_indexBuffer.resource->GetGPUVirtualAddress();
geometryDesc.Triangles.VertexBuffer.StartAddress = m_vertexBuffer.resource->GetGPUVirtualAddress();
geometryDesc.Triangles.VertexBuffer.StrideInBytes = 2 * sizeof(XMFLOAT3);
geometryDesc.Triangles.IndexCount = m_indexBuffer.resource->GetDesc().Width/sizeof(Index);
geometryDesc.Triangles.VertexCount = m_vertexBuffer.resource->GetDesc().Width/sizeof(Vertex);
geometryDesc.Triangles.IndexFormat = DXGI_FORMAT_R16_UINT;
geometryDesc.Triangles.VertexFormat = DXGI_FORMAT_R32G32B32_FLOAT;
geometryDesc.Flags = geometryFlags;
}

{
Expand All @@ -51,7 +58,11 @@ void DXProceduralProject::BuildGeometryDescsForBottomLevelAS(array<vector<D3D12_
// Remember to use m_aabbBuffer to get the AABB geometry data you previously filled in.
// Note: Having separate geometries allows of separate shader record binding per geometry.
// In this project, this lets us specify custom hit groups per AABB geometry.


for (auto primitiveType = 0; primitiveType < IntersectionShaderType::TotalPrimitiveCount; primitiveType++) {
(geometryDescs[BottomLevelASType::AABB][primitiveType]).AABBs.AABBs.StartAddress =
m_aabbBuffer.resource->GetGPUVirtualAddress() + primitiveType * aabbDescTemplate.AABBs.AABBs.StrideInBytes;
}
}
}

Expand All @@ -70,6 +81,11 @@ AccelerationStructureBuffers DXProceduralProject::BuildBottomLevelAS(const vecto
// Again, these tell the AS where the actual geometry data is and how it is laid out.
// TODO-2.6: fill the bottom-level inputs. Consider using D3D12_ELEMENTS_LAYOUT_ARRAY as the DescsLayout.
D3D12_BUILD_RAYTRACING_ACCELERATION_STRUCTURE_INPUTS &bottomLevelInputs = bottomLevelBuildDesc.Inputs;
bottomLevelInputs.Flags = buildFlags;
bottomLevelInputs.Type = D3D12_RAYTRACING_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL;
bottomLevelInputs.DescsLayout = D3D12_ELEMENTS_LAYOUT_ARRAY;
bottomLevelInputs.NumDescs = geometryDescs.size();
bottomLevelInputs.pGeometryDescs = geometryDescs.data();


// Query the driver for resource requirements to build an acceleration structure. We've done this for you.
Expand Down Expand Up @@ -110,7 +126,9 @@ AccelerationStructureBuffers DXProceduralProject::BuildBottomLevelAS(const vecto
// TODO-2.6: Now that you have the scratch and actual bottom-level AS desc, pass their GPU addresses to the bottomLevelBuildDesc.
// Consider reading about D3D12_BUILD_RAYTRACING_ACCELERATION_STRUCTURE_DESC.
// This should be as easy as passing the GPU addresses to the struct using GetGPUVirtualAddress() calls.


bottomLevelBuildDesc.ScratchAccelerationStructureData = scratch->GetGPUVirtualAddress();
bottomLevelBuildDesc.DestAccelerationStructureData = bottomLevelAS->GetGPUVirtualAddress();

// Fill up the command list with a command that tells the GPU how to build the bottom-level AS.
if (m_raytracingAPI == RaytracingAPI::FallbackLayer)
Expand All @@ -129,7 +147,7 @@ AccelerationStructureBuffers DXProceduralProject::BuildBottomLevelAS(const vecto
// the AccelerationStructureBuffers struct so the top-level AS can use it!
// Don't forget that this is the return value.
// Consider looking into the AccelerationStructureBuffers struct in DXR-Structs.h
return AccelerationStructureBuffers{};
return AccelerationStructureBuffers{scratch, bottomLevelAS, nullptr, bottomLevelPrebuildInfo.ResultDataMaxSizeInBytes};
}

// TODO-2.6: Build the instance descriptor for each bottom-level AS you built before.
Expand Down Expand Up @@ -181,7 +199,19 @@ void DXProceduralProject::BuildBottomLevelASInstanceDescs(BLASPtrType *bottomLev
// Where do you think procedural shader records would start then? Hint: right after.
// * Make each instance hover above the ground by ~ half its width
{
// Make the plane a little larger than the actual number of primitives in each dimension.

auto& instanceDesc = instanceDescs[BottomLevelASType::AABB];
instanceDesc = {};
instanceDesc.InstanceMask = 1;
instanceDesc.InstanceContributionToHitGroupIndex = 2;
instanceDesc.AccelerationStructure = bottomLevelASaddresses[BottomLevelASType::AABB];

// Store the transform in the instanceDesc.
XMMATRIX mTransform = XMMatrixTranslationFromVector(XMLoadFloat3(&XMFLOAT3(0.0f, c_aabbWidth * 0.5f, 0.0f)));

// Store the transform in the instanceDesc.
XMStoreFloat3x4(reinterpret_cast<XMFLOAT3X4*>(instanceDesc.Transform), mTransform);
}

// Upload all these instances to the GPU, and make sure the resouce is set to instanceDescsResource.
Expand All @@ -204,7 +234,11 @@ AccelerationStructureBuffers DXProceduralProject::BuildTopLevelAS(AccelerationSt
// TODO-2.6: fill in the topLevelInputs, read about D3D12_BUILD_RAYTRACING_ACCELERATION_STRUCTURE_INPUTS.
// Consider using D3D12_ELEMENTS_LAYOUT_ARRAY as a DescsLayout since we are using an array of bottom-level AS.
D3D12_BUILD_RAYTRACING_ACCELERATION_STRUCTURE_INPUTS &topLevelInputs = topLevelBuildDesc.Inputs;

topLevelInputs.Flags = buildFlags;
topLevelInputs.Type = D3D12_RAYTRACING_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL;
topLevelInputs.NumDescs = BottomLevelASType::Count;
topLevelInputs.DescsLayout = D3D12_ELEMENTS_LAYOUT_ARRAY;
//topLevelInputs.InstanceDescs = bottomLevelAS[0].instanceDesc->GetGPUVirtualAddress();

D3D12_RAYTRACING_ACCELERATION_STRUCTURE_PREBUILD_INFO topLevelPrebuildInfo = {};
if (m_raytracingAPI == RaytracingAPI::FallbackLayer)
Expand All @@ -218,7 +252,7 @@ AccelerationStructureBuffers DXProceduralProject::BuildTopLevelAS(AccelerationSt
ThrowIfFalse(topLevelPrebuildInfo.ResultDataMaxSizeInBytes > 0);

// TODO-2.6: Allocate a UAV buffer for the scracth/temporary top-level AS data.

AllocateUAVBuffer(device, topLevelPrebuildInfo.ScratchDataSizeInBytes, &scratch, D3D12_RESOURCE_STATE_UNORDERED_ACCESS, L"ScratchResource");

// Allocate space for the top-level AS.
{
Expand All @@ -233,6 +267,7 @@ AccelerationStructureBuffers DXProceduralProject::BuildTopLevelAS(AccelerationSt
}

// TODO-2.6: Allocate a UAV buffer for the actual top-level AS.
AllocateUAVBuffer(device, topLevelPrebuildInfo.ResultDataMaxSizeInBytes, &topLevelAS, initialResourceState, L"TopLevelAccelerationStructure");

}

Expand Down Expand Up @@ -261,7 +296,7 @@ AccelerationStructureBuffers DXProceduralProject::BuildTopLevelAS(AccelerationSt
};

// TODO-2.6: Call the fallback-templated version of BuildBottomLevelASInstanceDescs() you completed above.

BuildBottomLevelASInstanceDescs<D3D12_RAYTRACING_FALLBACK_INSTANCE_DESC, WRAPPED_GPU_POINTER>(bottomLevelASaddresses, &instanceDescsResource);
}
else // DirectX Raytracing
{
Expand All @@ -273,7 +308,8 @@ AccelerationStructureBuffers DXProceduralProject::BuildTopLevelAS(AccelerationSt
};

// TODO-2.6: Call the DXR-templated version of BuildBottomLevelASInstanceDescs() you completed above.

BuildBottomLevelASInstanceDescs<D3D12_RAYTRACING_INSTANCE_DESC, D3D12_GPU_VIRTUAL_ADDRESS>(bottomLevelASaddresses, &instanceDescsResource);

}

// Create a wrapped pointer to the acceleration structure.
Expand All @@ -286,7 +322,10 @@ AccelerationStructureBuffers DXProceduralProject::BuildTopLevelAS(AccelerationSt
// TODO-2.6: fill in the topLevelBuildDesc. Read about D3D12_BUILD_RAYTRACING_ACCELERATION_STRUCTURE_DESC.
// This should be as easy as passing the GPU addresses to the struct using GetGPUVirtualAddress() calls.


topLevelBuildDesc.ScratchAccelerationStructureData = scratch->GetGPUVirtualAddress();
topLevelBuildDesc.DestAccelerationStructureData = topLevelAS->GetGPUVirtualAddress();
topLevelInputs.InstanceDescs = instanceDescsResource->GetGPUVirtualAddress();

// Build acceleration structure.
if (m_raytracingAPI == RaytracingAPI::FallbackLayer)
{
Expand All @@ -304,7 +343,7 @@ AccelerationStructureBuffers DXProceduralProject::BuildTopLevelAS(AccelerationSt
// Very similar to how you did this in BuildBottomLevelAS() except now you have to worry about topLevelASBuffers.instanceDesc.
// Consider looking into the AccelerationStructureBuffers struct in DXR-Structs.h.
// Make sure to return the topLevelASBuffers before you exit the function.
return AccelerationStructureBuffers{};
return AccelerationStructureBuffers{ scratch, topLevelAS, instanceDescsResource, topLevelPrebuildInfo.ResultDataMaxSizeInBytes };
}

// TODO-2.6: This will wrap building the Acceleration Structure! This is what we will call when building our scene.
Expand All @@ -320,11 +359,14 @@ void DXProceduralProject::BuildAccelerationStructures()

// TODO-2.6: Build the geometry descriptors. Hint: you filled in a function that does this.
array<vector<D3D12_RAYTRACING_GEOMETRY_DESC>, BottomLevelASType::Count> geometryDescs;

BuildGeometryDescsForBottomLevelAS(geometryDescs);

// TODO-2.6: For each bottom-level object (triangle, procedural), build a bottom-level AS.
// Hint: you filled in a function that does this.
AccelerationStructureBuffers bottomLevelAS[BottomLevelASType::Count];
for (int i = 0; i < BottomLevelASType::Count; i++) {
bottomLevelAS[i] = BuildBottomLevelAS(geometryDescs[i]);
}


// Batch all resource barriers for bottom-level AS builds.
Expand All @@ -338,8 +380,7 @@ void DXProceduralProject::BuildAccelerationStructures()

// TODO-2.6: Build top-level AS. Hint, you already made a function that does this.
AccelerationStructureBuffers topLevelAS;


topLevelAS = BuildTopLevelAS(bottomLevelAS);
// Kick off acceleration structure construction.
m_deviceResources->ExecuteCommandList();

Expand All @@ -349,5 +390,8 @@ void DXProceduralProject::BuildAccelerationStructures()
// TODO-2.6: Store the AS buffers. The rest of the buffers will be released once we exit the function.
// Do this for both the bottom-level and the top-level AS. Consider re-reading the DXProceduralProject class
// to find what member variables should be set.

}
for (int i = 0; i < BottomLevelASType::Count; i++) {
m_bottomLevelAS[i] = bottomLevelAS[i].accelerationStructure;
}
m_topLevelAS = topLevelAS.accelerationStructure;
}
21 changes: 16 additions & 5 deletions src/D3D12RaytracingProceduralGeometry/DXR-DoRaytracing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ void DXProceduralProject::DoRaytracing()
commandList->SetComputeRootConstantBufferView(GlobalRootSignature::Slot::SceneConstant, m_sceneCB.GpuVirtualAddress(frameIndex));

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

m_aabbPrimitiveAttributeBuffer.CopyStagingToGpu(frameIndex);
commandList->SetComputeRootShaderResourceView(GlobalRootSignature::Slot::AABBattributeBuffer, m_aabbPrimitiveAttributeBuffer.GpuVirtualAddress(frameIndex));


// Bind the descriptor heaps.
if (m_raytracingAPI == RaytracingAPI::FallbackLayer)
Expand Down Expand Up @@ -50,23 +52,32 @@ void DXProceduralProject::DoRaytracing()
// 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.

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

dispatchDesc->HitGroupTable.StartAddress = m_hitGroupShaderTable->GetGPUVirtualAddress();
dispatchDesc->HitGroupTable.SizeInBytes = m_hitGroupShaderTable->GetDesc().Width;
dispatchDesc->HitGroupTable.StrideInBytes = m_hitGroupShaderTableStrideInBytes;

// TODO-2.8: now fill in dispatchDesc->MissShaderTable

dispatchDesc->MissShaderTable.StartAddress = m_missShaderTable->GetGPUVirtualAddress();
dispatchDesc->MissShaderTable.SizeInBytes = m_missShaderTable->GetDesc().Width;
dispatchDesc->MissShaderTable.StrideInBytes = m_missShaderTableStrideInBytes;

// TODO-2.8: now fill in dispatchDesc->RayGenerationShaderRecord

dispatchDesc->RayGenerationShaderRecord.StartAddress = m_rayGenShaderTable->GetGPUVirtualAddress();
dispatchDesc->RayGenerationShaderRecord.SizeInBytes = m_rayGenShaderTable->GetDesc().Width;


// We do this for you. This will define how many threads will be dispatched. Basically like a blockDims in CUDA!
dispatchDesc->Width = m_width;
Expand All @@ -92,4 +103,4 @@ void DXProceduralProject::DoRaytracing()
{
DispatchRays(m_dxrCommandList.Get(), m_dxrStateObject.Get(), &dispatchDesc);
}
}
}
10 changes: 9 additions & 1 deletion 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 frameCount = m_deviceResources->GetBackBufferCount();
auto numElements = m_aabbs.size();
m_aabbPrimitiveAttributeBuffer.Create(device, numElements, frameCount, L"AABB primitive attributes 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.
// XMMATRIX localSpaceToBottomLevelAS; // Matrix from local primitive space to bottom-level object space.
// XMMATRIX bottomLevelASToLocalSpace; // Matrix from bottom-level object space to local primitive space
XMMATRIX mTransform = XMMatrixMultiply(XMMatrixMultiply(mScale, mRotation), mTranslation);
m_aabbPrimitiveAttributeBuffer[primitiveIndex].localSpaceToBottomLevelAS = mTransform;
m_aabbPrimitiveAttributeBuffer[primitiveIndex].bottomLevelASToLocalSpace = XMMatrixInverse(nullptr, mTransform);
};

UINT offset = 0;
Expand Down
12 changes: 9 additions & 3 deletions src/D3D12RaytracingProceduralGeometry/DXR-Geometry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,12 @@ void DXProceduralProject::BuildProceduralGeometryAABBs()
// This should take into account the basePosition and the stride defined above.
auto InitializeAABB = [&](auto& offsetIndex, auto& size)
{
D3D12_RAYTRACING_AABB aabb{};
D3D12_RAYTRACING_AABB aabb{ basePosition.x + offsetIndex.x * stride.x,
basePosition.y + offsetIndex.y * stride.y,
basePosition.z + offsetIndex.z * stride.z,
basePosition.x + offsetIndex.x * stride.x + size.x,
basePosition.y + offsetIndex.y * stride.y + size.y,
basePosition.z + offsetIndex.z * stride.z + size.z};
return aabb;
};
m_aabbs.resize(IntersectionShaderType::TotalPrimitiveCount);
Expand All @@ -110,12 +115,13 @@ void DXProceduralProject::BuildProceduralGeometryAABBs()
// TODO-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 :)
void DXProceduralProject::BuildGeometry()
{

BuildPlaneGeometry();
BuildProceduralGeometryAABBs();
}
Loading