HLSL: Add string basic type and recognize string declaration grammar.
This includes the "< decl ; decl ; >" syntax which has its own namespace. This functionality is not implemented, just silently accepted.
This commit is contained in:
parent
eee9d536bc
commit
86f7138706
64
Test/baseResults/hlsl.string.frag.out
Executable file
64
Test/baseResults/hlsl.string.frag.out
Executable file
@ -0,0 +1,64 @@
|
|||||||
|
hlsl.string.frag
|
||||||
|
Shader version: 450
|
||||||
|
gl_FragCoord origin is upper left
|
||||||
|
0:? Sequence
|
||||||
|
0:10 Function Definition: main(f1; (global float)
|
||||||
|
0:10 Function Parameters:
|
||||||
|
0:10 'f' (layout(location=0 ) in float)
|
||||||
|
0:? Sequence
|
||||||
|
0:11 Sequence
|
||||||
|
0:11 move second child to first child (temp float)
|
||||||
|
0:? '@entryPointOutput' (layout(location=0 ) out float)
|
||||||
|
0:11 'f' (layout(location=0 ) in float)
|
||||||
|
0:11 Branch: Return
|
||||||
|
0:? Linker Objects
|
||||||
|
0:? '@entryPointOutput' (layout(location=0 ) out float)
|
||||||
|
0:? 'f' (layout(location=0 ) in float)
|
||||||
|
|
||||||
|
|
||||||
|
Linked fragment stage:
|
||||||
|
|
||||||
|
|
||||||
|
Shader version: 450
|
||||||
|
gl_FragCoord origin is upper left
|
||||||
|
0:? Sequence
|
||||||
|
0:10 Function Definition: main(f1; (global float)
|
||||||
|
0:10 Function Parameters:
|
||||||
|
0:10 'f' (layout(location=0 ) in float)
|
||||||
|
0:? Sequence
|
||||||
|
0:11 Sequence
|
||||||
|
0:11 move second child to first child (temp float)
|
||||||
|
0:? '@entryPointOutput' (layout(location=0 ) out float)
|
||||||
|
0:11 'f' (layout(location=0 ) in float)
|
||||||
|
0:11 Branch: Return
|
||||||
|
0:? Linker Objects
|
||||||
|
0:? '@entryPointOutput' (layout(location=0 ) out float)
|
||||||
|
0:? 'f' (layout(location=0 ) in float)
|
||||||
|
|
||||||
|
// Module Version 10000
|
||||||
|
// Generated by (magic number): 80001
|
||||||
|
// Id's are bound by 13
|
||||||
|
|
||||||
|
Capability Shader
|
||||||
|
1: ExtInstImport "GLSL.std.450"
|
||||||
|
MemoryModel Logical GLSL450
|
||||||
|
EntryPoint Fragment 4 "main" 8 10
|
||||||
|
ExecutionMode 4 OriginUpperLeft
|
||||||
|
Name 4 "main"
|
||||||
|
Name 8 "@entryPointOutput"
|
||||||
|
Name 10 "f"
|
||||||
|
Decorate 8(@entryPointOutput) Location 0
|
||||||
|
Decorate 10(f) Location 0
|
||||||
|
2: TypeVoid
|
||||||
|
3: TypeFunction 2
|
||||||
|
6: TypeFloat 32
|
||||||
|
7: TypePointer Output 6(float)
|
||||||
|
8(@entryPointOutput): 7(ptr) Variable Output
|
||||||
|
9: TypePointer Input 6(float)
|
||||||
|
10(f): 9(ptr) Variable Input
|
||||||
|
4(main): 2 Function None 3
|
||||||
|
5: Label
|
||||||
|
11: 6(float) Load 10(f)
|
||||||
|
Store 8(@entryPointOutput) 11
|
||||||
|
Return
|
||||||
|
FunctionEnd
|
||||||
12
Test/hlsl.string.frag
Executable file
12
Test/hlsl.string.frag
Executable file
@ -0,0 +1,12 @@
|
|||||||
|
string s = "string1";
|
||||||
|
string e = "";
|
||||||
|
string bracket < string a = "nested" ; > ;
|
||||||
|
string brackets < string b = "nest1" ; string c = "nest2" ; string d = "nest3" ; > ;
|
||||||
|
string brackete1 < > ;
|
||||||
|
string brackete2 < ; > ;
|
||||||
|
string brackete3 < ; ; > ;
|
||||||
|
|
||||||
|
float main(float f)
|
||||||
|
{
|
||||||
|
return f;
|
||||||
|
}
|
||||||
@ -55,6 +55,10 @@ enum TBasicType {
|
|||||||
EbtSampler,
|
EbtSampler,
|
||||||
EbtStruct,
|
EbtStruct,
|
||||||
EbtBlock,
|
EbtBlock,
|
||||||
|
|
||||||
|
// HLSL types that live only temporarily.
|
||||||
|
EbtString,
|
||||||
|
|
||||||
EbtNumTypes
|
EbtNumTypes
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -2,5 +2,5 @@
|
|||||||
// For the version, it uses the latest git tag followed by the number of commits.
|
// For the version, it uses the latest git tag followed by the number of commits.
|
||||||
// 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 "Overload400-PrecQual.1499"
|
#define GLSLANG_REVISION "Overload400-PrecQual.1501"
|
||||||
#define GLSLANG_DATE "19-Sep-2016"
|
#define GLSLANG_DATE "19-Sep-2016"
|
||||||
|
|||||||
@ -160,6 +160,7 @@ INSTANTIATE_TEST_CASE_P(
|
|||||||
{"hlsl.semicolons.frag", "main"},
|
{"hlsl.semicolons.frag", "main"},
|
||||||
{"hlsl.shapeConv.frag", "main"},
|
{"hlsl.shapeConv.frag", "main"},
|
||||||
{"hlsl.stringtoken.frag", "main"},
|
{"hlsl.stringtoken.frag", "main"},
|
||||||
|
{"hlsl.string.frag", "main"},
|
||||||
{"hlsl.structin.vert", "main"},
|
{"hlsl.structin.vert", "main"},
|
||||||
{"hlsl.intrinsics.vert", "VertexShaderFunction"},
|
{"hlsl.intrinsics.vert", "VertexShaderFunction"},
|
||||||
{"hlsl.matType.frag", "PixelShaderFunction"},
|
{"hlsl.matType.frag", "PixelShaderFunction"},
|
||||||
|
|||||||
@ -721,6 +721,54 @@ bool HlslGrammar::acceptMatrixTemplateType(TType& type)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// string_template_type
|
||||||
|
// : STRING
|
||||||
|
// | STRING identifier LEFT_ANGLE declaration SEMI_COLON ... declaration SEMICOLON RIGHT_ANGLE
|
||||||
|
//
|
||||||
|
bool HlslGrammar::acceptStringTemplateType(TType& type)
|
||||||
|
{
|
||||||
|
// STRING
|
||||||
|
if (! acceptTokenClass(EHTokString))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// no matter what happens next, we recognized a string type
|
||||||
|
new(&type) TType(EbtString);
|
||||||
|
|
||||||
|
// identifier LEFT_ANGLE, or not?
|
||||||
|
if (! acceptTokenClass(EHTokIdentifier)) {
|
||||||
|
expected("identifier following 'string'");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! peekTokenClass(EHTokLeftAngle)) {
|
||||||
|
// then it must be the non-template version, back up and let
|
||||||
|
// normal declaration code handle it
|
||||||
|
|
||||||
|
// recede the identifier
|
||||||
|
recedeToken();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// move past the LEFT_ANGLE
|
||||||
|
advanceToken();
|
||||||
|
|
||||||
|
// declaration SEMI_COLON ... declaration SEMICOLON RIGHT_ANGLE
|
||||||
|
do {
|
||||||
|
// eat any extra SEMI_COLON; don't know if the grammar calls for this or not
|
||||||
|
while (acceptTokenClass(EHTokSemicolon))
|
||||||
|
;
|
||||||
|
|
||||||
|
if (acceptTokenClass(EHTokRightAngle))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
// declaration
|
||||||
|
TIntermNode* node;
|
||||||
|
if (! acceptDeclaration(node)) {
|
||||||
|
expected("declaration in string list");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} while (true);
|
||||||
|
}
|
||||||
|
|
||||||
// sampler_type
|
// sampler_type
|
||||||
// : SAMPLER
|
// : SAMPLER
|
||||||
@ -894,6 +942,10 @@ bool HlslGrammar::acceptType(TType& type)
|
|||||||
return acceptMatrixTemplateType(type);
|
return acceptMatrixTemplateType(type);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case EHTokString:
|
||||||
|
return acceptStringTemplateType(type);
|
||||||
|
break;
|
||||||
|
|
||||||
case EHTokSampler: // fall through
|
case EHTokSampler: // fall through
|
||||||
case EHTokSampler1d: // ...
|
case EHTokSampler1d: // ...
|
||||||
case EHTokSampler2d: // ...
|
case EHTokSampler2d: // ...
|
||||||
@ -2062,6 +2114,9 @@ bool HlslGrammar::acceptLiteral(TIntermTyped*& node)
|
|||||||
case EHTokBoolConstant:
|
case EHTokBoolConstant:
|
||||||
node = intermediate.addConstantUnion(token.b, token.loc, true);
|
node = intermediate.addConstantUnion(token.b, token.loc, true);
|
||||||
break;
|
break;
|
||||||
|
case EHTokStringConstant:
|
||||||
|
node = nullptr;
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@ -73,6 +73,7 @@ namespace glslang {
|
|||||||
bool acceptTemplateType(TBasicType&);
|
bool acceptTemplateType(TBasicType&);
|
||||||
bool acceptVectorTemplateType(TType&);
|
bool acceptVectorTemplateType(TType&);
|
||||||
bool acceptMatrixTemplateType(TType&);
|
bool acceptMatrixTemplateType(TType&);
|
||||||
|
bool acceptStringTemplateType(TType&);
|
||||||
bool acceptSamplerType(TType&);
|
bool acceptSamplerType(TType&);
|
||||||
bool acceptTextureType(TType&);
|
bool acceptTextureType(TType&);
|
||||||
bool acceptStruct(TType&);
|
bool acceptStruct(TType&);
|
||||||
|
|||||||
@ -4052,6 +4052,11 @@ void HlslParseContext::declareTypedef(const TSourceLoc& loc, TString& identifier
|
|||||||
//
|
//
|
||||||
TIntermNode* HlslParseContext::declareVariable(const TSourceLoc& loc, TString& identifier, const TType& parseType, TArraySizes* arraySizes, TIntermTyped* initializer)
|
TIntermNode* HlslParseContext::declareVariable(const TSourceLoc& loc, TString& identifier, const TType& parseType, TArraySizes* arraySizes, TIntermTyped* initializer)
|
||||||
{
|
{
|
||||||
|
// string identifiers can nest inside < ... >, apparently with their own namespace,
|
||||||
|
// which is not implemented
|
||||||
|
if (parseType.getBasicType() == EbtString)
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
TType type;
|
TType type;
|
||||||
type.shallowCopy(parseType);
|
type.shallowCopy(parseType);
|
||||||
if (type.isImplicitlySizedArray()) {
|
if (type.isImplicitlySizedArray()) {
|
||||||
|
|||||||
@ -122,6 +122,7 @@ void HlslScanContext::fillInKeywordMap()
|
|||||||
(*KeywordMap)["Buffer"] = EHTokBuffer;
|
(*KeywordMap)["Buffer"] = EHTokBuffer;
|
||||||
(*KeywordMap)["vector"] = EHTokVector;
|
(*KeywordMap)["vector"] = EHTokVector;
|
||||||
(*KeywordMap)["matrix"] = EHTokMatrix;
|
(*KeywordMap)["matrix"] = EHTokMatrix;
|
||||||
|
(*KeywordMap)["string"] = EHTokString;
|
||||||
|
|
||||||
(*KeywordMap)["void"] = EHTokVoid;
|
(*KeywordMap)["void"] = EHTokVoid;
|
||||||
(*KeywordMap)["bool"] = EHTokBool;
|
(*KeywordMap)["bool"] = EHTokBool;
|
||||||
@ -471,6 +472,7 @@ EHlslTokenClass HlslScanContext::tokenizeIdentifier()
|
|||||||
case EHTokBuffer:
|
case EHTokBuffer:
|
||||||
case EHTokVector:
|
case EHTokVector:
|
||||||
case EHTokMatrix:
|
case EHTokMatrix:
|
||||||
|
case EHTokString:
|
||||||
return keyword;
|
return keyword;
|
||||||
|
|
||||||
// scalar types
|
// scalar types
|
||||||
|
|||||||
@ -70,6 +70,7 @@ enum EHlslTokenClass {
|
|||||||
EHTokBuffer,
|
EHTokBuffer,
|
||||||
EHTokVector,
|
EHTokVector,
|
||||||
EHTokMatrix,
|
EHTokMatrix,
|
||||||
|
EHTokString,
|
||||||
|
|
||||||
// scalar types
|
// scalar types
|
||||||
EHTokVoid,
|
EHTokVoid,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user