diff options
| author | lucy96chen <47800040+lucy96chen@users.noreply.github.com> | 2022-08-25 09:11:04 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-08-25 09:11:04 -0700 |
| commit | ef067bef2f2188a4b3c420cbcd8d223874888ed2 (patch) | |
| tree | 8469751f086779ba35d089d18d228cc404bf2531 | |
| parent | ba6f55ed9481960b4f6c7f0a6b8f1cf7d450c752 (diff) | |
Fix for Vulkan ray tracing test using a non-zero raygen shader index (#2380)
* Fixed math errors in SBT creation causing a ray tracing test to fail with a fully zero output when given a non-zero raygen shader index
* Removed unnecessary code
* raygen memcpy now copies the 32 bytes from srcHandle and zeroes out the remaining 32 bytes due to 64 byte alignment
| -rw-r--r-- | tools/gfx-unit-test/ray-tracing-tests.cpp | 3 | ||||
| -rw-r--r-- | tools/gfx/vulkan/vk-shader-table.cpp | 6 |
2 files changed, 3 insertions, 6 deletions
diff --git a/tools/gfx-unit-test/ray-tracing-tests.cpp b/tools/gfx-unit-test/ray-tracing-tests.cpp index 558c700d3..97a6ad7d1 100644 --- a/tools/gfx-unit-test/ray-tracing-tests.cpp +++ b/tools/gfx-unit-test/ray-tracing-tests.cpp @@ -488,11 +488,8 @@ namespace gfx_test runTestImpl(rayTracingTestImpl<RayTracingTestB>, unitTestContext, Slang::RenderApiFlag::D3D12); } -#if 0 - //TODO: fix test failure. SLANG_UNIT_TEST(RayTracingTestBVulkan) { runTestImpl(rayTracingTestImpl<RayTracingTestB>, unitTestContext, Slang::RenderApiFlag::Vulkan); } -#endif } diff --git a/tools/gfx/vulkan/vk-shader-table.cpp b/tools/gfx/vulkan/vk-shader-table.cpp index 89225f7c2..a47750ddb 100644 --- a/tools/gfx/vulkan/vk-shader-table.cpp +++ b/tools/gfx/vulkan/vk-shader-table.cpp @@ -22,8 +22,7 @@ RefPtr<BufferResource> ShaderTableImpl::createDeviceBuffer( auto vkApi = m_device->m_api; auto rtProps = vkApi.m_rtProperties; uint32_t handleSize = rtProps.shaderGroupHandleSize; - m_raygenTableSize = (uint32_t)VulkanUtil::calcAligned( - m_rayGenShaderCount * handleSize, rtProps.shaderGroupBaseAlignment); + m_raygenTableSize = m_rayGenShaderCount * rtProps.shaderGroupBaseAlignment; m_missTableSize = (uint32_t)VulkanUtil::calcAligned( m_missShaderCount * handleSize, rtProps.shaderGroupBaseAlignment); m_hitTableSize = (uint32_t)VulkanUtil::calcAligned( @@ -75,7 +74,7 @@ RefPtr<BufferResource> ShaderTableImpl::createDeviceBuffer( // index in the buffer of handles. for (uint32_t i = 0; i < m_rayGenShaderCount; i++) { - auto dstHandlePtr = subTablePtr + i * handleSize; + auto dstHandlePtr = subTablePtr + i * rtProps.shaderGroupBaseAlignment; auto shaderGroupName = m_shaderGroupNames[shaderTableEntryCounter++]; auto shaderGroupIndexPtr = pipelineImpl->shaderGroupNameToIndex.TryGetValue(shaderGroupName); @@ -85,6 +84,7 @@ RefPtr<BufferResource> ShaderTableImpl::createDeviceBuffer( auto shaderGroupIndex = *shaderGroupIndexPtr; auto srcHandlePtr = handles.getBuffer() + shaderGroupIndex * handleSize; memcpy(dstHandlePtr, srcHandlePtr, handleSize); + memset(dstHandlePtr + handleSize, 0, rtProps.shaderGroupBaseAlignment - handleSize); } subTablePtr += m_raygenTableSize; |
