diff options
| author | jsmall-nvidia <jsmall@nvidia.com> | 2023-04-17 15:09:37 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-04-17 15:09:37 -0400 |
| commit | 90a9f43573ec0777c2ae4fa20c8fdc51a4ae7b3a (patch) | |
| tree | 360750778be872a086674024a9ce5a68bf4e7cb3 /tests/serialization | |
| parent | a3f622ace1bdef1f1a4150ec85d1328d1a589333 (diff) | |
Round trip source map (#2810)
* #include an absolute path didn't work - because paths were taken to always be relative.
* Make output of obfuscation locs work in a slang-module.
* Tidy up detection for writing serialized source locs.
* Support for .zip references.
Handling of obfuscated source maps read from containers.
A test to check obfuscated source map working on a module.
* When using obfuscation, always obfuscate locs instead of stripping them. We keep a source map, so we can still produce reasonable errors.
* Write out source locs if debug information is enabled.
* Check output without sourcemap.
* Small fixes.
* Small improvements around hash calculation for source map name.
* Disable test that fails on x86 gcc linux for now.
* Fix issues around obfuscated source map using lines rather than columns.
Fix some issues around encoding/decoding.
* Make column calculation of source locs take into account utf8/tabs.
Don't special case obfuscated source map for lookup for source loc.
* Support following multiple source maps.
* Small fixes/improvements around SourceMap lookup.
Diffstat (limited to 'tests/serialization')
5 files changed, 63 insertions, 1 deletions
diff --git a/tests/serialization/obfuscated-loc-module.slang b/tests/serialization/obfuscated-loc-module.slang new file mode 100644 index 000000000..63c4f61ee --- /dev/null +++ b/tests/serialization/obfuscated-loc-module.slang @@ -0,0 +1,21 @@ +//TEST_IGNORE_FILE: + +// obfuscated-loc-module.slang + + +int billy(int v) +{ + return v + 1; +} + +// This function is designed to fail during IR passes/emit. +int silly(int a) +{ + int t = 0; + [ForceUnroll(10)] + while ( a > 0) + { + t = t + t + a; + } + return t; +} diff --git a/tests/serialization/obfuscated-module-check-loc.slang b/tests/serialization/obfuscated-module-check-loc.slang new file mode 100644 index 000000000..f603d5403 --- /dev/null +++ b/tests/serialization/obfuscated-module-check-loc.slang @@ -0,0 +1,29 @@ +//TEST:COMPILE: tests/serialization/obfuscated-loc-module.slang -o tests/serialization/obfuscated-loc-module.zip -g -obfuscate -source-map +//TEST:SIMPLE:-target hlsl -stage compute -entry computeMain -obfuscate -r tests/serialization/obfuscated-loc-module.zip +//TEST:COMPILE: tests/serialization/obfuscated-loc-module.slang -o tests/serialization/obfuscated-loc-module.zip -g -obfuscate +// Disable for now as it breaks on gcc/release as different hash seems to be produced +//DISABLE_TEST:SIMPLE:-target hlsl -stage compute -entry computeMain -obfuscate -r tests/serialization/obfuscated-loc-module.zip + +//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer +RWStructuredBuffer<float> outputBuffer; + +// This test checks obfuscated source map loc tracking through a round trip, and producing a location correctly from slang-module that has a source map + +// We *don't* import because if we do we'll get a fresh compilation from source... we want to make sure it's using the -r module +//import obfuscated_loc_module; +int silly(int v); +int billy(int v); + +[numthreads(1, 1, 1)] +void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + int x = int(dispatchThreadID.x); + + x = billy(x); + + // Will produce an error, because silly has an error. + int v = silly(x); + + outputBuffer[x] = v; +} + diff --git a/tests/serialization/obfuscated-module-check-loc.slang.1.expected b/tests/serialization/obfuscated-module-check-loc.slang.1.expected new file mode 100644 index 000000000..aaf3bfd48 --- /dev/null +++ b/tests/serialization/obfuscated-module-check-loc.slang.1.expected @@ -0,0 +1,6 @@ +result code = -1 +standard error = { +tests/serialization/obfuscated-loc-module.slang(16): error 40020: loop does not terminate within the limited number of iterations, unrolling is aborted. +} +standard output = { +} diff --git a/tests/serialization/obfuscated-module-check-loc.slang.3.expected b/tests/serialization/obfuscated-module-check-loc.slang.3.expected new file mode 100644 index 000000000..94f740eb5 --- /dev/null +++ b/tests/serialization/obfuscated-module-check-loc.slang.3.expected @@ -0,0 +1,6 @@ +result code = -1 +standard error = { +bc65f637-obfuscated(6): error 40020: loop does not terminate within the limited number of iterations, unrolling is aborted. +} +standard output = { +} diff --git a/tests/serialization/obfuscated-serialized-module-test.slang b/tests/serialization/obfuscated-serialized-module-test.slang index 55a68f6c2..b007b7516 100644 --- a/tests/serialization/obfuscated-serialized-module-test.slang +++ b/tests/serialization/obfuscated-serialized-module-test.slang @@ -3,7 +3,7 @@ // A test to try out the basics of module // serialization, obfuscation and source maps. -//TEST:COMPILE: tests/serialization/serialized-module.slang -o tests/serialization/obfuscated-serialized-module.slang-module -obfuscate -source-map +//TEST:COMPILE: tests/serialization/serialized-module.slang -o tests/serialization/obfuscated-serialized-module.slang-module -g -obfuscate -source-map //TEST:COMPARE_COMPUTE_EX:-slang -compute -Xslang... -r tests/serialization/obfuscated-serialized-module.slang-module -obfuscate -source-map -X. -shaderobj //import obfuscated_serialized_module; |
