From 13dd01489efd89268d15751c5299e5783015bbcd Mon Sep 17 00:00:00 2001 From: Jay Kwak <82421531+jkwak-work@users.noreply.github.com> Date: Mon, 21 Jul 2025 19:15:07 -0700 Subject: Add command-line arguments to examples (#7835) * Add command-line arguments to triangle example - Add -h/--help flag to show usage information - Add -api flag to select rendering API (d3d11 < /dev/null | d3d12|vulkan|metal|cpu|cuda|webgpu) - Platform-specific API availability (D3D on Windows, Metal on macOS) - Output works for both console and WIN32 applications --- examples/example-base/example-base.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'examples/example-base/example-base.cpp') diff --git a/examples/example-base/example-base.cpp b/examples/example-base/example-base.cpp index 9759e9f42..95864b0af 100644 --- a/examples/example-base/example-base.cpp +++ b/examples/example-base/example-base.cpp @@ -1,5 +1,7 @@ #include "example-base.h" +#include "slang.h" + #include #ifdef _WIN32 @@ -23,6 +25,16 @@ Slang::Result WindowedAppBase::initializeBase( #ifdef _DEBUG deviceDesc.enableValidation = true; #endif + + slang::CompilerOptionEntry slangOptions[] = { + {slang::CompilerOptionName::EmitSpirvDirectly, {slang::CompilerOptionValueKind::Int, 1}}, + {slang::CompilerOptionName::DebugInformation, + {slang::CompilerOptionValueKind::Int, SLANG_DEBUG_INFO_LEVEL_STANDARD}}}; + deviceDesc.slang.compilerOptionEntries = slangOptions; + // When in test mode, don't include debug information to avoid altering hash values during + // testing Otherwise, include debug information for better debugging experience + deviceDesc.slang.compilerOptionEntryCount = isTestMode() ? 1 : 2; + gDevice = getRHI()->createDevice(deviceDesc); if (!gDevice) { -- cgit v1.2.3