Commit 82d6baf8 by John Kessenich

HLSL: Implement packoffset production.

parent 1936eebe
...@@ -21,9 +21,9 @@ gl_FragCoord origin is upper left ...@@ -21,9 +21,9 @@ gl_FragCoord origin is upper left
0:? Linker Objects 0:? Linker Objects
0:? 'AmbientColor' (global 4-component vector of float) 0:? 'AmbientColor' (global 4-component vector of float)
0:? 'ff1' (global bool Face) 0:? 'ff1' (global bool Face)
0:? 'ff2' (global 4-component vector of float) 0:? 'ff2' (layout(offset=4 ) global 4-component vector of float)
0:? 'ff3' (global 4-component vector of float) 0:? 'ff3' (layout(offset=4 ) global 4-component vector of float)
0:? 'ff4' (global 4-component vector of float FragCoord) 0:? 'ff4' (layout(offset=4 ) global 4-component vector of float FragCoord)
Linked fragment stage: Linked fragment stage:
...@@ -51,9 +51,9 @@ gl_FragCoord origin is upper left ...@@ -51,9 +51,9 @@ gl_FragCoord origin is upper left
0:? Linker Objects 0:? Linker Objects
0:? 'AmbientColor' (global 4-component vector of float) 0:? 'AmbientColor' (global 4-component vector of float)
0:? 'ff1' (global bool Face) 0:? 'ff1' (global bool Face)
0:? 'ff2' (global 4-component vector of float) 0:? 'ff2' (layout(offset=4 ) global 4-component vector of float)
0:? 'ff3' (global 4-component vector of float) 0:? 'ff3' (layout(offset=4 ) global 4-component vector of float)
0:? 'ff4' (global 4-component vector of float FragCoord) 0:? 'ff4' (layout(offset=4 ) global 4-component vector of float FragCoord)
// Module Version 10000 // Module Version 10000
// Generated by (magic number): 80001 // Generated by (magic number): 80001
...@@ -74,6 +74,9 @@ gl_FragCoord origin is upper left ...@@ -74,6 +74,9 @@ gl_FragCoord origin is upper left
Name 28 "ff3" Name 28 "ff3"
Name 29 "ff4" Name 29 "ff4"
Decorate 26(ff1) BuiltIn FrontFacing Decorate 26(ff1) BuiltIn FrontFacing
Decorate 27(ff2) Offset 4
Decorate 28(ff3) Offset 4
Decorate 29(ff4) Offset 4
Decorate 29(ff4) BuiltIn FragCoord Decorate 29(ff4) BuiltIn FragCoord
2: TypeVoid 2: TypeVoid
3: TypeFunction 2 3: TypeFunction 2
......
...@@ -14,8 +14,8 @@ gl_FragCoord origin is upper left ...@@ -14,8 +14,8 @@ gl_FragCoord origin is upper left
0:37 's2' (global structure{temp 4-component vector of float i}) 0:37 's2' (global structure{temp 4-component vector of float i})
0:37 Constant: 0:37 Constant:
0:37 0 (const int) 0:37 0 (const int)
0:37 ff4: direct index for structure (temp 4-component vector of float FragCoord) 0:37 ff4: direct index for structure (layout(offset=4 ) temp 4-component vector of float FragCoord)
0:37 's4' (global structure{smooth in 4-component vector of float a, flat temp bool b, centroid noperspective temp 1-component vector of float c, centroid sample temp 2-component vector of float d, temp bool Face ff1, temp bool ff2, temp bool ff3, temp 4-component vector of float FragCoord ff4}) 0:37 's4' (global structure{smooth in 4-component vector of float a, flat temp bool b, centroid noperspective temp 1-component vector of float c, centroid sample temp 2-component vector of float d, temp bool Face ff1, layout(offset=4 ) temp bool ff2, layout(offset=4 ) temp bool ff3, layout(offset=4 ) temp 4-component vector of float FragCoord ff4})
0:37 Constant: 0:37 Constant:
0:37 7 (const int) 0:37 7 (const int)
0:39 Branch: Return with expression 0:39 Branch: Return with expression
...@@ -23,7 +23,7 @@ gl_FragCoord origin is upper left ...@@ -23,7 +23,7 @@ gl_FragCoord origin is upper left
0:? Linker Objects 0:? Linker Objects
0:? 's1' (global structure{temp bool b, temp bool c, temp 4-component vector of float a, temp 4-component vector of float d}) 0:? 's1' (global structure{temp bool b, temp bool c, temp 4-component vector of float a, temp 4-component vector of float d})
0:? 's2' (global structure{temp 4-component vector of float i}) 0:? 's2' (global structure{temp 4-component vector of float i})
0:? 's4' (global structure{smooth in 4-component vector of float a, flat temp bool b, centroid noperspective temp 1-component vector of float c, centroid sample temp 2-component vector of float d, temp bool Face ff1, temp bool ff2, temp bool ff3, temp 4-component vector of float FragCoord ff4}) 0:? 's4' (global structure{smooth in 4-component vector of float a, flat temp bool b, centroid noperspective temp 1-component vector of float c, centroid sample temp 2-component vector of float d, temp bool Face ff1, layout(offset=4 ) temp bool ff2, layout(offset=4 ) temp bool ff3, layout(offset=4 ) temp 4-component vector of float FragCoord ff4})
Linked fragment stage: Linked fragment stage:
...@@ -44,8 +44,8 @@ gl_FragCoord origin is upper left ...@@ -44,8 +44,8 @@ gl_FragCoord origin is upper left
0:37 's2' (global structure{temp 4-component vector of float i}) 0:37 's2' (global structure{temp 4-component vector of float i})
0:37 Constant: 0:37 Constant:
0:37 0 (const int) 0:37 0 (const int)
0:37 ff4: direct index for structure (temp 4-component vector of float FragCoord) 0:37 ff4: direct index for structure (layout(offset=4 ) temp 4-component vector of float FragCoord)
0:37 's4' (global structure{smooth in 4-component vector of float a, flat temp bool b, centroid noperspective temp 1-component vector of float c, centroid sample temp 2-component vector of float d, temp bool Face ff1, temp bool ff2, temp bool ff3, temp 4-component vector of float FragCoord ff4}) 0:37 's4' (global structure{smooth in 4-component vector of float a, flat temp bool b, centroid noperspective temp 1-component vector of float c, centroid sample temp 2-component vector of float d, temp bool Face ff1, layout(offset=4 ) temp bool ff2, layout(offset=4 ) temp bool ff3, layout(offset=4 ) temp 4-component vector of float FragCoord ff4})
0:37 Constant: 0:37 Constant:
0:37 7 (const int) 0:37 7 (const int)
0:39 Branch: Return with expression 0:39 Branch: Return with expression
...@@ -53,7 +53,7 @@ gl_FragCoord origin is upper left ...@@ -53,7 +53,7 @@ gl_FragCoord origin is upper left
0:? Linker Objects 0:? Linker Objects
0:? 's1' (global structure{temp bool b, temp bool c, temp 4-component vector of float a, temp 4-component vector of float d}) 0:? 's1' (global structure{temp bool b, temp bool c, temp 4-component vector of float a, temp 4-component vector of float d})
0:? 's2' (global structure{temp 4-component vector of float i}) 0:? 's2' (global structure{temp 4-component vector of float i})
0:? 's4' (global structure{smooth in 4-component vector of float a, flat temp bool b, centroid noperspective temp 1-component vector of float c, centroid sample temp 2-component vector of float d, temp bool Face ff1, temp bool ff2, temp bool ff3, temp 4-component vector of float FragCoord ff4}) 0:? 's4' (global structure{smooth in 4-component vector of float a, flat temp bool b, centroid noperspective temp 1-component vector of float c, centroid sample temp 2-component vector of float d, temp bool Face ff1, layout(offset=4 ) temp bool ff2, layout(offset=4 ) temp bool ff3, layout(offset=4 ) temp 4-component vector of float FragCoord ff4})
// Module Version 10000 // Module Version 10000
// Generated by (magic number): 80001 // Generated by (magic number): 80001
......
...@@ -13,7 +13,13 @@ cbuffer cbufName : register(b2) { ...@@ -13,7 +13,13 @@ cbuffer cbufName : register(b2) {
tbuffer tbufName : register(b8) { tbuffer tbufName : register(b8) {
float4 v4 : packoffset(c1); float4 v4 : packoffset(c1);
int i4 : packoffset(c3); int i4 : packoffset(c3);
float f1 : packoffset(c3.w);
float f3 : packoffset(c4.x);
float f4 : packoffset(c4.y);
float f5 : packoffset(c4.z);
float f6 : packoffset(c);
float f7;
}; };
float4 PixelShaderFunction(float4 input) : COLOR0 float4 PixelShaderFunction(float4 input) : COLOR0
......
...@@ -3,4 +3,4 @@ ...@@ -3,4 +3,4 @@
// For the date, it uses the current date (when then script is run). // For the date, it uses the current date (when then script is run).
#define GLSLANG_REVISION "SPIRV99.1362" #define GLSLANG_REVISION "SPIRV99.1362"
#define GLSLANG_DATE "28-Jul-2016" #define GLSLANG_DATE "29-Jul-2016"
...@@ -2537,15 +2537,23 @@ void HlslGrammar::acceptPostDecls(TType& type) ...@@ -2537,15 +2537,23 @@ void HlslGrammar::acceptPostDecls(TType& type)
expected("("); expected("(");
return; return;
} }
acceptTokenClass(EHTokIdentifier); HlslToken locationToken;
acceptTokenClass(EHTokDot); if (! acceptIdentifier(locationToken)) {
acceptTokenClass(EHTokIdentifier); expected("c[subcomponent][.component]");
return;
}
HlslToken componentToken;
if (acceptTokenClass(EHTokDot)) {
if (! acceptIdentifier(componentToken)) {
expected("component");
return;
}
}
if (! acceptTokenClass(EHTokRightParen)) { if (! acceptTokenClass(EHTokRightParen)) {
expected(")"); expected(")");
break; break;
} }
// TODO: process the packoffset information parseContext.handlePackOffset(locationToken.loc, type, *locationToken.string, componentToken.string);
// c1.y means component y of location slot 1
} else if (! acceptIdentifier(idToken)) { } else if (! acceptIdentifier(idToken)) {
expected("semantic or packoffset or register"); expected("semantic or packoffset or register");
return; return;
......
...@@ -2135,6 +2135,46 @@ void HlslParseContext::handleSemantic(TType& type, const TString& semantic) ...@@ -2135,6 +2135,46 @@ void HlslParseContext::handleSemantic(TType& type, const TString& semantic)
} }
// //
// Handle seeing something like ": packoffset( c[Subcomponent][.component] )"
//
// 'location' has the "c[Subcomponent]" part.
// 'component' points to the "component" part, or nullptr if not present.
//
void HlslParseContext::handlePackOffset(const TSourceLoc& loc, TType& type, const glslang::TString& location,
const glslang::TString* component)
{
if (location.size() == 0 || location[0] != 'c') {
error(loc, "expected 'c'", "packoffset", "");
return;
}
if (location.size() == 1)
return;
if (! isdigit(location[1])) {
error(loc, "expected number after 'c'", "packoffset", "");
return;
}
type.getQualifier().layoutOffset = 16 * atoi(location.substr(1, location.size()).c_str());
if (component) {
int componentOffset = 0;
switch ((*component)[0]) {
case 'x': componentOffset = 0; break;
case 'y': componentOffset = 4; break;
case 'z': componentOffset = 8; break;
case 'w': componentOffset = 12; break;
default:
componentOffset = -1;
break;
}
if (componentOffset < 0 || component->size() > 1) {
error(loc, "expected {x, y, z, w} for component", "packoffset", "");
return;
}
type.getQualifier().layoutOffset += componentOffset;
}
}
//
// Same error message for all places assignments don't work. // Same error message for all places assignments don't work.
// //
void HlslParseContext::assignError(const TSourceLoc& loc, const char* op, TString left, TString right) void HlslParseContext::assignError(const TSourceLoc& loc, const char* op, TString left, TString right)
......
...@@ -95,6 +95,7 @@ public: ...@@ -95,6 +95,7 @@ public:
void builtInOpCheck(const TSourceLoc&, const TFunction&, TIntermOperator&); void builtInOpCheck(const TSourceLoc&, const TFunction&, TIntermOperator&);
TFunction* handleConstructorCall(const TSourceLoc&, const TType&); TFunction* handleConstructorCall(const TSourceLoc&, const TType&);
void handleSemantic(TType& type, const TString& semantic); void handleSemantic(TType& type, const TString& semantic);
void handlePackOffset(const TSourceLoc&, TType& type, const glslang::TString& location, const glslang::TString* component);
TIntermAggregate* handleSamplerTextureCombine(const TSourceLoc& loc, TIntermTyped* argTex, TIntermTyped* argSampler); TIntermAggregate* handleSamplerTextureCombine(const TSourceLoc& loc, TIntermTyped* argTex, TIntermTyped* argSampler);
......
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