Skip to content

Commit

Permalink
examples: Fixes for ray-tracing examples
Browse files Browse the repository at this point in the history
- Assert that accelleration structure buffer is not nullptr
- Check if buffer creation succeeded before proceeding
 - This makes initialization not hang, but it still fails.
   Therefore, the test expectations are just updated to point to another issue.
- Enable ray-tracing tests on Windows
  • Loading branch information
aleino-nv committed Jan 3, 2025
1 parent 794c21b commit 60b9318
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 2 deletions.
4 changes: 4 additions & 0 deletions examples/ray-tracing-pipeline/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -382,13 +382,17 @@ struct RayTracing : public WindowedAppBase
asDraftBufferDesc.sizeInBytes =
(size_t)accelerationStructurePrebuildInfo.resultDataMaxSize;
ComPtr<IBufferResource> draftBuffer = gDevice->createBufferResource(asDraftBufferDesc);
if (!draftBuffer)
return SLANG_FAIL;
IBufferResource::Desc scratchBufferDesc;
scratchBufferDesc.type = IResource::Type::Buffer;
scratchBufferDesc.defaultState = ResourceState::UnorderedAccess;
scratchBufferDesc.sizeInBytes =
(size_t)accelerationStructurePrebuildInfo.scratchDataSize;
ComPtr<IBufferResource> scratchBuffer =
gDevice->createBufferResource(scratchBufferDesc);
if (!scratchBuffer)
return SLANG_FAIL;

// Build acceleration structure.
ComPtr<IQueryPool> compactedSizeQuery;
Expand Down
4 changes: 4 additions & 0 deletions examples/ray-tracing/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -373,12 +373,16 @@ struct RayTracing : public WindowedAppBase
asDraftBufferDesc.defaultState = ResourceState::AccelerationStructure;
asDraftBufferDesc.sizeInBytes = accelerationStructurePrebuildInfo.resultDataMaxSize;
ComPtr<IBufferResource> draftBuffer = gDevice->createBufferResource(asDraftBufferDesc);
if (!draftBuffer)
return SLANG_FAIL;
IBufferResource::Desc scratchBufferDesc;
scratchBufferDesc.type = IResource::Type::Buffer;
scratchBufferDesc.defaultState = ResourceState::UnorderedAccess;
scratchBufferDesc.sizeInBytes = accelerationStructurePrebuildInfo.scratchDataSize;
ComPtr<IBufferResource> scratchBuffer =
gDevice->createBufferResource(scratchBufferDesc);
if (!scratchBuffer)
return SLANG_FAIL;

// Build acceleration structure.
ComPtr<IQueryPool> compactedSizeQuery;
Expand Down
4 changes: 2 additions & 2 deletions tests/expected-example-failure-github.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ macos:aarch64:(debug|release):hello-world # See issue 5520
macos:aarch64:(debug|release):model-viewer # See issue 5520
macos:aarch64:(debug|release):ray-tracing # See issue 5520
macos:aarch64:(debug|release):ray-tracing-pipeline # See issue 5520
windows:x86_64:debug:ray-tracing # See issue 5520
windows:x86_64:debug:ray-tracing-pipeline # See issue 5520
windows:x86_64:debug:ray-tracing # See issue 5988
windows:x86_64:debug:ray-tracing-pipeline # See issue 5988
1 change: 1 addition & 0 deletions tools/gfx/d3d12/d3d12-device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2231,6 +2231,7 @@ Result DeviceImpl::createAccelerationStructure(
IAccelerationStructure** outAS)
{
#if SLANG_GFX_HAS_DXR_SUPPORT
assert(desc.buffer != nullptr);
RefPtr<AccelerationStructureImpl> result = new AccelerationStructureImpl();
result->m_device5 = m_device5;
result->m_buffer = static_cast<BufferResourceImpl*>(desc.buffer);
Expand Down

0 comments on commit 60b9318

Please sign in to comment.