Skip to content

Commit f5ce3a0

Browse files
authored
Merge branch 'master' into fix/SLANG_ENABLE_TEST_cannot_be_disabled_without_disabling_SLANG_ENABLE_GFX
2 parents 265f350 + 0101e5a commit f5ce3a0

File tree

1 file changed

+50
-1
lines changed

1 file changed

+50
-1
lines changed

tools/render-test/render-test-main.cpp

+50-1
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ class RenderTestApp
131131
ComPtr<IBuffer> m_vertexBuffer;
132132
ComPtr<IShaderProgram> m_shaderProgram;
133133
ComPtr<IPipeline> m_pipeline;
134+
ComPtr<IShaderTable> m_shaderTable;
134135
ComPtr<ITexture> m_depthBuffer;
135136
ComPtr<ITextureView> m_depthBufferView;
136137
ComPtr<ITexture> m_colorBuffer;
@@ -648,6 +649,7 @@ SlangResult RenderTestApp::initialize(
648649
m_pipeline = device->createRenderPipeline(desc);
649650
}
650651
break;
652+
651653
case Options::ShaderProgramType::GraphicsMeshCompute:
652654
case Options::ShaderProgramType::GraphicsTaskMeshCompute:
653655
{
@@ -660,6 +662,33 @@ SlangResult RenderTestApp::initialize(
660662
desc.depthStencil.format = Format::D32_FLOAT;
661663
m_pipeline = device->createRenderPipeline(desc);
662664
}
665+
break;
666+
667+
case Options::ShaderProgramType::RayTracing:
668+
{
669+
RayTracingPipelineDesc desc;
670+
desc.program = m_shaderProgram;
671+
672+
m_pipeline = device->createRayTracingPipeline(desc);
673+
674+
const char* raygenNames[] = {"raygenMain"};
675+
676+
// We don't define a miss shader for this test. OptiX allows
677+
// passing nullptr to indicate no miss shader, but something in
678+
// slang-rhi assumes that the miss shader always has a name. To
679+
// work around that, use a dummy name.
680+
const char* missNames[] = {"missNull"};
681+
682+
ShaderTableDesc shaderTableDesc = {};
683+
shaderTableDesc.program = m_shaderProgram;
684+
shaderTableDesc.rayGenShaderCount = 1;
685+
shaderTableDesc.rayGenShaderEntryPointNames = raygenNames;
686+
shaderTableDesc.missShaderCount = 1;
687+
shaderTableDesc.missShaderEntryPointNames = missNames;
688+
SLANG_RETURN_ON_FAIL(
689+
device->createShaderTable(shaderTableDesc, m_shaderTable.writeRef()));
690+
}
691+
break;
663692
}
664693
}
665694
// If success must have a pipeline state
@@ -972,6 +1001,25 @@ Result RenderTestApp::update()
9721001
m_options.computeDispatchSize[2]);
9731002
passEncoder->end();
9741003
}
1004+
else if (m_options.shaderType == Options::ShaderProgramType::RayTracing)
1005+
{
1006+
auto rootObject = m_device->createRootShaderObject(m_pipeline);
1007+
applyBinding(rootObject);
1008+
rootObject->finalize();
1009+
1010+
auto passEncoder = encoder->beginRayTracingPass();
1011+
RayTracingState state;
1012+
state.pipeline = static_cast<IRayTracingPipeline*>(m_pipeline.get());
1013+
state.rootObject = rootObject;
1014+
state.shaderTable = m_shaderTable;
1015+
passEncoder->setRayTracingState(state);
1016+
passEncoder->dispatchRays(
1017+
0,
1018+
m_options.computeDispatchSize[0],
1019+
m_options.computeDispatchSize[1],
1020+
m_options.computeDispatchSize[2]);
1021+
passEncoder->end();
1022+
}
9751023
else
9761024
{
9771025
auto rootObject = m_device->createRootShaderObject(m_pipeline);
@@ -1072,7 +1120,8 @@ Result RenderTestApp::update()
10721120
if (m_options.shaderType == Options::ShaderProgramType::Compute ||
10731121
m_options.shaderType == Options::ShaderProgramType::GraphicsCompute ||
10741122
m_options.shaderType == Options::ShaderProgramType::GraphicsMeshCompute ||
1075-
m_options.shaderType == Options::ShaderProgramType::GraphicsTaskMeshCompute)
1123+
m_options.shaderType == Options::ShaderProgramType::GraphicsTaskMeshCompute ||
1124+
m_options.shaderType == Options::ShaderProgramType::RayTracing)
10761125
{
10771126
SLANG_RETURN_ON_FAIL(writeBindingOutput(m_options.outputPath));
10781127
}

0 commit comments

Comments
 (0)