From fa3287fb6ec38127bad8fe948fbc190e7a3d54b2 Mon Sep 17 00:00:00 2001 From: Simon Kallweit <64953474+skallweitNV@users.noreply.github.com> Date: Thu, 17 Oct 2024 23:59:10 +0200 Subject: update slang-rhi (#5258) * update slang-rhi * update render-test to use new slang-rhi apis --------- Co-authored-by: Yong He --- tools/render-test/render-test-main.cpp | 31 +++++++++++++------------------ tools/render-test/shader-input-layout.cpp | 11 ++++------- tools/render-test/shader-input-layout.h | 5 ++--- 3 files changed, 19 insertions(+), 28 deletions(-) (limited to 'tools/render-test') diff --git a/tools/render-test/render-test-main.cpp b/tools/render-test/render-test-main.cpp index fe3452a9b..218125748 100644 --- a/tools/render-test/render-test-main.cpp +++ b/tools/render-test/render-test-main.cpp @@ -753,7 +753,7 @@ void RenderTestApp::_initializeAccelerationStructure() passEncoder->buildAccelerationStructure(buildDesc, draftAS, nullptr, scratchBuffer, 1, &compactedSizeQueryDesc); passEncoder->end(); commandBuffer->close(); - m_queue->executeCommandBuffer(commandBuffer); + m_queue->submit(commandBuffer); m_queue->waitOnHost(); uint64_t compactedSize = 0; @@ -768,7 +768,7 @@ void RenderTestApp::_initializeAccelerationStructure() m_bottomLevelAccelerationStructure, draftAS, AccelerationStructureCopyMode::Compact); passEncoder->end(); commandBuffer->close(); - m_queue->executeCommandBuffer(commandBuffer); + m_queue->submit(commandBuffer); m_queue->waitOnHost(); } @@ -835,7 +835,7 @@ void RenderTestApp::_initializeAccelerationStructure() passEncoder->buildAccelerationStructure(buildDesc, m_topLevelAccelerationStructure, nullptr, scratchBuffer, 0, nullptr); passEncoder->end(); commandBuffer->close(); - m_queue->executeCommandBuffer(commandBuffer); + m_queue->submit(commandBuffer); m_queue->waitOnHost(); } } @@ -982,7 +982,7 @@ Result RenderTestApp::update() commandBuffer->close(); m_startTicks = Process::getClockTick(); - m_queue->executeCommandBuffer(commandBuffer); + m_queue->submit(commandBuffer); m_queue->waitOnHost(); // 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 } } -#ifdef _DEBUG - rhiEnableDebugLayer(); -#endif StdWritersDebugCallback debugCallback; debugCallback.writers = stdWriters; - rhiSetDebugCallback(&debugCallback); - struct ResetDebugCallbackRAII - { - ~ResetDebugCallbackRAII() - { - rhiSetDebugCallback(nullptr); - } - } resetDebugCallbackRAII; // Use the profile name set on options if set input.profile = options.profileName.getLength() ? options.profileName : input.profile; StringBuilder rendererName; auto info = - rendererName << "[" << rhiGetDeviceTypeName(options.deviceType) << "] "; + rendererName << "[" << getRHI()->getDeviceTypeName(options.deviceType) << "] "; if (options.onlyStartup) { @@ -1310,9 +1299,15 @@ static SlangResult _innerMain(Slang::StdWriters* stdWriters, SlangSession* sessi Slang::ComPtr device; { - IDevice::Desc desc = {}; + DeviceDesc desc = {}; desc.deviceType = options.deviceType; +#if _DEBUG + desc.enableValidation = true; + desc.enableBackendValidation = true; + desc.debugCallback = &debugCallback; +#endif + desc.slang.lineDirectiveMode = SLANG_LINE_DIRECTIVE_MODE_NONE; if (options.generateSPIRVDirectly) desc.slang.targetFlags = SLANG_TARGET_FLAG_GENERATE_SPIRV_DIRECTLY; @@ -1343,7 +1338,7 @@ static SlangResult _innerMain(Slang::StdWriters* stdWriters, SlangSession* sessi desc.slang.slangGlobalSession = session; desc.slang.targetProfile = options.profileName.getBuffer(); { - SlangResult res = rhiCreateDevice(&desc, device.writeRef()); + SlangResult res = getRHI()->createDevice(desc, device.writeRef()); if (SLANG_FAILED(res)) { // We need to be careful here about SLANG_E_NOT_AVAILABLE. This return value means that the renderer couldn't diff --git a/tools/render-test/shader-input-layout.cpp b/tools/render-test/shader-input-layout.cpp index 61951db50..07711d712 100644 --- a/tools/render-test/shader-input-layout.cpp +++ b/tools/render-test/shader-input-layout.cpp @@ -21,8 +21,7 @@ namespace renderer_test { for (int i = 0; i < int(Format::_Count); ++i) { - FormatInfo info; - rhiGetFormatInfo(Format(i), &info); + const FormatInfo& info = getFormatInfo(Format(i)); if (slice == info.name) { return Format(i); @@ -1161,7 +1160,7 @@ namespace renderer_test // T for type to return, F for function pointer to operate on uint8->T template - void generateTextureDataWithTargetTStorage(TextureData& output, const InputTextureDesc& desc, rhi::FormatInfo& formatInfo, F loadUint8ToT) + void generateTextureDataWithTargetTStorage(TextureData& output, const InputTextureDesc& desc, const rhi::FormatInfo& formatInfo, F loadUint8ToT) { // the following function assumes input of 0 or 1 since our testing framework only tests with 0 or 1 TextureData work; @@ -1235,8 +1234,7 @@ namespace renderer_test } void generateTextureData(TextureData& output, const InputTextureDesc& desc) { - rhi::FormatInfo formatInfo; - rhiGetFormatInfo(desc.format, &formatInfo); + const FormatInfo& formatInfo = getFormatInfo(desc.format); switch (desc.format) { @@ -1354,8 +1352,7 @@ namespace renderer_test kFloat, }; SimpleScalarType type; - rhi::FormatInfo formatInfo; - rhiGetFormatInfo(inputDesc.format, &formatInfo); + const rhi::FormatInfo& formatInfo = getFormatInfo(inputDesc.format); switch (formatInfo.channelType) { case SLANG_SCALAR_TYPE_UINT64: diff --git a/tools/render-test/shader-input-layout.h b/tools/render-test/shader-input-layout.h index 59aea2562..9d4b139c8 100644 --- a/tools/render-test/shader-input-layout.h +++ b/tools/render-test/shader-input-layout.h @@ -127,9 +127,8 @@ struct TextureData { clearSlices(); - FormatInfo formatSizeInfo; - rhiGetFormatInfo(format, &formatSizeInfo); - m_formatSize = uint8_t(formatSizeInfo.blockSizeInBytes / formatSizeInfo.pixelsPerBlock); + const FormatInfo& formatInfo = getFormatInfo(format); + m_formatSize = uint8_t(formatInfo.blockSizeInBytes / formatInfo.pixelsPerBlock); m_format = format; } -- cgit v1.2.3