diff options
| author | Tim Foley <tfoleyNV@users.noreply.github.com> | 2018-10-29 14:44:39 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-10-29 14:44:39 -0700 |
| commit | 725985528f77ba939a5cddc71e5006fee7638465 (patch) | |
| tree | 9b5d4d90a02e38a7c564e6df1fa2944616cf7913 /tests/bindings | |
| parent | 56c9de0ae0f0b37d0c5f50f2b39d6c18362642bb (diff) | |
Rework command-line options handling for entry points and targets (#697)
* Rework command-line options handling for entry points and targets
Overview:
* The biggest functionality change is that the implicit ordering constraints when multiple `-entry` options are reversed: any `-stage` option affects the `-entry` to its *left* instead of to its *right* as it used to. This is technically a breaking change, but I expect most users aren't using this feature.
* The options parsing tries to handle profile versions and stages as distinct data (rather than using the combined `Profile` type all over), and treats a `-profile` option that specifies both a profile version and a stage (e.g., `-profile ps_5_0`) as if it were sugar for both a `-profile` and a `-stage` (e.g., `-profile sm_5_0 -stage fragment`).
* We now technically handle multiple `-target` options in one invocation of `-slangc`, but do not advertise that fact in the documentation because it might be confusing for users. Similar to the relationship between `-stage` and `-entry`, any `-profile` option affects the most recent `-target` option unless there is only one `-target`.
* The logic for associating `-o` options with corresponding entry points and targets has been beefed up. The rule is that a `-o` option for a compiled kernel binds to the entry point to its left, unless there is only one entry point (just like for `-stage`). The associated target for a `-o` option is found via a search, however, because otherwise it would be impossible to specify `-o` options for both SPIR-V and DXIL in one pass.
* The handling of output paths for entry points in the internal compiler structures was changed, because previously it could only handle one output path per entry point (even when there are multiple targets). The new logic builds up a per-target mapping from an entry point to its desired output path (if any).
Details:
* Support for formatting profile versions, stages, and compile targets (formats) was added to diagnostic printing, so that we can make better error messages. This is fairly ad hoc, and it would be nice to have all of the string<->enum stuff be more data-driven throughout the codebase.
* Test cases were added for (almost) all of the error conditions in the current options validation. The main one that is missing is around specifying an `-entry` option before any source file when compiling multiple files. This is because the test runner is putting the source file name first on the command line automatically, so we can't reproduce that case.
* Several reflection-related tests now reflect entry points where they didn't before, because the logic for detecting when to infer a default `main` entry point have been made more loose
* On the dxc path, beefed up the handling of mapping from Slang `Profile`s to the coresponding string to use when invoking dxc.
* A bunch of tests cases were in violation of the newly imposed rules, so those needed to be cleaned up.
* There were also a bunch of test cases that had accidentally gotten "disabled" at some point because there were comparing output from `slangc` both with and without a `-pass-through` option, but that meant that any errors in command-line parsing produced the *same* error output in both the Slang and pass-through cases. This change updates `slang-test` to always expect a successful run for these tests, and then manually updates or disables the various test cases that are affected.
* When merging the updated test for matrix layout mode, I found that the new command-line logic was failing to propagate a matrix layout mode passed to `render-test` into the compiler. This was because the `-matrix-layout*` options were implemented as per-target, but the target was being set by API while the option came in via command line (passed through the API). It seems like we want matrix layout mode to be a global option anyway (rather than per-target), so I made that change here.
* Add missing expected output files
* A 64-bit fix
* Remove commented-out code noted in review
Diffstat (limited to 'tests/bindings')
| -rw-r--r-- | tests/bindings/array-of-struct-of-resource.hlsl | 2 | ||||
| -rw-r--r-- | tests/bindings/binding0.hlsl | 2 | ||||
| -rw-r--r-- | tests/bindings/binding1.hlsl | 2 | ||||
| -rw-r--r-- | tests/bindings/explicit-binding.hlsl | 2 | ||||
| -rw-r--r-- | tests/bindings/multi-file.hlsl | 2 | ||||
| -rw-r--r-- | tests/bindings/multiple-parameter-blocks.slang | 2 | ||||
| -rw-r--r-- | tests/bindings/packoffset.hlsl | 2 | ||||
| -rw-r--r-- | tests/bindings/parameter-blocks.slang | 2 | ||||
| -rw-r--r-- | tests/bindings/resources-in-cbuffer.hlsl | 2 | ||||
| -rw-r--r-- | tests/bindings/resources-in-structs.hlsl.disabled | 2 | ||||
| -rw-r--r-- | tests/bindings/targets-and-uavs-structure.hlsl | 2 | ||||
| -rw-r--r-- | tests/bindings/targets-and-uavs.hlsl | 2 |
12 files changed, 12 insertions, 12 deletions
diff --git a/tests/bindings/array-of-struct-of-resource.hlsl b/tests/bindings/array-of-struct-of-resource.hlsl index 11dcc18da..b34e0469b 100644 --- a/tests/bindings/array-of-struct-of-resource.hlsl +++ b/tests/bindings/array-of-struct-of-resource.hlsl @@ -1,4 +1,4 @@ -//TEST:COMPARE_HLSL:-no-mangle -target dxbc-assembly -profile ps_5_1 -entry main +//TEST:COMPARE_HLSL:-no-mangle -profile ps_5_1 -entry main // Let's first confirm that Slang can reproduce what the // HLSL compiler would already do in the simple case (when diff --git a/tests/bindings/binding0.hlsl b/tests/bindings/binding0.hlsl index 3e9f92992..85f17e940 100644 --- a/tests/bindings/binding0.hlsl +++ b/tests/bindings/binding0.hlsl @@ -1,4 +1,4 @@ -//TEST:COMPARE_HLSL:-no-mangle -target dxbc-assembly -profile ps_4_0 -entry main +//TEST:COMPARE_HLSL:-no-mangle -profile ps_4_0 -entry main // Let's first confirm that Slang can reproduce what the // HLSL compiler would already do in the simple case (when diff --git a/tests/bindings/binding1.hlsl b/tests/bindings/binding1.hlsl index cc3389d93..8709c31c6 100644 --- a/tests/bindings/binding1.hlsl +++ b/tests/bindings/binding1.hlsl @@ -1,4 +1,4 @@ -//TEST:COMPARE_HLSL:-no-mangle -target dxbc-assembly -profile ps_4_0 -entry main +//TEST:COMPARE_HLSL:-no-mangle -profile ps_4_0 -entry main // We want to make sure that the registers Slang generates // are used, even if there are "dead" parameter earlier in the program. diff --git a/tests/bindings/explicit-binding.hlsl b/tests/bindings/explicit-binding.hlsl index b8da9a77a..9c38cdee0 100644 --- a/tests/bindings/explicit-binding.hlsl +++ b/tests/bindings/explicit-binding.hlsl @@ -1,4 +1,4 @@ -//TEST:COMPARE_HLSL:-no-mangle -target dxbc-assembly -profile ps_4_0 -entry main +//TEST:COMPARE_HLSL:-no-mangle -profile ps_4_0 -entry main // We need to allow the user to add explicit bindings to their parameters, // and we can't go and auto-assign anything to use the same locations. diff --git a/tests/bindings/multi-file.hlsl b/tests/bindings/multi-file.hlsl index 992703155..6269c703e 100644 --- a/tests/bindings/multi-file.hlsl +++ b/tests/bindings/multi-file.hlsl @@ -1,4 +1,4 @@ -//TEST:COMPARE_HLSL:-no-mangle -target dxbc-assembly -profile vs_4_0 -entry main Tests/bindings/multi-file-extra.hlsl -profile ps_4_0 -entry main +//TEST:COMPARE_HLSL:-no-mangle -profile sm_4_0 -entry main -stage vertex Tests/bindings/multi-file-extra.hlsl -entry main -stage fragment // Here we are going to test that we can correctly generating bindings when we // are presented with a program spanning multiple input files (and multiple entry points) diff --git a/tests/bindings/multiple-parameter-blocks.slang b/tests/bindings/multiple-parameter-blocks.slang index dee3c60f4..29eea6766 100644 --- a/tests/bindings/multiple-parameter-blocks.slang +++ b/tests/bindings/multiple-parameter-blocks.slang @@ -1,4 +1,4 @@ -//TEST:COMPARE_HLSL:-target dxbc-assembly -profile ps_5_1 -entry main -parameter-blocks-use-register-spaces +//TEST:COMPARE_HLSL:-profile ps_5_1 -entry main -parameter-blocks-use-register-spaces // Confirm that Slang `ParameterBlock<T>` generates // parameter bindings like we expect. diff --git a/tests/bindings/packoffset.hlsl b/tests/bindings/packoffset.hlsl index f912e76d8..81913d672 100644 --- a/tests/bindings/packoffset.hlsl +++ b/tests/bindings/packoffset.hlsl @@ -1,4 +1,4 @@ -//TEST:COMPARE_HLSL:-no-mangle -target dxbc-assembly -profile ps_4_0 -entry main +//TEST:COMPARE_HLSL:-no-mangle -profile ps_4_0 -entry main // Let's make sure we generate correct output in cases // where there are non-trivial `packoffset`s needed diff --git a/tests/bindings/parameter-blocks.slang b/tests/bindings/parameter-blocks.slang index 756a6ec1a..6941ce77c 100644 --- a/tests/bindings/parameter-blocks.slang +++ b/tests/bindings/parameter-blocks.slang @@ -1,4 +1,4 @@ -//TEST:COMPARE_HLSL:-no-mangle -target dxbc-assembly -profile ps_5_1 -entry main -parameter-blocks-use-register-spaces +//TEST:COMPARE_HLSL:-no-mangle -profile ps_5_1 -entry main -parameter-blocks-use-register-spaces // Confirm that Slang `ParameterBlock<T>` generates // parameter bindings like we expect. diff --git a/tests/bindings/resources-in-cbuffer.hlsl b/tests/bindings/resources-in-cbuffer.hlsl index e3dcfc28e..4d3d381d9 100644 --- a/tests/bindings/resources-in-cbuffer.hlsl +++ b/tests/bindings/resources-in-cbuffer.hlsl @@ -1,4 +1,4 @@ -//TEST:COMPARE_HLSL:-no-mangle -target dxbc-assembly -profile ps_4_0 -entry main +//TEST:COMPARE_HLSL:-no-mangle -profile ps_4_0 -entry main // Confirm that resources inside constant buffers get correct locations, // including the case where there are *multiple* constant buffers diff --git a/tests/bindings/resources-in-structs.hlsl.disabled b/tests/bindings/resources-in-structs.hlsl.disabled index 45c066f31..be218c29b 100644 --- a/tests/bindings/resources-in-structs.hlsl.disabled +++ b/tests/bindings/resources-in-structs.hlsl.disabled @@ -1,4 +1,4 @@ -//SLANG_TEST_OPTS:-target dxbc-assembly -profile ps_5_0 -entry main +//SLANG_TEST_OPTS:-profile ps_5_0 -entry main // Confirm that resources inside `struct` types work reasonably well, diff --git a/tests/bindings/targets-and-uavs-structure.hlsl b/tests/bindings/targets-and-uavs-structure.hlsl index 3c7499cf5..dd860369d 100644 --- a/tests/bindings/targets-and-uavs-structure.hlsl +++ b/tests/bindings/targets-and-uavs-structure.hlsl @@ -1,4 +1,4 @@ -//TEST(smoke):COMPARE_HLSL:-no-mangle -target dxbc-assembly -profile ps_5_0 -entry main +//TEST(smoke):COMPARE_HLSL:-no-mangle -profile ps_5_0 -entry main // Handle the case where the fragment shader output is // defined a structure, and the semantics are on the sub-fields diff --git a/tests/bindings/targets-and-uavs.hlsl b/tests/bindings/targets-and-uavs.hlsl index 7c6389e36..ac64c8f5f 100644 --- a/tests/bindings/targets-and-uavs.hlsl +++ b/tests/bindings/targets-and-uavs.hlsl @@ -1,4 +1,4 @@ -//TEST:COMPARE_HLSL:-no-mangle -target dxbc-assembly -profile ps_5_0 -entry main +//TEST:COMPARE_HLSL:-no-mangle -profile ps_5_0 -entry main // Render target outputs (`SV_Target`) and UAVs are treated // as sharing the same binding slots in HLSL, so we need to |
