yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
ea600fa8f
master
Slang Test
Slang Test (slang-test) is a command-line tool that coordinates and runs the Slang test suite. It acts as a test runner hub, executing various types of tests and collecting their results.
Basic Usage
slang-test [options] [test-prefix...]
If no test prefix is specified, all tests will be run. Test prefixes can be used to filter which tests to run, and include the path with directories separated by '/'.
Example:
slang-test -bindir path/to/bin-category full tests/compute/array-param
Command Line Options
Core Options
-h, --help: Show help message-bindir <path>: Set directory for binaries (default: the path to the slang-test executable)-test-dir <path>: Set directory for test files (default: tests/)-v: Enable verbose output-verbose-paths: Use verbose paths in output-hide-ignored: Hide results from ignored tests
Test Selection and Categories
-category <name>: Only run tests in specified category-exclude <name>: Exclude tests in specified category
Available test categories:
full: All testsquick: Quick testssmoke: Basic smoke testsrender: Rendering-related testscompute: Compute shader testsvulkan: Vulkan-specific testscompatibility-issue: Tests for compatibility issues
A test may be in one or more categories. The categories are specified on top of a test, for example: //TEST(smoke,compute):COMPARE_COMPUTE:
API Control Options
-api <expr>: Enable specific APIs (e.g., 'vk+dx12' or '+dx11')-api-only: Only run tests that use specified APIs-synthesizedTestApi <expr>: Set APIs for synthesized tests-skip-api-detection: Skip API availability detection
API expression syntax:
- Use
+or-to add or remove APIs from defaults - Examples:
vk: Vulkan only+vk: Add Vulkan to defaults-dx12: Remove DirectX 12 from defaultsall: All APIsall-vk: All APIs except Vulkangl+dx11: Only OpenGL and DirectX 11
Available APIs:
- OpenGL:
gl,ogl,opengl - Vulkan:
vk,vulkan - DirectX 12:
dx12,d3d12 - DirectX 11:
dx11,d3d11
Test Execution Options
-server-count <n>: Set number of test servers (default: 1)-use-shared-library: Run tests in-process using shared library-use-test-server: Run tests using test server-use-fully-isolated-test-server: Run each test in isolated server
Output Options
-appveyor: Use AppVeyor output format-travis: Use Travis CI output format-teamcity: Use TeamCity output format-xunit: Use xUnit output format-xunit2: Use xUnit 2 output format-show-adapter-info: Show detailed adapter information
Other Options
-generate-hlsl-baselines: Generate HLSL test baselines-emit-spirv-via-glsl: Emit SPIR-V through GLSL instead of directly-expected-failure-list <file>: Specify file containing expected failures
Test Types
Tests are identified by a special comment at the start of the test file: //TEST:<type>:
To ignore a test, use //DISABLE_TEST instead of //TEST.
Available test types:
SIMPLE: Runs the slangc compiler with specified options after the commandREFLECTION: Runs slang-reflection-test with the options specified after the commandCOMPARE_COMPUTE: Runs render-test to execute a compute shader and writes the result to a text file. The test passes if the output matches the expected contentCOMPARE_COMPUTE_EX: Same as COMPARE_COMPUTE, but supports additional parameter specificationsCOMPARE_RENDER_COMPUTE: Runs render-test with "-slang -gcompute" options and compares text file outputsLANG_SERVER: Tests Language Server Protocol features by sending requests (like completion, hover, signatures) and comparing responses with expected outputs
Deprecated test types (do not create new tests of these kinds, and we need to slowly migrate existing tests to use SIMPLE, COMPARE_COMPUTE(_EX) or COMPARE_RENDER_COMPUTE instead):
COMPARE_HLSL: Runs the slangc compiler with forced DXBC output and compares with a file having the '.expected' extensionCOMPARE_HLSL_RENDER: Runs render-test to generate two images - one using HLSL (expected) and one using Slang, saving both as .png files. The test passes if the images matchCOMPARE_HLSL_CROSS_COMPILE_RENDER: Runs render-test to generate two images - one using Slang and one using -glsl-cross. The test passes if the images matchCOMPARE_HLSL_GLSL_RENDER: Runs render-test to generate two images - one using -hlsl-rewrite and one using -glsl-rewrite. The test passes if the images matchCOMPARE_GLSL: Runs the slangc compiler both through Slang and directly, then compares the SPIR-V assembly outputHLSL_COMPUTE: Runs render-test with "-hlsl-rewrite -compute" options and compares text file outputsCROSS_COMPILE: Compiles using GLSL pass-through and through Slang, then compares the outputs
Unit Tests
In addition to the above test tools, there are also slang-unit-test-tool and gfx-unit-test-tool, which are invoked as in the following examples; but note that the unit tests do get run as part of slang-test as well.
To ignore a unit test, use the SLANG_IGNORE_TEST macro:
SLANG_UNIT_TEST (foo ) {if (condition ) {SLANG_IGNORE_TEST }// ... }
slang-unit-test-tool
# Regular unit tests slang-test slang-unit-test-tool/< test-name> # e.g. run the `byteEncode` test. slang-test slang-unit-test-tool/byteEncode
These tests are located in the tools/slang-unit-test directory, and defined with macros like SLANG_UNIT_TEST(byteEncode).
gfx-unit-test-tool
# Graphics unit tests slang-test gfx-unit-test-tool/< test-name> # e.g. run the `precompiledTargetModule2Vulkan` test. slang-test gfx-unit-test-tool/precompiledTargetModule2Vulkan
These tests are located in tools/gfx-unit-test, and likewise defined using macros like SLANG_UNIT_TEST(precompiledTargetModule2Vulkan).
1# Slang Test 2 3Slang Test (`slang-test`) is a command-line tool that coordinates and runs the Slang test suite. It acts as a test runner hub, executing various types of tests and collecting their results. 4 5## Basic Usage 6 7``` bash 8slang-test [options] [test-prefix...] 9``` 10 11If no test prefix is specified, all tests will be run. Test prefixes can be used to filter which tests to run, and include the path with directories separated by '/'. 12 13Example: 14``` bash 15slang-test -bindir path/to/bin -category full tests/compute/array-param 16``` 17 18## Command Line Options 19 20### Core Options 21- `-h, --help`: Show help message 22- `-bindir <path>`: Set directory for binaries (default: the path to the slang-test executable) 23- `-test-dir <path>`: Set directory for test files (default: tests/) 24- `-v`: Enable verbose output 25- `-verbose-paths`: Use verbose paths in output 26- `-hide-ignored`: Hide results from ignored tests 27 28### Test Selection and Categories 29- `-category <name>`: Only run tests in specified category 30- `-exclude <name>`: Exclude tests in specified category 31 32Available test categories: 33- `full`: All tests 34- `quick`: Quick tests 35- `smoke`: Basic smoke tests 36- `render`: Rendering-related tests 37- `compute`: Compute shader tests 38- `vulkan`: Vulkan-specific tests 39- `compatibility-issue`: Tests for compatibility issues 40 41A test may be in one or more categories. The categories are specified on top of a test, for example: //TEST(smoke,compute):COMPARE_COMPUTE: 42 43### API Control Options 44- `-api <expr>`: Enable specific APIs (e.g., 'vk+dx12' or '+dx11') 45- `-api-only`: Only run tests that use specified APIs 46- `-synthesizedTestApi <expr>`: Set APIs for synthesized tests 47- `-skip-api-detection`: Skip API availability detection 48 49API expression syntax: 50- Use `+` or `-` to add or remove APIs from defaults 51- Examples: 52- `vk`: Vulkan only 53- `+vk`: Add Vulkan to defaults 54- `-dx12`: Remove DirectX 12 from defaults 55- `all`: All APIs 56- `all-vk`: All APIs except Vulkan 57- `gl+dx11`: Only OpenGL and DirectX 11 58 59Available APIs: 60- OpenGL: `gl`, `ogl`, `opengl` 61- Vulkan: `vk`, `vulkan` 62- DirectX 12: `dx12`, `d3d12` 63- DirectX 11: `dx11`, `d3d11` 64 65### Test Execution Options 66- `-server-count <n>`: Set number of test servers (default: 1) 67- `-use-shared-library`: Run tests in-process using shared library 68- `-use-test-server`: Run tests using test server 69- `-use-fully-isolated-test-server`: Run each test in isolated server 70 71### Output Options 72- `-appveyor`: Use AppVeyor output format 73- `-travis`: Use Travis CI output format 74- `-teamcity`: Use TeamCity output format 75- `-xunit`: Use xUnit output format 76- `-xunit2`: Use xUnit 2 output format 77- `-show-adapter-info`: Show detailed adapter information 78 79### Other Options 80- `-generate-hlsl-baselines`: Generate HLSL test baselines 81- `-emit-spirv-via-glsl`: Emit SPIR-V through GLSL instead of directly 82- `-expected-failure-list <file>`: Specify file containing expected failures 83 84## Test Types 85 86Tests are identified by a special comment at the start of the test file: `//TEST:<type>:` 87 88To ignore a test, use `//DISABLE_TEST` instead of `//TEST`. 89 90Available test types: 91- `SIMPLE`: Runs the slangc compiler with specified options after the command 92- `REFLECTION`: Runs slang-reflection-test with the options specified after the command 93- `COMPARE_COMPUTE`: Runs render-test to execute a compute shader and writes the result to a text file. The test passes if the output matches the expected content 94- `COMPARE_COMPUTE_EX`: Same as COMPARE_COMPUTE, but supports additional parameter specifications 95- `COMPARE_RENDER_COMPUTE`: Runs render-test with "-slang -gcompute" options and compares text file outputs 96- `LANG_SERVER`: Tests Language Server Protocol features by sending requests (like completion, hover, signatures) and comparing responses with expected outputs 97 98Deprecated test types (do not create new tests of these kinds, and we need to slowly migrate existing tests to use SIMPLE, COMPARE_COMPUTE(_EX) or COMPARE_RENDER_COMPUTE instead): 99- `COMPARE_HLSL`: Runs the slangc compiler with forced DXBC output and compares with a file having the '.expected' extension 100- `COMPARE_HLSL_RENDER`: Runs render-test to generate two images - one using HLSL (expected) and one using Slang, saving both as .png files. The test passes if the images match 101- `COMPARE_HLSL_CROSS_COMPILE_RENDER`: Runs render-test to generate two images - one using Slang and one using -glsl-cross. The test passes if the images match 102- `COMPARE_HLSL_GLSL_RENDER`: Runs render-test to generate two images - one using -hlsl-rewrite and one using -glsl-rewrite. The test passes if the images match 103- `COMPARE_GLSL`: Runs the slangc compiler both through Slang and directly, then compares the SPIR-V assembly output 104- `HLSL_COMPUTE`: Runs render-test with "-hlsl-rewrite -compute" options and compares text file outputs 105- `CROSS_COMPILE`: Compiles using GLSL pass-through and through Slang, then compares the outputs 106 107## Unit Tests 108In addition to the above test tools, there are also `slang-unit-test-tool` and `gfx-unit-test-tool`, which are invoked as in the following examples; but note that the unit tests do get run as part of `slang-test` as well. 109 110To ignore a unit test, use the `SLANG_IGNORE_TEST` macro: 111 112``` cpp 113SLANG_UNIT_TEST( foo ) 114{ 115if ( condition ) 116{ 117SLANG_IGNORE_TEST 118} 119 120// ... 121} 122``` 123 124### slang-unit-test-tool 125``` bash 126# Regular unit tests 127slang-test slang-unit-test-tool/ < test-name > 128# e.g. run the `byteEncode` test. 129slang-test slang-unit-test-tool/byteEncode 130``` 131These tests are located in the [tools/slang-unit-test](https://github.com/shader-slang/slang/tree/master/tools/slang-unit-test) directory, and defined with macros like `SLANG_UNIT_TEST(byteEncode)`. 132 133### gfx-unit-test-tool 134``` bash 135# Graphics unit tests 136slang-test gfx-unit-test-tool/ < test-name > 137 138# e.g. run the `precompiledTargetModule2Vulkan` test. 139slang-test gfx-unit-test-tool/precompiledTargetModule2Vulkan 140``` 141These tests are located in [tools/gfx-unit-test](https://github.com/shader-slang/slang/tree/master/tools/gfx-unit-test), and likewise defined using macros like `SLANG_UNIT_TEST(precompiledTargetModule2Vulkan)`.