Skip to content

Commit fa3287f

Browse files
update slang-rhi (shader-slang#5258)
* update slang-rhi * update render-test to use new slang-rhi apis --------- Co-authored-by: Yong He <yonghe@outlook.com>
1 parent ee11a45 commit fa3287f

File tree

4 files changed

+20
-29
lines changed

4 files changed

+20
-29
lines changed

external/slang-rhi

Submodule slang-rhi updated 214 files

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

+13-18
Original file line numberDiff line numberDiff line change
@@ -753,7 +753,7 @@ void RenderTestApp::_initializeAccelerationStructure()
753753
passEncoder->buildAccelerationStructure(buildDesc, draftAS, nullptr, scratchBuffer, 1, &compactedSizeQueryDesc);
754754
passEncoder->end();
755755
commandBuffer->close();
756-
m_queue->executeCommandBuffer(commandBuffer);
756+
m_queue->submit(commandBuffer);
757757
m_queue->waitOnHost();
758758

759759
uint64_t compactedSize = 0;
@@ -768,7 +768,7 @@ void RenderTestApp::_initializeAccelerationStructure()
768768
m_bottomLevelAccelerationStructure, draftAS, AccelerationStructureCopyMode::Compact);
769769
passEncoder->end();
770770
commandBuffer->close();
771-
m_queue->executeCommandBuffer(commandBuffer);
771+
m_queue->submit(commandBuffer);
772772
m_queue->waitOnHost();
773773
}
774774

@@ -835,7 +835,7 @@ void RenderTestApp::_initializeAccelerationStructure()
835835
passEncoder->buildAccelerationStructure(buildDesc, m_topLevelAccelerationStructure, nullptr, scratchBuffer, 0, nullptr);
836836
passEncoder->end();
837837
commandBuffer->close();
838-
m_queue->executeCommandBuffer(commandBuffer);
838+
m_queue->submit(commandBuffer);
839839
m_queue->waitOnHost();
840840
}
841841
}
@@ -982,7 +982,7 @@ Result RenderTestApp::update()
982982
commandBuffer->close();
983983

984984
m_startTicks = Process::getClockTick();
985-
m_queue->executeCommandBuffer(commandBuffer);
985+
m_queue->submit(commandBuffer);
986986
m_queue->waitOnHost();
987987

988988
// If we are in a mode where output is requested, we need to snapshot the back buffer here
@@ -1244,26 +1244,15 @@ static SlangResult _innerMain(Slang::StdWriters* stdWriters, SlangSession* sessi
12441244
}
12451245
}
12461246

1247-
#ifdef _DEBUG
1248-
rhiEnableDebugLayer();
1249-
#endif
12501247
StdWritersDebugCallback debugCallback;
12511248
debugCallback.writers = stdWriters;
1252-
rhiSetDebugCallback(&debugCallback);
1253-
struct ResetDebugCallbackRAII
1254-
{
1255-
~ResetDebugCallbackRAII()
1256-
{
1257-
rhiSetDebugCallback(nullptr);
1258-
}
1259-
} resetDebugCallbackRAII;
12601249

12611250
// Use the profile name set on options if set
12621251
input.profile = options.profileName.getLength() ? options.profileName : input.profile;
12631252

12641253
StringBuilder rendererName;
12651254
auto info =
1266-
rendererName << "[" << rhiGetDeviceTypeName(options.deviceType) << "] ";
1255+
rendererName << "[" << getRHI()->getDeviceTypeName(options.deviceType) << "] ";
12671256

12681257
if (options.onlyStartup)
12691258
{
@@ -1310,9 +1299,15 @@ static SlangResult _innerMain(Slang::StdWriters* stdWriters, SlangSession* sessi
13101299

13111300
Slang::ComPtr<IDevice> device;
13121301
{
1313-
IDevice::Desc desc = {};
1302+
DeviceDesc desc = {};
13141303
desc.deviceType = options.deviceType;
13151304

1305+
#if _DEBUG
1306+
desc.enableValidation = true;
1307+
desc.enableBackendValidation = true;
1308+
desc.debugCallback = &debugCallback;
1309+
#endif
1310+
13161311
desc.slang.lineDirectiveMode = SLANG_LINE_DIRECTIVE_MODE_NONE;
13171312
if (options.generateSPIRVDirectly)
13181313
desc.slang.targetFlags = SLANG_TARGET_FLAG_GENERATE_SPIRV_DIRECTLY;
@@ -1343,7 +1338,7 @@ static SlangResult _innerMain(Slang::StdWriters* stdWriters, SlangSession* sessi
13431338
desc.slang.slangGlobalSession = session;
13441339
desc.slang.targetProfile = options.profileName.getBuffer();
13451340
{
1346-
SlangResult res = rhiCreateDevice(&desc, device.writeRef());
1341+
SlangResult res = getRHI()->createDevice(desc, device.writeRef());
13471342
if (SLANG_FAILED(res))
13481343
{
13491344
// We need to be careful here about SLANG_E_NOT_AVAILABLE. This return value means that the renderer couldn't

tools/render-test/shader-input-layout.cpp

+4-7
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ namespace renderer_test
2121
{
2222
for (int i = 0; i < int(Format::_Count); ++i)
2323
{
24-
FormatInfo info;
25-
rhiGetFormatInfo(Format(i), &info);
24+
const FormatInfo& info = getFormatInfo(Format(i));
2625
if (slice == info.name)
2726
{
2827
return Format(i);
@@ -1161,7 +1160,7 @@ namespace renderer_test
11611160

11621161
// T for type to return, F for function pointer to operate on uint8->T
11631162
template<typename T, typename F>
1164-
void generateTextureDataWithTargetTStorage(TextureData& output, const InputTextureDesc& desc, rhi::FormatInfo& formatInfo, F loadUint8ToT)
1163+
void generateTextureDataWithTargetTStorage(TextureData& output, const InputTextureDesc& desc, const rhi::FormatInfo& formatInfo, F loadUint8ToT)
11651164
{
11661165
// the following function assumes input of 0 or 1 since our testing framework only tests with 0 or 1
11671166
TextureData work;
@@ -1235,8 +1234,7 @@ namespace renderer_test
12351234
}
12361235
void generateTextureData(TextureData& output, const InputTextureDesc& desc)
12371236
{
1238-
rhi::FormatInfo formatInfo;
1239-
rhiGetFormatInfo(desc.format, &formatInfo);
1237+
const FormatInfo& formatInfo = getFormatInfo(desc.format);
12401238

12411239
switch (desc.format)
12421240
{
@@ -1354,8 +1352,7 @@ namespace renderer_test
13541352
kFloat,
13551353
};
13561354
SimpleScalarType type;
1357-
rhi::FormatInfo formatInfo;
1358-
rhiGetFormatInfo(inputDesc.format, &formatInfo);
1355+
const rhi::FormatInfo& formatInfo = getFormatInfo(inputDesc.format);
13591356
switch (formatInfo.channelType)
13601357
{
13611358
case SLANG_SCALAR_TYPE_UINT64:

tools/render-test/shader-input-layout.h

+2-3
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,8 @@ struct TextureData
127127
{
128128
clearSlices();
129129

130-
FormatInfo formatSizeInfo;
131-
rhiGetFormatInfo(format, &formatSizeInfo);
132-
m_formatSize = uint8_t(formatSizeInfo.blockSizeInBytes / formatSizeInfo.pixelsPerBlock);
130+
const FormatInfo& formatInfo = getFormatInfo(format);
131+
m_formatSize = uint8_t(formatInfo.blockSizeInBytes / formatInfo.pixelsPerBlock);
133132
m_format = format;
134133
}
135134

0 commit comments

Comments
 (0)