Commit 82d6baf8 by John Kessenich

HLSL: Implement packoffset production.

parent 1936eebe
......@@ -21,9 +21,9 @@ gl_FragCoord origin is upper left
0:? Linker Objects
0:? 'AmbientColor' (global 4-component vector of float)
0:? 'ff1' (global bool Face)
0:? 'ff2' (global 4-component vector of float)
0:? 'ff3' (global 4-component vector of float)
0:? 'ff4' (global 4-component vector of float FragCoord)
0:? 'ff2' (layout(offset=4 ) global 4-component vector of float)
0:? 'ff3' (layout(offset=4 ) global 4-component vector of float)
0:? 'ff4' (layout(offset=4 ) global 4-component vector of float FragCoord)
Linked fragment stage:
......@@ -51,9 +51,9 @@ gl_FragCoord origin is upper left
0:? Linker Objects
0:? 'AmbientColor' (global 4-component vector of float)
0:? 'ff1' (global bool Face)
0:? 'ff2' (global 4-component vector of float)
0:? 'ff3' (global 4-component vector of float)
0:? 'ff4' (global 4-component vector of float FragCoord)
0:? 'ff2' (layout(offset=4 ) global 4-component vector of float)
0:? 'ff3' (layout(offset=4 ) global 4-component vector of float)
0:? 'ff4' (layout(offset=4 ) global 4-component vector of float FragCoord)
// Module Version 10000
// Generated by (magic number): 80001
......@@ -74,6 +74,9 @@ gl_FragCoord origin is upper left
Name 28 "ff3"
Name 29 "ff4"
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
2: TypeVoid
3: TypeFunction 2
......
......@@ -14,8 +14,8 @@ gl_FragCoord origin is upper left
0:37 's2' (global structure{temp 4-component vector of float i})
0:37 Constant:
0:37 0 (const int)
0:37 ff4: direct index for structure (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 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, 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 7 (const int)
0:39 Branch: Return with expression
......@@ -23,7 +23,7 @@ gl_FragCoord origin is upper left
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:? '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:
......@@ -44,8 +44,8 @@ gl_FragCoord origin is upper left
0:37 's2' (global structure{temp 4-component vector of float i})
0:37 Constant:
0:37 0 (const int)
0:37 ff4: direct index for structure (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 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, 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 7 (const int)
0:39 Branch: Return with expression
......@@ -53,7 +53,7 @@ gl_FragCoord origin is upper left
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:? '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
// Generated by (magic number): 80001
......
......@@ -13,7 +13,13 @@ cbuffer cbufName : register(b2) {
tbuffer tbufName : register(b8) {
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
......
......@@ -3,4 +3,4 @@
// For the date, it uses the current date (when then script is run).
#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)
expected("(");
return;
}
acceptTokenClass(EHTokIdentifier);
acceptTokenClass(EHTokDot);
acceptTokenClass(EHTokIdentifier);
HlslToken locationToken;
if (! acceptIdentifier(locationToken)) {
expected("c[subcomponent][.component]");
return;
}
HlslToken componentToken;
if (acceptTokenClass(EHTokDot)) {
if (! acceptIdentifier(componentToken)) {
expected("component");
return;
}
}
if (! acceptTokenClass(EHTokRightParen)) {
expected(")");
break;
}
// TODO: process the packoffset information
// c1.y means component y of location slot 1
parseContext.handlePackOffset(locationToken.loc, type, *locationToken.string, componentToken.string);
} else if (! acceptIdentifier(idToken)) {
expected("semantic or packoffset or register");
return;
......
......@@ -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.
//
void HlslParseContext::assignError(const TSourceLoc& loc, const char* op, TString left, TString right)
......
......@@ -95,6 +95,7 @@ public:
void builtInOpCheck(const TSourceLoc&, const TFunction&, TIntermOperator&);
TFunction* handleConstructorCall(const TSourceLoc&, const TType&);
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);
......
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