summaryrefslogtreecommitdiff
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
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).
-rw-r--r--source/core/slang-string.cpp5
-rw-r--r--source/core/slang-string.h7
-rw-r--r--source/slang/diagnostic-defs.h32
-rw-r--r--source/slang/diagnostics.cpp6
-rw-r--r--source/slang/diagnostics.h1
-rw-r--r--source/slang/modifier-defs.h4
-rw-r--r--source/slang/parameter-binding.cpp105
-rw-r--r--source/slang/parser.cpp81
-rw-r--r--tests/diagnostics/gh-38-vs.hlsl.expected4
-rw-r--r--tests/diagnostics/packoffset.slang11
-rw-r--r--tests/diagnostics/packoffset.slang.expected6
-rw-r--r--tests/diagnostics/register-bindings.slang22
-rw-r--r--tests/diagnostics/register-bindings.slang.expected10
-rw-r--r--tests/hlsl/dxsdk/AdaptiveTessellationCS40/Render.hlsl2
-rw-r--r--tests/hlsl/dxsdk/BasicHLSL11/BasicHLSL11_PS.hlsl6
-rw-r--r--tests/hlsl/dxsdk/BasicHLSL11/BasicHLSL11_VS.hlsl4
-rw-r--r--tests/hlsl/dxsdk/CascadedShadowMaps11/RenderCascadeShadow.hlsl2
-rw-r--r--tests/hlsl/dxsdk/DynamicShaderLinkage11/DynamicShaderLinkage11_VS.hlsl4
-rw-r--r--tests/hlsl/dxsdk/MultithreadedRendering11/MultithreadedRendering11_VS.hlsl4
-rw-r--r--tests/hlsl/dxsdk/OIT11/SceneVS.hlsl2
-rw-r--r--tests/hlsl/dxsdk/VarianceShadows11/RenderVarianceShadow.hlsl2
-rw-r--r--tests/reflection/explicit-register-space.slang12
-rw-r--r--tests/reflection/explicit-register-space.slang.expected17
23 files changed, 293 insertions, 56 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)
{
diff --git a/source/slang/diagnostic-defs.h b/source/slang/diagnostic-defs.h
index 8f564cc59..f8e048bdb 100644
--- a/source/slang/diagnostic-defs.h
+++ b/source/slang/diagnostic-defs.h
@@ -253,18 +253,6 @@ DIAGNOSTIC(39999, Error, tooManyArguments, "too many arguments to call (got $0,
DIAGNOSTIC(39999, Error, invalidIntegerLiteralSuffix, "invalid suffix '$0' on integer literal")
DIAGNOSTIC(39999, Error, invalidFloatingPOintLiteralSuffix, "invalid suffix '$0' on floating-point literal")
-DIAGNOSTIC(39999, Error, conflictingExplicitBindingsForParameter, "conflicting explicit bindings for parameter '$0'")
-DIAGNOSTIC(39999, Warning, parameterBindingsOverlap, "explicit binding for parameter '$0' overlaps with parameter '$1'")
-
-
-DIAGNOSTIC(39999, Error, shaderParameterDeclarationsDontMatch, "declarations of shader parameter '$0' in different translation units don't match")
-
-DIAGNOSTIC(39999, Note, shaderParameterTypeMismatch, "type is declared as '$0' in one translation unit, and '$0' in another")
-DIAGNOSTIC(39999, Note, fieldTypeMisMatch, "type of field '$0' is declared as '$1' in one translation unit, and '$2' in another")
-DIAGNOSTIC(39999, Note, fieldDeclarationsDontMatch, "type '$0' is declared with different fields in each translation unit")
-DIAGNOSTIC(39999, Note, usedInDeclarationOf, "used in declaration of '$0'")
-
-
@@ -287,6 +275,26 @@ DIAGNOSTIC(38021, Error, typeArgumentDoesNotConformToInterface, "type argument `
DIAGNOSTIC(38200, Error, recursiveModuleImport, "module `$0` recursively imports itself")
DIAGNOSTIC(39999, Fatal, errorInImportedModule, "error in imported module, compilation ceased.")
+// 39xxx - Type layout and parameter binding.
+
+DIAGNOSTIC(39000, Error, conflictingExplicitBindingsForParameter, "conflicting explicit bindings for parameter '$0'")
+DIAGNOSTIC(39001, Warning, parameterBindingsOverlap, "explicit binding for parameter '$0' overlaps with parameter '$1'")
+
+
+DIAGNOSTIC(39002, Error, shaderParameterDeclarationsDontMatch, "declarations of shader parameter '$0' in different translation units don't match")
+
+DIAGNOSTIC(39003, Note, shaderParameterTypeMismatch, "type is declared as '$0' in one translation unit, and '$0' in another")
+DIAGNOSTIC(39004, Note, fieldTypeMisMatch, "type of field '$0' is declared as '$1' in one translation unit, and '$2' in another")
+DIAGNOSTIC(39005, Note, fieldDeclarationsDontMatch, "type '$0' is declared with different fields in each translation unit")
+DIAGNOSTIC(39006, Note, usedInDeclarationOf, "used in declaration of '$0'")
+
+DIAGNOSTIC(39007, Error, unknownRegisterClass, "unknown register class: '$0'")
+DIAGNOSTIC(39008, Error, expectedARegisterIndex, "expected a register index after '$0'")
+DIAGNOSTIC(39009, Error, expectedSpace, "expected 'space', got '$0'")
+DIAGNOSTIC(39010, Error, expectedSpaceIndex, "expected a register space index after 'space'")
+DIAGNOSTIC(39011, Error, componentMaskNotSupported, "explicit register component masks are not yet supported in Slang")
+DIAGNOSTIC(39012, Error, packOffsetNotSupported, "explicit 'packoffset' bindings are not yet supported in Slang")
+
//
// 4xxxx - IL code generation.
//
diff --git a/source/slang/diagnostics.cpp b/source/slang/diagnostics.cpp
index 03acf50dc..77473b95f 100644
--- a/source/slang/diagnostics.cpp
+++ b/source/slang/diagnostics.cpp
@@ -39,6 +39,12 @@ void printDiagnosticArg(StringBuilder& sb, Slang::String const& str)
sb << str;
}
+void printDiagnosticArg(StringBuilder& sb, Slang::UnownedStringSlice const& str)
+{
+ sb.append(str);
+}
+
+
void printDiagnosticArg(StringBuilder& sb, Name* name)
{
sb << getText(name);
diff --git a/source/slang/diagnostics.h b/source/slang/diagnostics.h
index 9bc3b3d8c..a12de03e4 100644
--- a/source/slang/diagnostics.h
+++ b/source/slang/diagnostics.h
@@ -77,6 +77,7 @@ namespace Slang
void printDiagnosticArg(StringBuilder& sb, int val);
void printDiagnosticArg(StringBuilder& sb, UInt val);
void printDiagnosticArg(StringBuilder& sb, Slang::String const& str);
+ void printDiagnosticArg(StringBuilder& sb, Slang::UnownedStringSlice const& str);
void printDiagnosticArg(StringBuilder& sb, Name* name);
void printDiagnosticArg(StringBuilder& sb, Decl* decl);
void printDiagnosticArg(StringBuilder& sb, Type* type);
diff --git a/source/slang/modifier-defs.h b/source/slang/modifier-defs.h
index 6212a244e..f9b3b6675 100644
--- a/source/slang/modifier-defs.h
+++ b/source/slang/modifier-defs.h
@@ -164,7 +164,9 @@ SYNTAX_CLASS(HLSLLayoutSemantic, HLSLSemantic)
END_SYNTAX_CLASS()
// An HLSL `register` semantic
-SIMPLE_SYNTAX_CLASS(HLSLRegisterSemantic, HLSLLayoutSemantic)
+SYNTAX_CLASS(HLSLRegisterSemantic, HLSLLayoutSemantic)
+ FIELD(Token, spaceName)
+END_SYNTAX_CLASS()
// TODO(tfoley): `packoffset`
SIMPLE_SYNTAX_CLASS(HLSLPackOffsetSemantic, HLSLLayoutSemantic)
diff --git a/source/slang/parameter-binding.cpp b/source/slang/parameter-binding.cpp
index 4378cb06b..e0cc26f2b 100644
--- a/source/slang/parameter-binding.cpp
+++ b/source/slang/parameter-binding.cpp
@@ -288,8 +288,34 @@ struct LayoutSemanticInfo
// TODO: need to deal with component-granularity binding...
};
+static bool isDigit(char c)
+{
+ return (c >= '0') && (c <= '9');
+}
+
+/// Given a string that specifies a name and index (e.g., `COLOR0`),
+/// split it into slices for the name part and the index part.
+static void splitNameAndIndex(
+ String const& text,
+ UnownedStringSlice& outName,
+ UnownedStringSlice& outDigits)
+{
+ char const* nameBegin = text.begin();
+ char const* digitsEnd = text.end();
+
+ char const* nameEnd = digitsEnd;
+ while( nameEnd != nameBegin && isDigit(*(nameEnd - 1)) )
+ {
+ nameEnd--;
+ }
+ char const* digitsBegin = nameEnd;
+
+ outName = UnownedStringSlice(nameBegin, nameEnd);
+ outDigits = UnownedStringSlice(digitsBegin, digitsEnd);
+}
+
LayoutSemanticInfo ExtractLayoutSemanticInfo(
- ParameterBindingContext* /*context*/,
+ ParameterBindingContext* context,
HLSLLayoutSemantic* semantic)
{
LayoutSemanticInfo info;
@@ -297,12 +323,31 @@ LayoutSemanticInfo ExtractLayoutSemanticInfo(
info.index = 0;
info.kind = LayoutResourceKind::None;
- auto registerName = semantic->registerName.Content;
+ String registerName = semantic->registerName.Content;
if (registerName.Length() == 0)
return info;
+ // The register name is expected to be in the form:
+ //
+ // identifier-char+ digit+
+ //
+ // where the identifier characters name a "register class"
+ // and the digits identify a register index within that class.
+ //
+ // We are going to split the string the user gave us
+ // into these constituent parts:
+ //
+ UnownedStringSlice registerClassName;
+ UnownedStringSlice registerIndexDigits;
+ splitNameAndIndex(registerName, registerClassName, registerIndexDigits);
+
+ // All of the register classes we support are single ASCII characters,
+ // so we really just care about the first byte, but we want to be
+ // careful and only look at it if the register class name is one
+ // byte long.
+ char registerClassChar = registerClassName.size() == 1 ? *registerClassName.begin() : 0;
LayoutResourceKind kind = LayoutResourceKind::None;
- switch (registerName[0])
+ switch (registerClassChar)
{
case 'b':
kind = LayoutResourceKind::ConstantBuffer;
@@ -321,29 +366,59 @@ LayoutSemanticInfo ExtractLayoutSemanticInfo(
break;
default:
- // TODO: issue an error here!
+ getSink(context)->diagnose(semantic->registerName, Diagnostics::unknownRegisterClass, registerClassName);
return info;
}
- // TODO: need to parse and handle `space` binding
- int space = 0;
+ // For a `register` semantic, the register index is not optional (unlike
+ // how it works for varying input/output semantics).
+ if( registerIndexDigits.size() == 0 )
+ {
+ getSink(context)->diagnose(semantic->registerName, Diagnostics::expectedARegisterIndex, registerClassName);
+ }
UInt index = 0;
- for (UInt ii = 1; ii < registerName.Length(); ++ii)
+ for(auto c : registerIndexDigits)
{
- int c = registerName[ii];
- if (c >= '0' && c <= '9')
- {
- index = index * 10 + (c - '0');
- }
- else
+ SLANG_ASSERT(isDigit(c));
+ index = index * 10 + (c - '0');
+ }
+
+
+ UInt space = 0;
+ if( auto registerSemantic = dynamic_cast<HLSLRegisterSemantic*>(semantic) )
+ {
+ auto const& spaceName = registerSemantic->spaceName.Content;
+ if(spaceName.Length() != 0)
{
- // TODO: issue an error here!
- return info;
+ UnownedStringSlice spaceSpelling;
+ UnownedStringSlice spaceDigits;
+ splitNameAndIndex(spaceName, spaceSpelling, spaceDigits);
+
+ if( spaceSpelling != UnownedTerminatedStringSlice("space") )
+ {
+ getSink(context)->diagnose(semantic->registerName, Diagnostics::expectedSpace, spaceSpelling);
+ }
+ else if( spaceDigits.size() == 0 )
+ {
+ getSink(context)->diagnose(semantic->registerName, Diagnostics::expectedSpaceIndex);
+ }
+ else
+ {
+ for(auto c : spaceDigits)
+ {
+ SLANG_ASSERT(isDigit(c));
+ space = space * 10 + (c - '0');
+ }
+ }
}
}
// TODO: handle component mask part of things...
+ if( semantic->componentMask.Content.Length() != 0 )
+ {
+ getSink(context)->diagnose(semantic->componentMask, Diagnostics::componentMaskNotSupported);
+ }
info.kind = kind;
info.index = (int) index;
diff --git a/source/slang/parser.cpp b/source/slang/parser.cpp
index 5d1b254d7..ab95be5ac 100644
--- a/source/slang/parser.cpp
+++ b/source/slang/parser.cpp
@@ -1835,24 +1835,76 @@ namespace Slang
}
}
- //
- // layout-semantic ::= (register | packoffset) '(' register-name component-mask? ')'
- // register-name ::= identifier
- // component-mask ::= '.' identifier
- //
- static void ParseHLSLLayoutSemantic(
- Parser* parser,
- HLSLLayoutSemantic* semantic)
+ /// Parse the "register name" part of a `register` or `packoffset` semantic.
+ ///
+ /// The syntax matched is:
+ ///
+ /// register-name-and-component-mask ::= register-name component-mask?
+ /// register-name ::= identifier
+ /// component-mask ::= '.' identifier
+ ///
+ static void parseHLSLRegisterNameAndOptionalComponentMask(
+ Parser* parser,
+ HLSLLayoutSemantic* semantic)
{
- semantic->name = parser->ReadToken(TokenType::Identifier);
-
- parser->ReadToken(TokenType::LParent);
semantic->registerName = parser->ReadToken(TokenType::Identifier);
if (AdvanceIf(parser, TokenType::Dot))
{
semantic->componentMask = parser->ReadToken(TokenType::Identifier);
}
+ }
+
+ /// Parse an HLSL `register` semantic.
+ ///
+ /// The syntax matched is:
+ ///
+ /// register-semantic ::= 'register' '(' register-name-and-component-mask register-space? ')'
+ /// register-space ::= ',' identifier
+ ///
+ static void parseHLSLRegisterSemantic(
+ Parser* parser,
+ HLSLRegisterSemantic* semantic)
+ {
+ // Read the `register` keyword
+ semantic->name = parser->ReadToken(TokenType::Identifier);
+
+ // Expect a parenthized list of additional arguments
+ parser->ReadToken(TokenType::LParent);
+
+ // First argument is a required register name and optional component mask
+ parseHLSLRegisterNameAndOptionalComponentMask(parser, semantic);
+
+ // Second argument is an optional register space
+ if(AdvanceIf(parser, TokenType::Comma))
+ {
+ semantic->spaceName = parser->ReadToken(TokenType::Identifier);
+ }
+
+ parser->ReadToken(TokenType::RParent);
+ }
+
+ /// Parse an HLSL `packoffset` semantic.
+ ///
+ /// The syntax matched is:
+ ///
+ /// packoffset-semantic ::= 'packoffset' '(' register-name-and-component-mask ')'
+ ///
+ static void parseHLSLPackOffsetSemantic(
+ Parser* parser,
+ HLSLPackOffsetSemantic* semantic)
+ {
+ // Read the `packoffset` keyword
+ semantic->name = parser->ReadToken(TokenType::Identifier);
+
+ // Expect a parenthized list of additional arguments
+ parser->ReadToken(TokenType::LParent);
+
+ // First and only argument is a required register name and optional component mask
+ parseHLSLRegisterNameAndOptionalComponentMask(parser, semantic);
+
parser->ReadToken(TokenType::RParent);
+
+ parser->sink->diagnose(semantic, Diagnostics::packOffsetNotSupported);
}
//
@@ -1864,18 +1916,21 @@ namespace Slang
if (parser->LookAheadToken("register"))
{
RefPtr<HLSLRegisterSemantic> semantic = new HLSLRegisterSemantic();
- ParseHLSLLayoutSemantic(parser, semantic.Ptr());
+ parser->FillPosition(semantic);
+ parseHLSLRegisterSemantic(parser, semantic.Ptr());
return semantic;
}
else if (parser->LookAheadToken("packoffset"))
{
RefPtr<HLSLPackOffsetSemantic> semantic = new HLSLPackOffsetSemantic();
- ParseHLSLLayoutSemantic(parser, semantic.Ptr());
+ parser->FillPosition(semantic);
+ parseHLSLPackOffsetSemantic(parser, semantic.Ptr());
return semantic;
}
else if (parser->LookAheadToken(TokenType::Identifier))
{
RefPtr<HLSLSimpleSemantic> semantic = new HLSLSimpleSemantic();
+ parser->FillPosition(semantic);
semantic->name = parser->ReadToken(TokenType::Identifier);
return semantic;
}
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"
+ }
+ }
+ ]
+}
+}