Commit 054378d9 by John Kessenich

HLSL: Non-functional: Make test valid HLSL, and related comments/cleanup.

parent e2ff404f
cbuffer { cbuffer buf1 {
float4 v1; float4 v1;
}; };
tbuffer { tbuffer buf2 {
float4 v2; float4 v2;
}; };
cbuffer cbufName : register(b2, space10) { cbuffer cbufName {
float4 v3; float4 v3 : packoffset(c0);
int i3 : packoffset(c1.y); int i3 : packoffset(c1.y);
} // no semicolon is okay } // no semicolon is okay
tbuffer tbufName : register(b8) { tbuffer tbufName : register(t8) {
float4 v4 : packoffset(c1); float4 v4 : packoffset(c1);
int i4 : packoffset(c3); int i4 : packoffset(c3);
float f1 : packoffset(c3.w); float f1 : packoffset(c3.w);
...@@ -19,14 +19,14 @@ tbuffer tbufName : register(b8) { ...@@ -19,14 +19,14 @@ tbuffer tbufName : register(b8) {
float f4 : packoffset(c4.y); float f4 : packoffset(c4.y);
float f5 : packoffset(c4.z); float f5 : packoffset(c4.z);
float f6 : packoffset(c); float f6 : packoffset(c);
float f7; float f7 : packoffset(c8);
float3x4 m1; float3x4 m1 : packoffset(c7);
row_major float3x4 m2; row_major float3x4 m2 : packoffset(c11);
column_major float3x4 m3; column_major float3x4 m3 : packoffset(c15);
float3x4 m4; float3x4 m4 : packoffset(c19);
} // no semicolon is okay } // no semicolon is okay
float4 PixelShaderFunction(float4 input) : COLOR0 float4 PixelShaderFunction(float4 input : SV_POSITION) : SV_TARGET0
{ {
return input + v1 + v2 + v3 + v4; return input + v1 + v2 + v3 + v4;
} }
...@@ -725,7 +725,9 @@ void TReflection::buildCounterIndices() ...@@ -725,7 +725,9 @@ void TReflection::buildCounterIndices()
// Returns false if the input is too malformed to do this. // Returns false if the input is too malformed to do this.
bool TReflection::addStage(EShLanguage stage, const TIntermediate& intermediate) bool TReflection::addStage(EShLanguage stage, const TIntermediate& intermediate)
{ {
if (intermediate.getNumEntryPoints() != 1 || intermediate.isRecursive()) if (intermediate.getTreeRoot() == nullptr ||
intermediate.getNumEntryPoints() != 1 ||
intermediate.isRecursive())
return false; return false;
buildAttributeReflection(stage, intermediate); buildAttributeReflection(stage, intermediate);
......
...@@ -296,7 +296,8 @@ bool HlslGrammar::acceptSamplerDeclarationDX9(TType& /*type*/) ...@@ -296,7 +296,8 @@ bool HlslGrammar::acceptSamplerDeclarationDX9(TType& /*type*/)
// declaration // declaration
// : sampler_declaration_dx9 post_decls SEMICOLON // : sampler_declaration_dx9 post_decls SEMICOLON
// | fully_specified_type declarator_list SEMICOLON(optional for cbuffer/tbuffer) // | fully_specified_type // for cbuffer/tbuffer
// | fully_specified_type declarator_list SEMICOLON // for non cbuffer/tbuffer
// | fully_specified_type identifier function_parameters post_decls compound_statement // function definition // | fully_specified_type identifier function_parameters post_decls compound_statement // function definition
// | fully_specified_type identifier sampler_state post_decls compound_statement // sampler definition // | fully_specified_type identifier sampler_state post_decls compound_statement // sampler definition
// | typedef declaration // | typedef declaration
...@@ -374,7 +375,9 @@ bool HlslGrammar::acceptDeclaration(TIntermNode*& nodeList) ...@@ -374,7 +375,9 @@ bool HlslGrammar::acceptDeclaration(TIntermNode*& nodeList)
if (! acceptFullySpecifiedType(declaredType, nodeList)) if (! acceptFullySpecifiedType(declaredType, nodeList))
return false; return false;
// identifier // declarator_list
// : declarator
// : identifier
HlslToken idToken; HlslToken idToken;
TIntermAggregate* initializers = nullptr; TIntermAggregate* initializers = nullptr;
while (acceptIdentifier(idToken)) { while (acceptIdentifier(idToken)) {
...@@ -483,11 +486,10 @@ bool HlslGrammar::acceptDeclaration(TIntermNode*& nodeList) ...@@ -483,11 +486,10 @@ bool HlslGrammar::acceptDeclaration(TIntermNode*& nodeList)
} }
} }
if (acceptTokenClass(EHTokComma)) { // COMMA
if (acceptTokenClass(EHTokComma))
declarator_list = true; declarator_list = true;
continue;
} }
};
// The top-level initializer node is a sequence. // The top-level initializer node is a sequence.
if (initializers != nullptr) if (initializers != nullptr)
...@@ -1901,18 +1903,19 @@ bool HlslGrammar::acceptStruct(TType& type, TIntermNode*& nodeList) ...@@ -1901,18 +1903,19 @@ bool HlslGrammar::acceptStruct(TType& type, TIntermNode*& nodeList)
TStorageQualifier storageQualifier = EvqTemporary; TStorageQualifier storageQualifier = EvqTemporary;
bool readonly = false; bool readonly = false;
// CBUFFER
if (acceptTokenClass(EHTokCBuffer)) { if (acceptTokenClass(EHTokCBuffer)) {
// CBUFFER
storageQualifier = EvqUniform; storageQualifier = EvqUniform;
// TBUFFER
} else if (acceptTokenClass(EHTokTBuffer)) { } else if (acceptTokenClass(EHTokTBuffer)) {
// TBUFFER
storageQualifier = EvqBuffer; storageQualifier = EvqBuffer;
readonly = true; readonly = true;
} } else if (! acceptTokenClass(EHTokClass) && ! acceptTokenClass(EHTokStruct)) {
// CLASS // Neither CLASS nor STRUCT
// STRUCT
else if (! acceptTokenClass(EHTokClass) && ! acceptTokenClass(EHTokStruct))
return false; return false;
}
// Now known to be one of CBUFFER, TBUFFER, CLASS, or STRUCT
// IDENTIFIER // IDENTIFIER
TString structName = ""; TString structName = "";
......
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