summaryrefslogtreecommitdiffstats
path: root/tools/gfx
diff options
context:
space:
mode:
authorskallweitNV <64953474+skallweitNV@users.noreply.github.com>2022-10-26 17:28:16 +0200
committerGitHub <noreply@github.com>2022-10-26 08:28:16 -0700
commit26e622245b930f973963fa3200ab8dc0aadc3b1f (patch)
treec942fae8e51dc6c56f3023ec377d258e1e19c34c /tools/gfx
parent41cb7c13e37ec32ffb6557d21da079d77151e136 (diff)
Fix D3D12 dispatchRays() when using an empty miss and/or hitgroup table (#2468)
Diffstat (limited to 'tools/gfx')
-rw-r--r--tools/gfx/d3d12/d3d12-command-encoder.cpp28
1 files changed, 17 insertions, 11 deletions
diff --git a/tools/gfx/d3d12/d3d12-command-encoder.cpp b/tools/gfx/d3d12/d3d12-command-encoder.cpp
index a9245bebc..4c99dd5a8 100644
--- a/tools/gfx/d3d12/d3d12-command-encoder.cpp
+++ b/tools/gfx/d3d12/d3d12-command-encoder.cpp
@@ -1383,17 +1383,23 @@ void RayTracingCommandEncoderImpl::dispatchRays(
rayGenShaderIndex * kRayGenRecordSize;
dispatchDesc.RayGenerationShaderRecord.SizeInBytes = D3D12_SHADER_IDENTIFIER_SIZE_IN_BYTES;
- dispatchDesc.MissShaderTable.StartAddress =
- shaderTableAddr + shaderTableImpl->m_missTableOffset;
- dispatchDesc.MissShaderTable.SizeInBytes =
- shaderTableImpl->m_missShaderCount * D3D12_SHADER_IDENTIFIER_SIZE_IN_BYTES;
- dispatchDesc.MissShaderTable.StrideInBytes = D3D12_SHADER_IDENTIFIER_SIZE_IN_BYTES;
-
- dispatchDesc.HitGroupTable.StartAddress =
- shaderTableAddr + shaderTableImpl->m_hitGroupTableOffset;
- dispatchDesc.HitGroupTable.SizeInBytes =
- shaderTableImpl->m_hitGroupCount * D3D12_SHADER_IDENTIFIER_SIZE_IN_BYTES;
- dispatchDesc.HitGroupTable.StrideInBytes = D3D12_SHADER_IDENTIFIER_SIZE_IN_BYTES;
+ if (shaderTableImpl->m_missShaderCount > 0)
+ {
+ dispatchDesc.MissShaderTable.StartAddress =
+ shaderTableAddr + shaderTableImpl->m_missTableOffset;
+ dispatchDesc.MissShaderTable.SizeInBytes =
+ shaderTableImpl->m_missShaderCount * D3D12_SHADER_IDENTIFIER_SIZE_IN_BYTES;
+ dispatchDesc.MissShaderTable.StrideInBytes = D3D12_SHADER_IDENTIFIER_SIZE_IN_BYTES;
+ }
+
+ if (shaderTableImpl->m_hitGroupCount > 0)
+ {
+ dispatchDesc.HitGroupTable.StartAddress =
+ shaderTableAddr + shaderTableImpl->m_hitGroupTableOffset;
+ dispatchDesc.HitGroupTable.SizeInBytes =
+ shaderTableImpl->m_hitGroupCount * D3D12_SHADER_IDENTIFIER_SIZE_IN_BYTES;
+ dispatchDesc.HitGroupTable.StrideInBytes = D3D12_SHADER_IDENTIFIER_SIZE_IN_BYTES;
+ }
dispatchDesc.Width = (UINT)width;
dispatchDesc.Height = (UINT)height;