Skip to content

Slang examples should take command-line argument to give an option for rendering API #7829

@jkwak-work

Description

@jkwak-work

Problem Description
There are a few examples in Slang repo including "triangle".
Currently most, if not all, examples share the same implementation for how the command-line arguments are handled.

It only takes "--test-mode" at the moment but we should add more options starting with a help message, "-h" and "-help".

We can also provide an option to select which rendering API to use such as d3d11, d3d12, vulkan, and metal.
Because all of the examples now use slang-rhi, it is easy to switch the rendering API.

Preferred Solution
It will be good to add the following command-line argument with the actual implementation.

Usage: triangle [options]

Options:
  -h, --help                     Show this help message
  -api (d3d11|d3d12|vulkan|metal) Use a given rendering API (Default: XXX)
  -test-mode                  Print the hash value of the rendered scene and exit

I am not sure which one is used as a default API currently.
We will need to investigate how the default is handled and print it in the help message.

With the choice of the rendering API, we can call the following function with an explicit value for "deviceType",

Slang::Result WindowedAppBase::initializeBase(
    const char* title,
    int width,
    int height,
    DeviceType deviceType)

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions