From 60bcc6809f57e12f3705cc65cb325b0983b08899 Mon Sep 17 00:00:00 2001 From: Tim Foley Date: Wed, 2 May 2018 11:40:09 -0700 Subject: 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). --- tests/reflection/explicit-register-space.slang | 12 ++++++++++++ tests/reflection/explicit-register-space.slang.expected | 17 +++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 tests/reflection/explicit-register-space.slang create mode 100644 tests/reflection/explicit-register-space.slang.expected (limited to 'tests/reflection') 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" + } + } + ] +} +} -- cgit v1.2.3