Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update slang-rhi (shader object refactor) #6251

Merged
merged 6 commits into from
Feb 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,21 @@
"configurePreset": "default",
"configuration": "RelWithDebInfo"
},
{
"name": "vs2022-debug",
"configurePreset": "vs2022",
"configuration": "Debug"
},
{
"name": "vs2022-release",
"configurePreset": "vs2022",
"configuration": "Release"
},
{
"name": "vs2022-releaseWithDebugInfo",
"configurePreset": "vs2022",
"configuration": "RelWithDebInfo"
},
{
"name": "emscripten",
"configurePreset": "emscripten",
Expand Down
2 changes: 1 addition & 1 deletion external/slang-rhi
Submodule slang-rhi updated 273 files
2 changes: 0 additions & 2 deletions tests/bugs/ray-query-in-generic.slang
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ struct Ray
float3 eval(float t) { return origin + t * dir; }
};

RaytracingAccelerationStructure sceneBVH;

uint getCommittedStatus<let Flags : int>(RayQuery<Flags> q)
{
return q.CommittedStatus();
Expand Down
1 change: 1 addition & 0 deletions tests/compute/byte-address-buffer-aligned.slang
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

// Confirm compilation of `(RW)ByteAddressBuffer` with aligned load / stores to wider data types.

//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=buffer0
[vk::binding(2, 3)] RWByteAddressBuffer buffer0;

[shader("compute")]
Expand Down
1 change: 1 addition & 0 deletions tests/compute/byte-address-buffer-array.slang
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

// Confirm compilation of `(RW)ByteAddressBuffer` with aligned load / stores to wider data types.

//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=buffer
[vk::binding(2, 3)] RWByteAddressBuffer buffer;
struct Block {
float4 val[2];
Expand Down
4 changes: 2 additions & 2 deletions tools/render-test/options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -249,9 +249,9 @@ static rhi::DeviceType _toRenderType(Slang::RenderApiType apiType)
{
SLANG_RETURN_ON_FAIL(reader.expectArg(outOptions.entryPointName));
}
else if (argValue == "-enable-backend-validation")
else if (argValue == "-enable-debug-layers")
{
outOptions.enableBackendValidation = true;
outOptions.enableDebugLayers = true;
}
else if (argValue == "-dx12-experimental")
{
Expand Down
2 changes: 1 addition & 1 deletion tools/render-test/options.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ struct Options

bool generateSPIRVDirectly = true;

bool enableBackendValidation = false;
bool enableDebugLayers = false;

bool dx12Experimental = false;

Expand Down
53 changes: 20 additions & 33 deletions tools/render-test/render-test-main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ struct AssignValsFromLayoutContext
if (field.name.getLength() == 0)
{
// If no name was given, assume by-indexing matching is requested
auto fieldCursor = dstCursor.getElement((GfxIndex)fieldIndex);
auto fieldCursor = dstCursor.getElement((uint32_t)fieldIndex);
if (!fieldCursor.isValid())
{
StdWriters::getError().print(
Expand Down Expand Up @@ -638,7 +638,7 @@ SlangResult RenderTestApp::initialize(
SLANG_RETURN_ON_FAIL(
device->createBuffer(vertexBufferDesc, kVertexData, m_vertexBuffer.writeRef()));

ColorTargetState colorTarget;
ColorTargetDesc colorTarget;
colorTarget.format = Format::R8G8B8A8_UNORM;
RenderPipelineDesc desc;
desc.program = m_shaderProgram;
Expand All @@ -653,7 +653,7 @@ SlangResult RenderTestApp::initialize(
case Options::ShaderProgramType::GraphicsMeshCompute:
case Options::ShaderProgramType::GraphicsTaskMeshCompute:
{
ColorTargetState colorTarget;
ColorTargetDesc colorTarget;
colorTarget.format = Format::R8G8B8A8_UNORM;
RenderPipelineDesc desc;
desc.program = m_shaderProgram;
Expand Down Expand Up @@ -986,15 +986,10 @@ Result RenderTestApp::update()
auto encoder = m_queue->createCommandEncoder();
if (m_options.shaderType == Options::ShaderProgramType::Compute)
{
auto rootObject = m_device->createRootShaderObject(m_pipeline);
applyBinding(rootObject);
rootObject->finalize();

auto passEncoder = encoder->beginComputePass();
ComputeState state;
state.pipeline = static_cast<IComputePipeline*>(m_pipeline.get());
state.rootObject = rootObject;
passEncoder->setComputeState(state);
auto rootObject =
passEncoder->bindPipeline(static_cast<IComputePipeline*>(m_pipeline.get()));
applyBinding(rootObject);
passEncoder->dispatchCompute(
m_options.computeDispatchSize[0],
m_options.computeDispatchSize[1],
Expand All @@ -1003,16 +998,11 @@ Result RenderTestApp::update()
}
else if (m_options.shaderType == Options::ShaderProgramType::RayTracing)
{
auto rootObject = m_device->createRootShaderObject(m_pipeline);
applyBinding(rootObject);
rootObject->finalize();

auto passEncoder = encoder->beginRayTracingPass();
RayTracingState state;
state.pipeline = static_cast<IRayTracingPipeline*>(m_pipeline.get());
state.rootObject = rootObject;
state.shaderTable = m_shaderTable;
passEncoder->setRayTracingState(state);
auto rootObject = passEncoder->bindPipeline(
static_cast<IRayTracingPipeline*>(m_pipeline.get()),
m_shaderTable);
applyBinding(rootObject);
passEncoder->dispatchRays(
0,
m_options.computeDispatchSize[0],
Expand All @@ -1022,11 +1012,6 @@ Result RenderTestApp::update()
}
else
{
auto rootObject = m_device->createRootShaderObject(m_pipeline);
applyBinding(rootObject);
setProjectionMatrix(rootObject);
rootObject->finalize();

RenderPassColorAttachment colorAttachment = {};
colorAttachment.view = m_colorBufferView;
colorAttachment.loadOp = LoadOp::Clear;
Expand All @@ -1041,13 +1026,15 @@ Result RenderTestApp::update()
renderPass.depthStencilAttachment = &depthStencilAttachment;

auto passEncoder = encoder->beginRenderPass(renderPass);
auto rootObject =
passEncoder->bindPipeline(static_cast<IRenderPipeline*>(m_pipeline.get()));
applyBinding(rootObject);
setProjectionMatrix(rootObject);

RenderState state;
state.pipeline = static_cast<IRenderPipeline*>(m_pipeline.get());
state.rootObject = rootObject;
state.viewports[0] = Viewport((float)gWindowWidth, (float)gWindowHeight);
state.viewports[0] = Viewport::fromSize(gWindowWidth, gWindowHeight);
state.viewportCount = 1;
state.scissorRects[0] = ScissorRect(gWindowWidth, gWindowHeight);
state.scissorRects[0] = ScissorRect::fromSize(gWindowWidth, gWindowHeight);
state.scissorRectCount = 1;

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

if (options.enableBackendValidation)
desc.enableBackendValidation = true;

desc.slang.lineDirectiveMode = SLANG_LINE_DIRECTIVE_MODE_NONE;
if (options.generateSPIRVDirectly)
desc.slang.targetFlags = SLANG_TARGET_FLAG_GENERATE_SPIRV_DIRECTLY;
Expand Down Expand Up @@ -1460,7 +1444,10 @@ static SlangResult _innerMain(
desc.slang.slangGlobalSession = session;
desc.slang.targetProfile = options.profileName.getBuffer();
{
getRHI()->enableDebugLayers();
if (options.enableDebugLayers)
{
getRHI()->enableDebugLayers();
}
SlangResult res = getRHI()->createDevice(desc, device.writeRef());
if (SLANG_FAILED(res))
{
Expand Down
2 changes: 1 addition & 1 deletion tools/slang-test/slang-test-main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3528,7 +3528,7 @@ TestResult runComputeComparisonImpl(
// This is due to the limitation that Slang RPC implementation expects only
// one time communication.
if (input.spawnType != SpawnType::UseTestServer)
cmdLine.addArg("-enable-backend-validation");
cmdLine.addArg("-enable-debug-layers");
#endif

if (context->isExecuting())
Expand Down
Loading