diff options
| author | Tim Foley <tfoleyNV@users.noreply.github.com> | 2018-05-02 11:40:09 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-05-02 11:40:09 -0700 |
| commit | 60bcc6809f57e12f3705cc65cb325b0983b08899 (patch) | |
| tree | db7707963ffaaff2778b24909e7ffdb5e18ac906 /tests | |
| parent | d3c1c8b5a80d7ae72678ae209b5c0a7a7053ae2a (diff) | |
Add support for explicit register space bindings (#542)
This change adds support for specifying explicit register spaces, like:
```hlsl
// Bind to texture register #2 in space #1
Texture2D t : register(t2, space1);
```
I added a test case to confirm that the register space is properly propagated through the Slang reflection API.
This change also adds proper error messages for some error/unsupported cases that weren't being diagnosed:
* Specifying a completely bogus register "class" (e.g., `register(bad99)`)
* Failing to specify a register index (`register(u)`)
* Specifying a component mask (`register(t0.x)`)
* Using `packoffset` bindings
I added test cases to cover all of these, as well as the new errors around support for register `space` bindings.
In order to get the existing tests to pass, I had to remove explicit `packoffset` bindings from some DXSDK test shaders.
None of these `packoffset` bindings were semantically significant (they matched what the compiler would do anyway, for both Slang and the standard HLSL compiler). Removing them is required for Slang now that we give an explicit error about our lack of `packoffset` support.
In a future change we might add logic to either detect semantically insignificant `packoffset`s, or to just go ahead and support them properly (as a general feature on `struct` types).
Diffstat (limited to 'tests')
15 files changed, 93 insertions, 15 deletions
diff --git a/tests/diagnostics/gh-38-vs.hlsl.expected b/tests/diagnostics/gh-38-vs.hlsl.expected index 05f455821..76987ae44 100644 --- a/tests/diagnostics/gh-38-vs.hlsl.expected +++ b/tests/diagnostics/gh-38-vs.hlsl.expected @@ -1,8 +1,8 @@ result code = -1 standard error = { -tests/diagnostics/gh-38-fs.hlsl(7): error 39999: conflicting explicit bindings for parameter 'conflicting' +tests/diagnostics/gh-38-fs.hlsl(7): error 39000: conflicting explicit bindings for parameter 'conflicting' tests/diagnostics/gh-38-vs.hlsl(7): note: see other declaration of 'conflicting' -tests/diagnostics/gh-38-fs.hlsl(5): warning 39999: explicit binding for parameter 'overlappingB' overlaps with parameter 'overlappingA' +tests/diagnostics/gh-38-fs.hlsl(5): warning 39001: explicit binding for parameter 'overlappingB' overlaps with parameter 'overlappingA' tests/diagnostics/gh-38-vs.hlsl(5): note: see declaration of 'overlappingA' } standard output = { diff --git a/tests/diagnostics/packoffset.slang b/tests/diagnostics/packoffset.slang new file mode 100644 index 000000000..31ee63bbd --- /dev/null +++ b/tests/diagnostics/packoffset.slang @@ -0,0 +1,11 @@ +// packoffset.slang +//TEST:SIMPLE:-target hlsl + +// use of `packoffset` (not supported): +cbuffer B +{ + float4 x : packoffset(c0); +} + +void main() +{}
\ No newline at end of file diff --git a/tests/diagnostics/packoffset.slang.expected b/tests/diagnostics/packoffset.slang.expected new file mode 100644 index 000000000..3930fee6a --- /dev/null +++ b/tests/diagnostics/packoffset.slang.expected @@ -0,0 +1,6 @@ +result code = -1 +standard error = { +tests/diagnostics/packoffset.slang(7): error 39012: explicit 'packoffset' bindings are not yet supported in Slang +} +standard output = { +} diff --git a/tests/diagnostics/register-bindings.slang b/tests/diagnostics/register-bindings.slang new file mode 100644 index 000000000..188d22bf5 --- /dev/null +++ b/tests/diagnostics/register-bindings.slang @@ -0,0 +1,22 @@ +// register-bindings.slang +//TEST:SIMPLE:-target hlsl + +// Various bad forms for register bindings + +// Not a valid register class: +Texture2D a : register(DOESNT_EXIST); + +// No register index given: +TextureCube b : register(t); + +// Unexpected name in place of `space`: +SamplerState c : register(s0, s1); + +// No space index given after `space`: +SamplerState d : register(s2, space); + +// use of a component mask (not supported): +Texture2D e : register(t3.x); + +void main() +{}
\ No newline at end of file diff --git a/tests/diagnostics/register-bindings.slang.expected b/tests/diagnostics/register-bindings.slang.expected new file mode 100644 index 000000000..04d062b10 --- /dev/null +++ b/tests/diagnostics/register-bindings.slang.expected @@ -0,0 +1,10 @@ +result code = -1 +standard error = { +tests/diagnostics/register-bindings.slang(7): error 39007: unknown register class: 'DOESNT_EXIST' +tests/diagnostics/register-bindings.slang(10): error 39008: expected a register index after 't' +tests/diagnostics/register-bindings.slang(13): error 39009: expected 'space', got 's' +tests/diagnostics/register-bindings.slang(16): error 39010: expected a register space index after 'space' +tests/diagnostics/register-bindings.slang(19): error 39011: explicit register component masks are not yet supported in Slang +} +standard output = { +} diff --git a/tests/hlsl/dxsdk/AdaptiveTessellationCS40/Render.hlsl b/tests/hlsl/dxsdk/AdaptiveTessellationCS40/Render.hlsl index 73eeb8f81..7b7b285b7 100644 --- a/tests/hlsl/dxsdk/AdaptiveTessellationCS40/Render.hlsl +++ b/tests/hlsl/dxsdk/AdaptiveTessellationCS40/Render.hlsl @@ -15,7 +15,7 @@ //-------------------------------------------------------------------------------------- cbuffer cbPerObject : register( b0 ) { - row_major matrix g_mWorldViewProjection : packoffset( c0 ); + row_major matrix g_mWorldViewProjection ;//SLANG: : packoffset( c0 ); } // The tessellated vertex structure diff --git a/tests/hlsl/dxsdk/BasicHLSL11/BasicHLSL11_PS.hlsl b/tests/hlsl/dxsdk/BasicHLSL11/BasicHLSL11_PS.hlsl index d119653a9..97b8b6c7e 100644 --- a/tests/hlsl/dxsdk/BasicHLSL11/BasicHLSL11_PS.hlsl +++ b/tests/hlsl/dxsdk/BasicHLSL11/BasicHLSL11_PS.hlsl @@ -21,13 +21,13 @@ //-------------------------------------------------------------------------------------- cbuffer cbPerObject : register( b0 ) { - float4 g_vObjectColor : packoffset( c0 ); + float4 g_vObjectColor ;//SLANG: : packoffset( c0 ); }; cbuffer cbPerFrame : register( b1 ) { - float3 g_vLightDir : packoffset( c0 ); - float g_fAmbient : packoffset( c0.w ); + float3 g_vLightDir ;//SLANG: : packoffset( c0 ); + float g_fAmbient ;//SLANG: : packoffset( c0.w ); }; //-------------------------------------------------------------------------------------- diff --git a/tests/hlsl/dxsdk/BasicHLSL11/BasicHLSL11_VS.hlsl b/tests/hlsl/dxsdk/BasicHLSL11/BasicHLSL11_VS.hlsl index 6d854a83b..fa5a7e0b4 100644 --- a/tests/hlsl/dxsdk/BasicHLSL11/BasicHLSL11_VS.hlsl +++ b/tests/hlsl/dxsdk/BasicHLSL11/BasicHLSL11_VS.hlsl @@ -19,8 +19,8 @@ //-------------------------------------------------------------------------------------- cbuffer cbPerObject : register( b0 ) { - matrix g_mWorldViewProjection : packoffset( c0 ); - matrix g_mWorld : packoffset( c4 ); + matrix g_mWorldViewProjection ;//SLANG: : packoffset( c0 ); + matrix g_mWorld ;//SLANG: : packoffset( c4 ); }; //-------------------------------------------------------------------------------------- diff --git a/tests/hlsl/dxsdk/CascadedShadowMaps11/RenderCascadeShadow.hlsl b/tests/hlsl/dxsdk/CascadedShadowMaps11/RenderCascadeShadow.hlsl index 0f3b851df..e9175834a 100644 --- a/tests/hlsl/dxsdk/CascadedShadowMaps11/RenderCascadeShadow.hlsl +++ b/tests/hlsl/dxsdk/CascadedShadowMaps11/RenderCascadeShadow.hlsl @@ -19,7 +19,7 @@ //-------------------------------------------------------------------------------------- cbuffer cbPerObject : register( b0 ) { - matrix g_mWorldViewProjection : packoffset( c0 ); + matrix g_mWorldViewProjection ;//SLANG: : packoffset( c0 ); }; //-------------------------------------------------------------------------------------- diff --git a/tests/hlsl/dxsdk/DynamicShaderLinkage11/DynamicShaderLinkage11_VS.hlsl b/tests/hlsl/dxsdk/DynamicShaderLinkage11/DynamicShaderLinkage11_VS.hlsl index 80f7c452a..7421c8aa7 100644 --- a/tests/hlsl/dxsdk/DynamicShaderLinkage11/DynamicShaderLinkage11_VS.hlsl +++ b/tests/hlsl/dxsdk/DynamicShaderLinkage11/DynamicShaderLinkage11_VS.hlsl @@ -19,8 +19,8 @@ //-------------------------------------------------------------------------------------- cbuffer cbPerObject : register( b0 ) { - float4x4 g_mWorldViewProjection : packoffset( c0 ); - float4x4 g_mWorld : packoffset( c4 ); + float4x4 g_mWorldViewProjection ;//SLANG: : packoffset( c0 ); + float4x4 g_mWorld ;//SLANG: : packoffset( c4 ); }; //-------------------------------------------------------------------------------------- diff --git a/tests/hlsl/dxsdk/MultithreadedRendering11/MultithreadedRendering11_VS.hlsl b/tests/hlsl/dxsdk/MultithreadedRendering11/MultithreadedRendering11_VS.hlsl index c2239293e..464bb4c8a 100644 --- a/tests/hlsl/dxsdk/MultithreadedRendering11/MultithreadedRendering11_VS.hlsl +++ b/tests/hlsl/dxsdk/MultithreadedRendering11/MultithreadedRendering11_VS.hlsl @@ -23,11 +23,11 @@ //-------------------------------------------------------------------------------------- cbuffer cbPerObject : register( b0 ) { - matrix g_mWorld : packoffset( c0 ); + matrix g_mWorld ;//SLANG: : packoffset( c0 ); }; cbuffer cbPerScene : register( b1 ) { - matrix g_mViewProj : packoffset( c0 ); + matrix g_mViewProj ;//SLANG: : packoffset( c0 ); }; //-------------------------------------------------------------------------------------- diff --git a/tests/hlsl/dxsdk/OIT11/SceneVS.hlsl b/tests/hlsl/dxsdk/OIT11/SceneVS.hlsl index b361df0d6..a6b971a57 100644 --- a/tests/hlsl/dxsdk/OIT11/SceneVS.hlsl +++ b/tests/hlsl/dxsdk/OIT11/SceneVS.hlsl @@ -16,7 +16,7 @@ cbuffer cbPerObject : register( b0 ) { - row_major matrix g_mWorldViewProjection : packoffset( c0 ); + row_major matrix g_mWorldViewProjection ;//SLANG: : packoffset( c0 ); } struct SceneVS_Input diff --git a/tests/hlsl/dxsdk/VarianceShadows11/RenderVarianceShadow.hlsl b/tests/hlsl/dxsdk/VarianceShadows11/RenderVarianceShadow.hlsl index af5ba6343..e80360754 100644 --- a/tests/hlsl/dxsdk/VarianceShadows11/RenderVarianceShadow.hlsl +++ b/tests/hlsl/dxsdk/VarianceShadows11/RenderVarianceShadow.hlsl @@ -10,7 +10,7 @@ //-------------------------------------------------------------------------------------- cbuffer cbPerObject : register( b0 ) { - matrix g_mWorldViewProjection : packoffset( c0 ); + matrix g_mWorldViewProjection ;//SLANG: : packoffset( c0 ); }; //-------------------------------------------------------------------------------------- diff --git a/tests/reflection/explicit-register-space.slang b/tests/reflection/explicit-register-space.slang new file mode 100644 index 000000000..d0bdc8178 --- /dev/null +++ b/tests/reflection/explicit-register-space.slang @@ -0,0 +1,12 @@ +// explicit-register-space.slang +//TEST:REFLECTION:-profile ps_5_1 -target hlsl + +// Confirm that we handle explicit register spaces +// on global shader parameters. + +Texture2D tx : register(t1, space2); + +float4 main() : SV_Target +{ + return 0.0; +}
\ No newline at end of file diff --git a/tests/reflection/explicit-register-space.slang.expected b/tests/reflection/explicit-register-space.slang.expected new file mode 100644 index 000000000..7c1a88662 --- /dev/null +++ b/tests/reflection/explicit-register-space.slang.expected @@ -0,0 +1,17 @@ +result code = 0 +standard error = { +} +standard output = { +{ + "parameters": [ + { + "name": "tx", + "binding": {"kind": "shaderResource", "space": 2, "index": 1}, + "type": { + "kind": "resource", + "baseShape": "texture2D" + } + } + ] +} +} |
