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/test-base.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'examples/example-base/test-base.h') diff --git a/examples/example-base/test-base.h b/examples/example-base/test-base.h index 293c9f0d8..2705baa26 100644 --- a/examples/example-base/test-base.h +++ b/examples/example-base/test-base.h @@ -2,6 +2,7 @@ #include "core/slang-string-util.h" #include "slang-com-ptr.h" +#include "slang-rhi.h" #include "slang.h" using Slang::ComPtr; @@ -10,7 +11,7 @@ class TestBase { public: - // Parses command line options. This example only has one option for testing purpose. + // Parses command line options including help, API selection, and test mode. int parseOption(int argc, char** argv); void printEntrypointHashes( @@ -19,8 +20,14 @@ public: ComPtr& composedProgram); bool isTestMode() const { return m_isTestMode; } + bool shouldShowHelp() const { return m_showHelp; } + rhi::DeviceType getDeviceType() const { return m_deviceType; } + + void printUsage(const char* programName) const; private: bool m_isTestMode = false; + bool m_showHelp = false; + rhi::DeviceType m_deviceType = rhi::DeviceType::Default; uint64_t m_globalCounter = 0; }; -- cgit v1.2.3