Skip to content

Commit fb7f922

Browse files
committed
update slang-rhi API usage
1 parent dda548f commit fb7f922

File tree

4 files changed

+24
-37
lines changed

4 files changed

+24
-37
lines changed

tools/render-test/options.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -249,9 +249,9 @@ static rhi::DeviceType _toRenderType(Slang::RenderApiType apiType)
249249
{
250250
SLANG_RETURN_ON_FAIL(reader.expectArg(outOptions.entryPointName));
251251
}
252-
else if (argValue == "-enable-backend-validation")
252+
else if (argValue == "-enable-debug-layers")
253253
{
254-
outOptions.enableBackendValidation = true;
254+
outOptions.enableDebugLayers = true;
255255
}
256256
else if (argValue == "-dx12-experimental")
257257
{

tools/render-test/options.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ struct Options
8787

8888
bool generateSPIRVDirectly = true;
8989

90-
bool enableBackendValidation = false;
90+
bool enableDebugLayers = false;
9191

9292
bool dx12Experimental = false;
9393

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

+20-33
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ struct AssignValsFromLayoutContext
355355
if (field.name.getLength() == 0)
356356
{
357357
// If no name was given, assume by-indexing matching is requested
358-
auto fieldCursor = dstCursor.getElement((GfxIndex)fieldIndex);
358+
auto fieldCursor = dstCursor.getElement((uint32_t)fieldIndex);
359359
if (!fieldCursor.isValid())
360360
{
361361
StdWriters::getError().print(
@@ -638,7 +638,7 @@ SlangResult RenderTestApp::initialize(
638638
SLANG_RETURN_ON_FAIL(
639639
device->createBuffer(vertexBufferDesc, kVertexData, m_vertexBuffer.writeRef()));
640640

641-
ColorTargetState colorTarget;
641+
ColorTargetDesc colorTarget;
642642
colorTarget.format = Format::R8G8B8A8_UNORM;
643643
RenderPipelineDesc desc;
644644
desc.program = m_shaderProgram;
@@ -653,7 +653,7 @@ SlangResult RenderTestApp::initialize(
653653
case Options::ShaderProgramType::GraphicsMeshCompute:
654654
case Options::ShaderProgramType::GraphicsTaskMeshCompute:
655655
{
656-
ColorTargetState colorTarget;
656+
ColorTargetDesc colorTarget;
657657
colorTarget.format = Format::R8G8B8A8_UNORM;
658658
RenderPipelineDesc desc;
659659
desc.program = m_shaderProgram;
@@ -986,15 +986,10 @@ Result RenderTestApp::update()
986986
auto encoder = m_queue->createCommandEncoder();
987987
if (m_options.shaderType == Options::ShaderProgramType::Compute)
988988
{
989-
auto rootObject = m_device->createRootShaderObject(m_pipeline);
990-
applyBinding(rootObject);
991-
rootObject->finalize();
992-
993989
auto passEncoder = encoder->beginComputePass();
994-
ComputeState state;
995-
state.pipeline = static_cast<IComputePipeline*>(m_pipeline.get());
996-
state.rootObject = rootObject;
997-
passEncoder->setComputeState(state);
990+
auto rootObject =
991+
passEncoder->bindPipeline(static_cast<IComputePipeline*>(m_pipeline.get()));
992+
applyBinding(rootObject);
998993
passEncoder->dispatchCompute(
999994
m_options.computeDispatchSize[0],
1000995
m_options.computeDispatchSize[1],
@@ -1003,16 +998,11 @@ Result RenderTestApp::update()
1003998
}
1004999
else if (m_options.shaderType == Options::ShaderProgramType::RayTracing)
10051000
{
1006-
auto rootObject = m_device->createRootShaderObject(m_pipeline);
1007-
applyBinding(rootObject);
1008-
rootObject->finalize();
1009-
10101001
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);
1002+
auto rootObject = passEncoder->bindPipeline(
1003+
static_cast<IRayTracingPipeline*>(m_pipeline.get()),
1004+
m_shaderTable);
1005+
applyBinding(rootObject);
10161006
passEncoder->dispatchRays(
10171007
0,
10181008
m_options.computeDispatchSize[0],
@@ -1022,11 +1012,6 @@ Result RenderTestApp::update()
10221012
}
10231013
else
10241014
{
1025-
auto rootObject = m_device->createRootShaderObject(m_pipeline);
1026-
applyBinding(rootObject);
1027-
setProjectionMatrix(rootObject);
1028-
rootObject->finalize();
1029-
10301015
RenderPassColorAttachment colorAttachment = {};
10311016
colorAttachment.view = m_colorBufferView;
10321017
colorAttachment.loadOp = LoadOp::Clear;
@@ -1041,13 +1026,15 @@ Result RenderTestApp::update()
10411026
renderPass.depthStencilAttachment = &depthStencilAttachment;
10421027

10431028
auto passEncoder = encoder->beginRenderPass(renderPass);
1029+
auto rootObject =
1030+
passEncoder->bindPipeline(static_cast<IRenderPipeline*>(m_pipeline.get()));
1031+
applyBinding(rootObject);
1032+
setProjectionMatrix(rootObject);
10441033

10451034
RenderState state;
1046-
state.pipeline = static_cast<IRenderPipeline*>(m_pipeline.get());
1047-
state.rootObject = rootObject;
1048-
state.viewports[0] = Viewport((float)gWindowWidth, (float)gWindowHeight);
1035+
state.viewports[0] = Viewport::fromSize(gWindowWidth, gWindowHeight);
10491036
state.viewportCount = 1;
1050-
state.scissorRects[0] = ScissorRect(gWindowWidth, gWindowHeight);
1037+
state.scissorRects[0] = ScissorRect::fromSize(gWindowWidth, gWindowHeight);
10511038
state.scissorRectCount = 1;
10521039

10531040
if (m_options.shaderType == Options::ShaderProgramType::GraphicsMeshCompute ||
@@ -1413,9 +1400,6 @@ static SlangResult _innerMain(
14131400
desc.debugCallback = &debugCallback;
14141401
#endif
14151402

1416-
if (options.enableBackendValidation)
1417-
desc.enableBackendValidation = true;
1418-
14191403
desc.slang.lineDirectiveMode = SLANG_LINE_DIRECTIVE_MODE_NONE;
14201404
if (options.generateSPIRVDirectly)
14211405
desc.slang.targetFlags = SLANG_TARGET_FLAG_GENERATE_SPIRV_DIRECTLY;
@@ -1460,7 +1444,10 @@ static SlangResult _innerMain(
14601444
desc.slang.slangGlobalSession = session;
14611445
desc.slang.targetProfile = options.profileName.getBuffer();
14621446
{
1463-
getRHI()->enableDebugLayers();
1447+
if (options.enableDebugLayers)
1448+
{
1449+
getRHI()->enableDebugLayers();
1450+
}
14641451
SlangResult res = getRHI()->createDevice(desc, device.writeRef());
14651452
if (SLANG_FAILED(res))
14661453
{

tools/slang-test/slang-test-main.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -3524,7 +3524,7 @@ TestResult runComputeComparisonImpl(
35243524
// This is due to the limitation that Slang RPC implementation expects only
35253525
// one time communication.
35263526
if (input.spawnType != SpawnType::UseTestServer)
3527-
cmdLine.addArg("-enable-backend-validation");
3527+
cmdLine.addArg("-enable-debug-layers");
35283528
#endif
35293529

35303530
if (context->isExecuting())

0 commit comments

Comments
 (0)