summaryrefslogtreecommitdiffstats
path: root/source/core
diff options
context:
space:
mode:
authorTim Foley <tfoleyNV@users.noreply.github.com>2018-05-02 11:40:09 -0700
committerGitHub <noreply@github.com>2018-05-02 11:40:09 -0700
commit60bcc6809f57e12f3705cc65cb325b0983b08899 (patch)
treedb7707963ffaaff2778b24909e7ffdb5e18ac906 /source/core
parentd3c1c8b5a80d7ae72678ae209b5c0a7a7053ae2a (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 'source/core')
-rw-r--r--source/core/slang-string.cpp5
-rw-r--r--source/core/slang-string.h7
2 files changed, 12 insertions, 0 deletions
diff --git a/source/core/slang-string.cpp b/source/core/slang-string.cpp
index 2420cb7d7..b195e12d5 100644
--- a/source/core/slang-string.cpp
+++ b/source/core/slang-string.cpp
@@ -298,6 +298,11 @@ namespace Slang
append(slice.begin(), slice.end());
}
+ void String::append(UnownedStringSlice const& slice)
+ {
+ append(slice.begin(), slice.end());
+ }
+
void String::append(int32_t value, int radix)
{
enum { kCount = 33 };
diff --git a/source/core/slang-string.h b/source/core/slang-string.h
index 9f18554f6..894776ca6 100644
--- a/source/core/slang-string.h
+++ b/source/core/slang-string.h
@@ -193,6 +193,12 @@ namespace Slang
return (*this) == UnownedStringSlice(str, str + strlen(str));
}
+ bool operator!=(UnownedStringSlice const& other) const
+ {
+ return !(*this == other);
+ }
+
+
bool endsWith(UnownedStringSlice const& other) const;
bool endsWith(char const* str) const;
@@ -328,6 +334,7 @@ namespace Slang
void append(char chr);
void append(String const& str);
void append(StringSlice const& slice);
+ void append(UnownedStringSlice const& slice);
String(int32_t val, int radix = 10)
{