Commit 2fcdd64e by John Kessenich

HLSL: Remove support for named tbuffer/cbuffer. Fixes #939.

parent 054378d9
...@@ -2,26 +2,19 @@ hlsl.reflection.vert ...@@ -2,26 +2,19 @@ hlsl.reflection.vert
Uniform reflection: Uniform reflection:
anonMember3: offset 80, type 8b52, size 1, index 0, binding -1 anonMember3: offset 80, type 8b52, size 1, index 0, binding -1
s.a: offset 0, type 1404, size 1, index 1, binding -1 s.a: offset 0, type 1404, size 1, index 1, binding -1
ablock.scalar: offset 12, type 1404, size 1, index 2, binding -1
m23: offset 16, type 8b67, size 1, index 0, binding -1 m23: offset 16, type 8b67, size 1, index 0, binding -1
scalarAfterm23: offset 48, type 1404, size 1, index 0, binding -1 scalarAfterm23: offset 48, type 1404, size 1, index 0, binding -1
c_m23: offset 16, type 8b67, size 1, index 3, binding -1 c_m23: offset 16, type 8b67, size 1, index 2, binding -1
c_scalarAfterm23: offset 48, type 1404, size 1, index 3, binding -1 c_scalarAfterm23: offset 48, type 1404, size 1, index 2, binding -1
scalarBeforeArray: offset 96, type 1404, size 1, index 0, binding -1 scalarBeforeArray: offset 96, type 1404, size 1, index 0, binding -1
floatArray: offset 112, type 1406, size 5, index 0, binding -1 floatArray: offset 112, type 1406, size 5, index 0, binding -1
scalarAfterArray: offset 192, type 1404, size 1, index 0, binding -1 scalarAfterArray: offset 192, type 1404, size 1, index 0, binding -1
ablock.memfloat2: offset 48, type 8b50, size 1, index 2, binding -1 m22: offset 208, type 8b5a, size 9, index 0, binding -1
ablock.memf1: offset 56, type 1406, size 1, index 2, binding -1
ablock.memf2: offset 60, type 8b56, size 1, index 2, binding -1
ablock.memf3: offset 64, type 1404, size 1, index 2, binding -1
ablock.memfloat2a: offset 72, type 8b50, size 1, index 2, binding -1
ablock.m22: offset 80, type 8b5a, size 7, index 2, binding -1
dm22: offset 32, type 8b5a, size 4, index 1, binding -1 dm22: offset 32, type 8b5a, size 4, index 1, binding -1
m22: offset 208, type 8b5a, size 3, index 0, binding -1 foo.n1.a: offset 0, type 1406, size 1, index 3, binding -1
nest.foo.n1.a: offset 0, type 1406, size 1, index 4, binding -1 foo.n2.b: offset 16, type 1406, size 1, index 3, binding -1
nest.foo.n2.b: offset 16, type 1406, size 1, index 4, binding -1 foo.n2.c: offset 20, type 1406, size 1, index 3, binding -1
nest.foo.n2.c: offset 20, type 1406, size 1, index 4, binding -1 foo.n2.d: offset 24, type 1406, size 1, index 3, binding -1
nest.foo.n2.d: offset 24, type 1406, size 1, index 4, binding -1
deepA.d2.d1[2].va: offset 376, type 8b50, size 2, index 1, binding -1 deepA.d2.d1[2].va: offset 376, type 8b50, size 2, index 1, binding -1
deepB.d2.d1.va: offset 984, type 8b50, size 2, index 1, binding -1 deepB.d2.d1.va: offset 984, type 8b50, size 2, index 1, binding -1
deepB.d2.d1[0].va: offset 984, type 8b50, size 2, index 1, binding -1 deepB.d2.d1[0].va: offset 984, type 8b50, size 2, index 1, binding -1
...@@ -61,19 +54,18 @@ deepD[1].d2.d1[2].b: offset 2480, type 8b56, size 1, index 1, binding -1 ...@@ -61,19 +54,18 @@ deepD[1].d2.d1[2].b: offset 2480, type 8b56, size 1, index 1, binding -1
deepD[1].d2.d1[3].va: offset 2480, type 8b50, size 3, index 1, binding -1 deepD[1].d2.d1[3].va: offset 2480, type 8b50, size 3, index 1, binding -1
deepD[1].d2.d1[3].b: offset 2480, type 8b56, size 1, index 1, binding -1 deepD[1].d2.d1[3].b: offset 2480, type 8b56, size 1, index 1, binding -1
deepD[1].v3: offset 2480, type 8b54, size 1, index 1, binding -1 deepD[1].v3: offset 2480, type 8b54, size 1, index 1, binding -1
arrBl.foo: offset 0, type 1406, size 1, index 5, binding -1 foo1: offset 0, type 1406, size 1, index 4, binding -1
arrBl2.foo: offset 0, type 1406, size 1, index 6, binding -1 foo2: offset 0, type 1406, size 1, index 5, binding -1
anonMember1: offset 0, type 8b51, size 1, index 0, binding -1 anonMember1: offset 0, type 8b51, size 1, index 0, binding -1
uf1: offset 16, type 1406, size 1, index 1, binding -1 uf1: offset 16, type 1406, size 1, index 1, binding -1
Uniform block reflection: Uniform block reflection:
nameless: offset -1, type ffffffff, size 496, index -1, binding -1 nameless: offset -1, type ffffffff, size 496, index -1, binding -1
$Global: offset -1, type ffffffff, size 3088, index -1, binding -1 $Global: offset -1, type ffffffff, size 3088, index -1, binding -1
ablock: offset -1, type ffffffff, size 304, index -1, binding -1
c_nameless: offset -1, type ffffffff, size 96, index -1, binding -1 c_nameless: offset -1, type ffffffff, size 96, index -1, binding -1
nest: offset -1, type ffffffff, size 32, index -1, binding -1 nested: offset -1, type ffffffff, size 32, index -1, binding -1
arrBl: offset -1, type ffffffff, size 4, index -1, binding -1 abl: offset -1, type ffffffff, size 4, index -1, binding -1
arrBl2: offset -1, type ffffffff, size 4, index -1, binding -1 abl2: offset -1, type ffffffff, size 4, index -1, binding -1
Vertex attribute reflection: Vertex attribute reflection:
attributeFloat: offset 0, type 1406, size 0, index 0, binding -1 attributeFloat: offset 0, type 1406, size 0, index 0, binding -1
......
cbuffer buf1 { cbuffer buf1 {
float4 v1; float4 v1;
}; }; // extraneous ;
tbuffer buf2 { tbuffer buf2 {
float4 v2; float4 v2;
}; }; // extraneous ;
cbuffer cbufName { cbuffer cbufName {
float4 v3 : packoffset(c0); float4 v3 : packoffset(c0);
int i3 : packoffset(c1.y); int i3 : packoffset(c1.y);
} // no semicolon is okay }
tbuffer tbufName : register(t8) { tbuffer tbufName : register(t8) {
float4 v4 : packoffset(c1); float4 v4 : packoffset(c1);
...@@ -24,9 +24,14 @@ tbuffer tbufName : register(t8) { ...@@ -24,9 +24,14 @@ tbuffer tbufName : register(t8) {
row_major float3x4 m2 : packoffset(c11); row_major float3x4 m2 : packoffset(c11);
column_major float3x4 m3 : packoffset(c15); column_major float3x4 m3 : packoffset(c15);
float3x4 m4 : packoffset(c19); float3x4 m4 : packoffset(c19);
} // no semicolon is okay }
float foo() // float looks like identifier, but can't be part of tbuffer
{
return 1.0;
}
float4 PixelShaderFunction(float4 input : SV_POSITION) : SV_TARGET0 float4 PixelShaderFunction(float4 input : SV_POSITION) : SV_TARGET0
{ {
return input + v1 + v2 + v3 + v4; return (input + v1 + v2 + v3 + v4) * foo();
} }
...@@ -19,27 +19,10 @@ cbuffer c_nameless { ...@@ -19,27 +19,10 @@ cbuffer c_nameless {
float4 c_anonMember3; float4 c_anonMember3;
}; };
cbuffer named {
float3 deadMember1;
int scalar;
float4 member2;
float4 member3;
float2 memfloat2;
float memf1;
bool memf2;
int memf3;
float2 memfloat2a;
float2x2 m22[7];
} ablock;
cbuffer namelessdead { cbuffer namelessdead {
int a; int a;
}; };
cbuffer namedDead {
int b;
} bblock;
struct N1 { struct N1 {
float a; float a;
}; };
...@@ -57,7 +40,7 @@ struct N3 { ...@@ -57,7 +40,7 @@ struct N3 {
cbuffer nested { cbuffer nested {
N3 foo; N3 foo;
} nest; }
struct TS { struct TS {
int a; int a;
...@@ -89,16 +72,12 @@ struct deep3 { ...@@ -89,16 +72,12 @@ struct deep3 {
int3 v3; int3 v3;
}; };
uniform deep3 deepA[2], deepB[2], deepC[3], deepD[2]; uniform deep3 deepA[2], deepB[2], deepC[3], deepD[2];
const bool control = true; const bool control = true;
void deadFunction() void deadFunction()
{ {
float3 v3 = ablock.deadMember1;
float4 v = anonDeadMember2; float4 v = anonDeadMember2;
float f = ufDead4; float f = ufDead4;
} }
...@@ -110,12 +89,12 @@ void liveFunction2() ...@@ -110,12 +89,12 @@ void liveFunction2()
} }
tbuffer abl { tbuffer abl {
float foo; float foo1;
} arrBl; }
tbuffer abl2 { tbuffer abl2 {
float foo; float foo2;
} arrBl2; }
void flizv(in float attributeFloat, in float2 attributeFloat2, in float3 attributeFloat3, in float4 attributeFloat4, in float4x4 attributeMat4) void flizv(in float attributeFloat, in float2 attributeFloat2, in float3 attributeFloat3, in float4 attributeFloat4, in float4x4 attributeMat4)
{ {
...@@ -130,22 +109,16 @@ void flizv(in float attributeFloat, in float2 attributeFloat2, in float3 attribu ...@@ -130,22 +109,16 @@ void flizv(in float attributeFloat, in float2 attributeFloat2, in float3 attribu
liveFunction2(); liveFunction2();
f = anonMember3.z; f = anonMember3.z;
f = s.a; f = s.a;
f = ablock.scalar;
f = m23[1].y + scalarAfterm23; f = m23[1].y + scalarAfterm23;
f = c_m23[1].y + c_scalarAfterm23; f = c_m23[1].y + c_scalarAfterm23;
f += scalarBeforeArray; f += scalarBeforeArray;
f += floatArray[2]; f += floatArray[2];
f += floatArray[4]; f += floatArray[4];
f += scalarAfterArray; f += scalarAfterArray;
f += ablock.memfloat2.x; f += m22[i][1][0];
f += ablock.memf1;
f += float(ablock.memf2);
f += ablock.memf3;
f += ablock.memfloat2a.y;
f += ablock.m22[i][1][0];
f += dm22[3][0][1]; f += dm22[3][0][1];
f += m22[2][1].y; f += m22[2][1].y;
f += nest.foo.n1.a + nest.foo.n2.b + nest.foo.n2.c + nest.foo.n2.d; f += foo.n1.a + foo.n2.b + foo.n2.c + foo.n2.d;
f += deepA[i].d2.d1[2].va[1].x; f += deepA[i].d2.d1[2].va[1].x;
f += deepB[1].d2.d1[i].va[1].x; f += deepB[1].d2.d1[i].va[1].x;
f += deepB[i].d2.d1[i].va[1].x; f += deepB[i].d2.d1[i].va[1].x;
...@@ -154,8 +127,8 @@ void flizv(in float attributeFloat, in float2 attributeFloat2, in float3 attribu ...@@ -154,8 +127,8 @@ void flizv(in float attributeFloat, in float2 attributeFloat2, in float3 attribu
} else } else
f = ufDead3; f = ufDead3;
f += arrBl.foo + arrBl.foo; f += foo1 + foo2;
f += arrBl2.foo; f += foo2;
f += attributeFloat; f += attributeFloat;
f += attributeFloat2.x; f += attributeFloat2.x;
......
...@@ -371,10 +371,16 @@ bool HlslGrammar::acceptDeclaration(TIntermNode*& nodeList) ...@@ -371,10 +371,16 @@ bool HlslGrammar::acceptDeclaration(TIntermNode*& nodeList)
// if (acceptSamplerDeclarationDX9(declaredType)) // if (acceptSamplerDeclarationDX9(declaredType))
// return true; // return true;
bool forbidDeclarators = (peekTokenClass(EHTokCBuffer) || peekTokenClass(EHTokTBuffer));
// fully_specified_type // fully_specified_type
if (! acceptFullySpecifiedType(declaredType, nodeList)) if (! acceptFullySpecifiedType(declaredType, nodeList))
return false; return false;
// cbuffer and tbuffer end with the closing '}'.
// No semicolon is included.
if (forbidDeclarators)
return true;
// declarator_list // declarator_list
// : declarator // : declarator
// : identifier // : identifier
...@@ -489,7 +495,7 @@ bool HlslGrammar::acceptDeclaration(TIntermNode*& nodeList) ...@@ -489,7 +495,7 @@ bool HlslGrammar::acceptDeclaration(TIntermNode*& nodeList)
// COMMA // COMMA
if (acceptTokenClass(EHTokComma)) if (acceptTokenClass(EHTokComma))
declarator_list = true; declarator_list = true;
} }
// The top-level initializer node is a sequence. // The top-level initializer node is a sequence.
if (initializers != nullptr) if (initializers != nullptr)
...@@ -501,18 +507,15 @@ bool HlslGrammar::acceptDeclaration(TIntermNode*& nodeList) ...@@ -501,18 +507,15 @@ bool HlslGrammar::acceptDeclaration(TIntermNode*& nodeList)
else else
nodeList = initializers; nodeList = initializers;
// SEMICOLON(optional for cbuffer/tbuffer) // SEMICOLON
if (! acceptTokenClass(EHTokSemicolon)) { if (! acceptTokenClass(EHTokSemicolon)) {
// This may have been a false detection of what appeared to be a declaration, but
// was actually an assignment such as "float = 4", where "float" is an identifier.
// We put the token back to let further parsing happen for cases where that may
// happen. This errors on the side of caution, and mostly triggers the error.
if (peek() == EHTokAssign || peek() == EHTokLeftBracket || peek() == EHTokDot || peek() == EHTokComma) { if (peek() == EHTokAssign || peek() == EHTokLeftBracket || peek() == EHTokDot || peek() == EHTokComma) {
// This may have been a false detection of what appeared to be a declaration, but
// was actually an assignment such as "float = 4", where "float" is an identifier.
// We put the token back to let further parsing happen for cases where that may
// happen. This errors on the side of caution, and mostly triggers the error.
recedeToken(); recedeToken();
return false; return false;
} else if (declaredType.getBasicType() == EbtBlock) {
// cbuffer, et. al. (but not struct) don't have an ending semicolon
return true;
} else { } else {
expected(";"); expected(";");
return false; return false;
...@@ -1904,10 +1907,10 @@ bool HlslGrammar::acceptStruct(TType& type, TIntermNode*& nodeList) ...@@ -1904,10 +1907,10 @@ bool HlslGrammar::acceptStruct(TType& type, TIntermNode*& nodeList)
bool readonly = false; bool readonly = false;
if (acceptTokenClass(EHTokCBuffer)) { if (acceptTokenClass(EHTokCBuffer)) {
// CBUFFER // CBUFFER
storageQualifier = EvqUniform; storageQualifier = EvqUniform;
} else if (acceptTokenClass(EHTokTBuffer)) { } else if (acceptTokenClass(EHTokTBuffer)) {
// TBUFFER // TBUFFER
storageQualifier = EvqBuffer; storageQualifier = EvqBuffer;
readonly = true; readonly = true;
} else if (! acceptTokenClass(EHTokClass) && ! acceptTokenClass(EHTokStruct)) { } else if (! acceptTokenClass(EHTokClass) && ! acceptTokenClass(EHTokStruct)) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment