diff options
| author | Tim Foley <tfoley@nvidia.com> | 2017-08-25 15:18:10 -0700 |
|---|---|---|
| committer | Tim Foley <tfoley@nvidia.com> | 2017-08-25 15:48:49 -0700 |
| commit | 8c68434d6fa6ff1b2e54586637869cceace9d1bb (patch) | |
| tree | 69f257a9357fa1962ec4a76b258c06abdafef1bc /tests | |
| parent | 7e05e062a0b7c39dbce6e850227d2038aca2f38e (diff) | |
Fix some resources-in-structs bugs
Fixes #171
Fixes #172
These two bugs related to bad logic in handling of splitting resource-containing `cbuffer` declarations.
- Issue #171 was the case where a `cbuffer` *only* had resource fields, in which case we crashed whenever referencing any field (some code was assuming there had to be non-resource fields)
- Issue #172 was a case where two fields were declared with a single declaration (`Texture2D a, b;`), and the logic we had for tracking resource-type fields was accidentally tagging *both* fields with a single modifier so that field `b` would get confused for `a` in some contexts, and attempts to access `b` would crash.
Both issues are now fixed, and regression tests have been added.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/bugs/gh-171.slang | 34 | ||||
| -rw-r--r-- | tests/bugs/gh-172.slang | 41 |
2 files changed, 75 insertions, 0 deletions
diff --git a/tests/bugs/gh-171.slang b/tests/bugs/gh-171.slang new file mode 100644 index 000000000..6a8d27ff0 --- /dev/null +++ b/tests/bugs/gh-171.slang @@ -0,0 +1,34 @@ +//TEST:COMPARE_HLSL: -profile ps_5_0 -entry main -target dxbc-assembly -split-mixed-types +// Make sure we don't crash when desugaring resources +// in structs when a `cbuffer` only contains resources. + +#ifdef __SLANG__ + +cbuffer C +{ + Texture2D t; + SamplerState s; +}; + +float4 main(float2 uv: UV) : SV_Target +{ + return t.Sample(s, uv); +} + +#else + +cbuffer C : register(b0) +{ +}; + +Texture2D SLANG_parameterBlock_C_t : register(t0); +SamplerState SLANG_parameterBlock_C_s : register(s0); + +float4 main(float2 uv: UV) : SV_Target +{ + return SLANG_parameterBlock_C_t.Sample(SLANG_parameterBlock_C_s, uv); +} + +#endif + + diff --git a/tests/bugs/gh-172.slang b/tests/bugs/gh-172.slang new file mode 100644 index 000000000..f898b5f4b --- /dev/null +++ b/tests/bugs/gh-172.slang @@ -0,0 +1,41 @@ +//TEST:COMPARE_HLSL: -profile ps_5_0 -entry main -target dxbc-assembly -split-mixed-types + +// Make sure we don't crash when desugaring resource in structs, +// when the user also declares multiple variables with a +// single declaration. + +#ifdef __SLANG__ + +cbuffer C +{ + Texture2D t0, t1; + SamplerState s; + float2 uv; +}; + +float4 main() : SV_Target +{ + return t0.Sample(s, uv) + + t1.Sample(s, uv); +} + +#else + +cbuffer C : register(b0) +{ + float2 uv; +}; + +Texture2D SLANG_parameterBlock_C_t0 : register(t0); +Texture2D SLANG_parameterBlock_C_t1 : register(t1); +SamplerState SLANG_parameterBlock_C_s : register(s0); + +float4 main() : SV_Target +{ + return SLANG_parameterBlock_C_t0.Sample(SLANG_parameterBlock_C_s, uv) + + SLANG_parameterBlock_C_t1.Sample(SLANG_parameterBlock_C_s, uv); +} + +#endif + + |
