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 /tools/gfx/vulkan/vk-shader-table.cpp | |
| 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
Diffstat (limited to 'tools/gfx/vulkan/vk-shader-table.cpp')
| -rw-r--r-- | tools/gfx/vulkan/vk-shader-table.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
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; |
