summaryrefslogtreecommitdiffstats
path: root/examples/example-base/example-base.cpp
diff options
context:
space:
mode:
authorJay Kwak <82421531+jkwak-work@users.noreply.github.com>2025-07-21 19:15:07 -0700
committerGitHub <noreply@github.com>2025-07-21 19:15:07 -0700
commit13dd01489efd89268d15751c5299e5783015bbcd (patch)
tree13208541f8838a16e69d38645f7eebfc76326394 /examples/example-base/example-base.cpp
parenta77d22bf3bfc3098b01e4886c3a63fb751edc704 (diff)
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
Diffstat (limited to 'examples/example-base/example-base.cpp')
-rw-r--r--examples/example-base/example-base.cpp12
1 files changed, 12 insertions, 0 deletions
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 <chrono>
#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)
{