@@ -131,6 +131,7 @@ class RenderTestApp
131
131
ComPtr<IBuffer> m_vertexBuffer;
132
132
ComPtr<IShaderProgram> m_shaderProgram;
133
133
ComPtr<IPipeline> m_pipeline;
134
+ ComPtr<IShaderTable> m_shaderTable;
134
135
ComPtr<ITexture> m_depthBuffer;
135
136
ComPtr<ITextureView> m_depthBufferView;
136
137
ComPtr<ITexture> m_colorBuffer;
@@ -648,6 +649,7 @@ SlangResult RenderTestApp::initialize(
648
649
m_pipeline = device->createRenderPipeline (desc);
649
650
}
650
651
break ;
652
+
651
653
case Options::ShaderProgramType::GraphicsMeshCompute:
652
654
case Options::ShaderProgramType::GraphicsTaskMeshCompute:
653
655
{
@@ -660,6 +662,33 @@ SlangResult RenderTestApp::initialize(
660
662
desc.depthStencil .format = Format::D32_FLOAT;
661
663
m_pipeline = device->createRenderPipeline (desc);
662
664
}
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 ;
663
692
}
664
693
}
665
694
// If success must have a pipeline state
@@ -972,6 +1001,25 @@ Result RenderTestApp::update()
972
1001
m_options.computeDispatchSize [2 ]);
973
1002
passEncoder->end ();
974
1003
}
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
+ }
975
1023
else
976
1024
{
977
1025
auto rootObject = m_device->createRootShaderObject (m_pipeline);
@@ -1072,7 +1120,8 @@ Result RenderTestApp::update()
1072
1120
if (m_options.shaderType == Options::ShaderProgramType::Compute ||
1073
1121
m_options.shaderType == Options::ShaderProgramType::GraphicsCompute ||
1074
1122
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)
1076
1125
{
1077
1126
SLANG_RETURN_ON_FAIL (writeBindingOutput (m_options.outputPath ));
1078
1127
}
0 commit comments