yum-mirror/slang

Making it easier to work with shaders

git clone https://git.yummers.dev/yum-mirror/slang

Janne Kiviluoto (NVIDIA)Add deterministic shuffling of tests in directory (#8622)e4d1200cb

master
5.6 KiB167 linesraw
1// options.h
2
3#ifndef OPTIONS_H_INCLUDED
4#define OPTIONS_H_INCLUDED
5
6#include "../../source/core/slang-dictionary.h"
7#include "../../source/core/slang-render-api-util.h"
8#include "../../source/core/slang-smart-pointer.h"
9#include "test-reporter.h"
10
11// A category that a test can be tagged with
12struct TestCategory : public Slang::RefObject
13{
14    // The name of the category, from the user perspective
15    Slang::String name;
16
17    // The logical "super-category" of this category
18    TestCategory* parent;
19};
20
21struct TestCategorySet
22{
23public:
24    /// Find a category with the specified name. Returns nullptr if not found
25    TestCategory* find(Slang::String const& name);
26    /// Adds a category with the specified name, and parent. Returns the category object.
27    /// Parent can be nullptr
28    TestCategory* add(Slang::String const& name, TestCategory* parent);
29    /// Finds a category by name, else reports and writes an error
30    TestCategory* findOrError(Slang::String const& name);
31
32    Slang::RefPtr<TestCategory> defaultCategory; ///< The default category
33
34protected:
35    Slang::Dictionary<Slang::String, Slang::RefPtr<TestCategory>> m_categoryMap;
36};
37
38enum class SpawnType
39{
40    Default,          ///< Default - typically uses shared library, on CI may use TestServer
41    UseExe,           ///< Tests using executable (for example slangc)
42    UseSharedLibrary, ///< Runs testing in process (a crash tan take down the
43    UseTestServer,    ///< Use the test server to isolate testing
44    UseFullyIsolatedTestServer, ///< Uses a test server for each test (slow!)
45};
46
47enum class VerbosityLevel
48{
49    Failure, ///< Only show failures and errors
50    Info,    ///< Show test discovery and results (default)
51    Verbose, ///< Show detailed output including command lines
52};
53
54struct Options
55{
56    char const* appName = "slang-test";
57
58    // Directory to use when looking for binaries to run. If empty it's not set.
59    Slang::String binDir;
60
61    // Root directory to use when looking for test cases
62    Slang::String testDir;
63
64    // only run test cases with names have one of these prefixes.
65    Slang::List<Slang::String> testPrefixes;
66
67    // skip test cases with names that have one of these prefixes.
68    Slang::List<Slang::String> excludePrefixes;
69
70    // verbosity level for output
71    VerbosityLevel verbosity = VerbosityLevel::Info;
72
73    // When true results from ignored tests are not shown
74    bool hideIgnored = false;
75
76    // When true only tests that use an api that matches the enabledApis flags will run
77    bool apiOnly = false;
78
79    // Use verbose paths
80    bool verbosePaths = false;
81
82    // force generation of baselines for HLSL tests
83    bool generateHLSLBaselines = false;
84
85    // Skip generation of reference images for render tests, assume they already exist
86    bool skipReferenceImageGeneration = false;
87
88    // Whether to skip the step of creating test devices to check if an API is actually available.
89    bool skipApiDetection = false;
90
91    // Dump expected/actual output on failures, for debugging.
92    // This is especially intended for use in continuous
93    // integration builds.
94    bool dumpOutputOnFailure = false;
95
96    // When true it will run with debug layer (e.g. vulkan validation layer)
97    bool enableDebugLayers = false;
98
99    // Set the default spawn type to use
100    // Having tests isolated, slows down testing considerably, so using UseSharedLibrary is the most
101    // desirable default usually.
102    SpawnType defaultSpawnType = SpawnType::Default;
103
104    // kind of output to generate
105    TestOutputMode outputMode = TestOutputMode::Default;
106
107    // Only run tests that match one of the given categories
108    Slang::Dictionary<TestCategory*, TestCategory*> includeCategories;
109
110    // Exclude test that match one these categories
111    Slang::Dictionary<TestCategory*, TestCategory*> excludeCategories;
112
113    // By default we can test against all apis. If is set to anything other than AllOf only tests
114    // that *require* the API will be run.
115    Slang::RenderApiFlags enabledApis = Slang::RenderApiFlag::AllOf;
116
117    // The subCommand to execute. Will be empty if there is no subCommand
118    Slang::String subCommand;
119
120    // Arguments to the sub command. Note that if there is a subCommand the first parameter is
121    // always the subCommand itself.
122    Slang::List<Slang::String> subCommandArgs;
123
124    // By default we potentially synthesize test for all
125    // TODO: Vulkan is disabled by default for now as the majority as vulkan synthesized tests
126    // CPU is disabled by default
127    // CUDA is disabled by default
128    Slang::RenderApiFlags synthesizedTestApis =
129        Slang::RenderApiFlag::AllOf & ~(Slang::RenderApiFlag::Vulkan | Slang::RenderApiFlag::CPU);
130
131    // If true, print detailed adapter information
132    bool showAdapterInfo = false;
133
134    // Maximum number of test servers to run.
135    int serverCount = 1;
136
137    bool emitSPIRVDirectly = true;
138
139    // Whether to enable RHI device caching in render-test (default: true in slang-test)
140    bool cacheRhiDevice = true;
141
142    Slang::HashSet<Slang::String> capabilities;
143    Slang::HashSet<Slang::String> expectedFailureList;
144
145    // Ignore abort message dialog popup on Windows
146    bool ignoreAbortMsg = false;
147
148    /// Parse the args, report any errors into stdError, and write the results into optionsOut
149    static SlangResult parse(
150        int argc,
151        char** argv,
152        TestCategorySet* categorySet,
153        Slang::WriterHelper stdOut,
154        Slang::WriterHelper stdError,
155        Options* optionsOut);
156
157    /// Display help message
158    static void showHelp(Slang::WriterHelper stdOut);
159
160    /// Whether to shuffle tests
161    bool shuffleTests = false;
162
163    /// Seed for shuffling deterministically
164    uint32_t shuffleSeed = 1;
165};
166
167#endif // OPTIONS_H_INCLUDED