зеркало из https://github.com/stride3d/xkslang.git
Merge pull request #385 from steve-lunarg/inout-qualifiers
HLSL: add in/out/inout qualifiers
This commit is contained in:
Коммит
51e74b17bf
|
@ -0,0 +1,220 @@
|
||||||
|
hlsl.inoutquals.frag
|
||||||
|
Shader version: 450
|
||||||
|
gl_FragCoord origin is upper left
|
||||||
|
0:? Sequence
|
||||||
|
0:14 Function Definition: MyFunc(f1;f1;f1; (global void)
|
||||||
|
0:8 Function Parameters:
|
||||||
|
0:8 'x' (in float)
|
||||||
|
0:8 'y' (out float)
|
||||||
|
0:8 'z' (inout float)
|
||||||
|
0:? Sequence
|
||||||
|
0:9 move second child to first child (temp float)
|
||||||
|
0:9 'y' (out float)
|
||||||
|
0:9 'x' (in float)
|
||||||
|
0:10 move second child to first child (temp float)
|
||||||
|
0:10 'z' (inout float)
|
||||||
|
0:10 'y' (out float)
|
||||||
|
0:11 move second child to first child (temp float)
|
||||||
|
0:11 'x' (in float)
|
||||||
|
0:11 Constant:
|
||||||
|
0:11 -1.000000
|
||||||
|
0:26 Function Definition: main(vf4; (global structure{temp 4-component vector of float Color, temp float FragDepth Depth})
|
||||||
|
0:15 Function Parameters:
|
||||||
|
0:15 'inpos' (noperspective in 4-component vector of float FragCoord)
|
||||||
|
0:? Sequence
|
||||||
|
0:18 Sequence
|
||||||
|
0:18 move second child to first child (temp float)
|
||||||
|
0:18 'x' (temp float)
|
||||||
|
0:18 Constant:
|
||||||
|
0:18 7.000000
|
||||||
|
0:18 move second child to first child (temp float)
|
||||||
|
0:18 'z' (temp float)
|
||||||
|
0:18 Constant:
|
||||||
|
0:18 3.000000
|
||||||
|
0:19 Function Call: MyFunc(f1;f1;f1; (global void)
|
||||||
|
0:19 'x' (temp float)
|
||||||
|
0:19 'y' (temp float)
|
||||||
|
0:19 'z' (temp float)
|
||||||
|
0:21 move second child to first child (temp 4-component vector of float)
|
||||||
|
0:21 Color: direct index for structure (temp 4-component vector of float)
|
||||||
|
0:21 'psout' (temp structure{temp 4-component vector of float Color, temp float FragDepth Depth})
|
||||||
|
0:21 Constant:
|
||||||
|
0:21 0 (const int)
|
||||||
|
0:? Construct vec4 (temp 4-component vector of float)
|
||||||
|
0:21 'x' (temp float)
|
||||||
|
0:21 'y' (temp float)
|
||||||
|
0:21 'z' (temp float)
|
||||||
|
0:21 Constant:
|
||||||
|
0:21 1.000000
|
||||||
|
0:22 move second child to first child (temp float)
|
||||||
|
0:22 Depth: direct index for structure (temp float FragDepth)
|
||||||
|
0:22 'psout' (temp structure{temp 4-component vector of float Color, temp float FragDepth Depth})
|
||||||
|
0:22 Constant:
|
||||||
|
0:22 1 (const int)
|
||||||
|
0:22 direct index (temp float)
|
||||||
|
0:22 'inpos' (noperspective in 4-component vector of float FragCoord)
|
||||||
|
0:22 Constant:
|
||||||
|
0:22 3 (const int)
|
||||||
|
0:24 Branch: Return with expression
|
||||||
|
0:24 'psout' (temp structure{temp 4-component vector of float Color, temp float FragDepth Depth})
|
||||||
|
0:? Linker Objects
|
||||||
|
|
||||||
|
|
||||||
|
Linked fragment stage:
|
||||||
|
|
||||||
|
|
||||||
|
Shader version: 450
|
||||||
|
gl_FragCoord origin is upper left
|
||||||
|
0:? Sequence
|
||||||
|
0:14 Function Definition: MyFunc(f1;f1;f1; (global void)
|
||||||
|
0:8 Function Parameters:
|
||||||
|
0:8 'x' (in float)
|
||||||
|
0:8 'y' (out float)
|
||||||
|
0:8 'z' (inout float)
|
||||||
|
0:? Sequence
|
||||||
|
0:9 move second child to first child (temp float)
|
||||||
|
0:9 'y' (out float)
|
||||||
|
0:9 'x' (in float)
|
||||||
|
0:10 move second child to first child (temp float)
|
||||||
|
0:10 'z' (inout float)
|
||||||
|
0:10 'y' (out float)
|
||||||
|
0:11 move second child to first child (temp float)
|
||||||
|
0:11 'x' (in float)
|
||||||
|
0:11 Constant:
|
||||||
|
0:11 -1.000000
|
||||||
|
0:26 Function Definition: main(vf4; (global structure{temp 4-component vector of float Color, temp float FragDepth Depth})
|
||||||
|
0:15 Function Parameters:
|
||||||
|
0:15 'inpos' (noperspective in 4-component vector of float FragCoord)
|
||||||
|
0:? Sequence
|
||||||
|
0:18 Sequence
|
||||||
|
0:18 move second child to first child (temp float)
|
||||||
|
0:18 'x' (temp float)
|
||||||
|
0:18 Constant:
|
||||||
|
0:18 7.000000
|
||||||
|
0:18 move second child to first child (temp float)
|
||||||
|
0:18 'z' (temp float)
|
||||||
|
0:18 Constant:
|
||||||
|
0:18 3.000000
|
||||||
|
0:19 Function Call: MyFunc(f1;f1;f1; (global void)
|
||||||
|
0:19 'x' (temp float)
|
||||||
|
0:19 'y' (temp float)
|
||||||
|
0:19 'z' (temp float)
|
||||||
|
0:21 move second child to first child (temp 4-component vector of float)
|
||||||
|
0:21 Color: direct index for structure (temp 4-component vector of float)
|
||||||
|
0:21 'psout' (temp structure{temp 4-component vector of float Color, temp float FragDepth Depth})
|
||||||
|
0:21 Constant:
|
||||||
|
0:21 0 (const int)
|
||||||
|
0:? Construct vec4 (temp 4-component vector of float)
|
||||||
|
0:21 'x' (temp float)
|
||||||
|
0:21 'y' (temp float)
|
||||||
|
0:21 'z' (temp float)
|
||||||
|
0:21 Constant:
|
||||||
|
0:21 1.000000
|
||||||
|
0:22 move second child to first child (temp float)
|
||||||
|
0:22 Depth: direct index for structure (temp float FragDepth)
|
||||||
|
0:22 'psout' (temp structure{temp 4-component vector of float Color, temp float FragDepth Depth})
|
||||||
|
0:22 Constant:
|
||||||
|
0:22 1 (const int)
|
||||||
|
0:22 direct index (temp float)
|
||||||
|
0:22 'inpos' (noperspective in 4-component vector of float FragCoord)
|
||||||
|
0:22 Constant:
|
||||||
|
0:22 3 (const int)
|
||||||
|
0:24 Branch: Return with expression
|
||||||
|
0:24 'psout' (temp structure{temp 4-component vector of float Color, temp float FragDepth Depth})
|
||||||
|
0:? Linker Objects
|
||||||
|
|
||||||
|
// Module Version 10000
|
||||||
|
// Generated by (magic number): 80001
|
||||||
|
// Id's are bound by 54
|
||||||
|
|
||||||
|
Capability Shader
|
||||||
|
1: ExtInstImport "GLSL.std.450"
|
||||||
|
MemoryModel Logical GLSL450
|
||||||
|
EntryPoint Fragment 4 "main" 45
|
||||||
|
ExecutionMode 4 OriginUpperLeft
|
||||||
|
Source HLSL 450
|
||||||
|
Name 4 "main"
|
||||||
|
Name 12 "MyFunc(f1;f1;f1;"
|
||||||
|
Name 9 "x"
|
||||||
|
Name 10 "y"
|
||||||
|
Name 11 "z"
|
||||||
|
Name 17 "x"
|
||||||
|
Name 19 "z"
|
||||||
|
Name 21 "y"
|
||||||
|
Name 22 "param"
|
||||||
|
Name 24 "param"
|
||||||
|
Name 25 "param"
|
||||||
|
Name 31 "PS_OUTPUT"
|
||||||
|
MemberName 31(PS_OUTPUT) 0 "Color"
|
||||||
|
MemberName 31(PS_OUTPUT) 1 "Depth"
|
||||||
|
Name 33 "psout"
|
||||||
|
Name 45 "inpos"
|
||||||
|
MemberDecorate 31(PS_OUTPUT) 1 BuiltIn FragDepth
|
||||||
|
Decorate 45(inpos) NoPerspective
|
||||||
|
Decorate 45(inpos) BuiltIn FragCoord
|
||||||
|
2: TypeVoid
|
||||||
|
3: TypeFunction 2
|
||||||
|
6: TypeFloat 32
|
||||||
|
7: TypePointer Function 6(float)
|
||||||
|
8: TypeFunction 2 7(ptr) 7(ptr) 7(ptr)
|
||||||
|
16: 6(float) Constant 3212836864
|
||||||
|
18: 6(float) Constant 1088421888
|
||||||
|
20: 6(float) Constant 1077936128
|
||||||
|
30: TypeVector 6(float) 4
|
||||||
|
31(PS_OUTPUT): TypeStruct 30(fvec4) 6(float)
|
||||||
|
32: TypePointer Function 31(PS_OUTPUT)
|
||||||
|
34: TypeInt 32 1
|
||||||
|
35: 34(int) Constant 0
|
||||||
|
39: 6(float) Constant 1065353216
|
||||||
|
41: TypePointer Function 30(fvec4)
|
||||||
|
43: 34(int) Constant 1
|
||||||
|
44: TypePointer Input 30(fvec4)
|
||||||
|
45(inpos): 44(ptr) Variable Input
|
||||||
|
46: TypeInt 32 0
|
||||||
|
47: 46(int) Constant 3
|
||||||
|
48: TypePointer Input 6(float)
|
||||||
|
4(main): 2 Function None 3
|
||||||
|
5: Label
|
||||||
|
17(x): 7(ptr) Variable Function
|
||||||
|
19(z): 7(ptr) Variable Function
|
||||||
|
21(y): 7(ptr) Variable Function
|
||||||
|
22(param): 7(ptr) Variable Function
|
||||||
|
24(param): 7(ptr) Variable Function
|
||||||
|
25(param): 7(ptr) Variable Function
|
||||||
|
33(psout): 32(ptr) Variable Function
|
||||||
|
Store 17(x) 18
|
||||||
|
Store 19(z) 20
|
||||||
|
23: 6(float) Load 17(x)
|
||||||
|
Store 22(param) 23
|
||||||
|
26: 6(float) Load 19(z)
|
||||||
|
Store 25(param) 26
|
||||||
|
27: 2 FunctionCall 12(MyFunc(f1;f1;f1;) 22(param) 24(param) 25(param)
|
||||||
|
28: 6(float) Load 24(param)
|
||||||
|
Store 21(y) 28
|
||||||
|
29: 6(float) Load 25(param)
|
||||||
|
Store 19(z) 29
|
||||||
|
36: 6(float) Load 17(x)
|
||||||
|
37: 6(float) Load 21(y)
|
||||||
|
38: 6(float) Load 19(z)
|
||||||
|
40: 30(fvec4) CompositeConstruct 36 37 38 39
|
||||||
|
42: 41(ptr) AccessChain 33(psout) 35
|
||||||
|
Store 42 40
|
||||||
|
49: 48(ptr) AccessChain 45(inpos) 47
|
||||||
|
50: 6(float) Load 49
|
||||||
|
51: 7(ptr) AccessChain 33(psout) 43
|
||||||
|
Store 51 50
|
||||||
|
52:31(PS_OUTPUT) Load 33(psout)
|
||||||
|
ReturnValue 52
|
||||||
|
FunctionEnd
|
||||||
|
12(MyFunc(f1;f1;f1;): 2 Function None 8
|
||||||
|
9(x): 7(ptr) FunctionParameter
|
||||||
|
10(y): 7(ptr) FunctionParameter
|
||||||
|
11(z): 7(ptr) FunctionParameter
|
||||||
|
13: Label
|
||||||
|
14: 6(float) Load 9(x)
|
||||||
|
Store 10(y) 14
|
||||||
|
15: 6(float) Load 10(y)
|
||||||
|
Store 11(z) 15
|
||||||
|
Store 9(x) 16
|
||||||
|
Return
|
||||||
|
FunctionEnd
|
|
@ -0,0 +1,25 @@
|
||||||
|
struct PS_OUTPUT
|
||||||
|
{
|
||||||
|
float4 Color : SV_Target0;
|
||||||
|
float Depth : SV_Depth;
|
||||||
|
};
|
||||||
|
|
||||||
|
void MyFunc(in float x, out float y, inout float z)
|
||||||
|
{
|
||||||
|
y = x;
|
||||||
|
z = y;
|
||||||
|
x = -1; // no effect since x = in param
|
||||||
|
}
|
||||||
|
|
||||||
|
PS_OUTPUT main(noperspective in float4 inpos : SV_Position)
|
||||||
|
{
|
||||||
|
PS_OUTPUT psout;
|
||||||
|
|
||||||
|
float x = 7, y, z = 3;
|
||||||
|
MyFunc(x, y, z);
|
||||||
|
|
||||||
|
psout.Color = float4(x, y, z, 1);
|
||||||
|
psout.Depth = inpos.w;
|
||||||
|
|
||||||
|
return psout;
|
||||||
|
}
|
|
@ -82,6 +82,7 @@ INSTANTIATE_TEST_CASE_P(
|
||||||
{"hlsl.float4.frag", "PixelShaderFunction"},
|
{"hlsl.float4.frag", "PixelShaderFunction"},
|
||||||
{"hlsl.forLoop.frag", "PixelShaderFunction"},
|
{"hlsl.forLoop.frag", "PixelShaderFunction"},
|
||||||
{"hlsl.if.frag", "PixelShaderFunction"},
|
{"hlsl.if.frag", "PixelShaderFunction"},
|
||||||
|
{"hlsl.inoutquals.frag", "main"},
|
||||||
{"hlsl.init.frag", "ShaderFunction"},
|
{"hlsl.init.frag", "ShaderFunction"},
|
||||||
{"hlsl.intrinsics.barriers.comp", "ComputeShaderFunction"},
|
{"hlsl.intrinsics.barriers.comp", "ComputeShaderFunction"},
|
||||||
{"hlsl.intrinsics.comp", "ComputeShaderFunction"},
|
{"hlsl.intrinsics.comp", "ComputeShaderFunction"},
|
||||||
|
|
|
@ -478,6 +478,15 @@ void HlslGrammar::acceptQualifier(TQualifier& qualifier)
|
||||||
case EHTokPrecise:
|
case EHTokPrecise:
|
||||||
qualifier.noContraction = true;
|
qualifier.noContraction = true;
|
||||||
break;
|
break;
|
||||||
|
case EHTokIn:
|
||||||
|
qualifier.storage = EvqIn;
|
||||||
|
break;
|
||||||
|
case EHTokOut:
|
||||||
|
qualifier.storage = EvqOut;
|
||||||
|
break;
|
||||||
|
case EHTokInOut:
|
||||||
|
qualifier.storage = EvqInOut;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -114,6 +114,9 @@ void HlslScanContext::fillInKeywordMap()
|
||||||
(*KeywordMap)["row_major"] = EHTokRowMajor;
|
(*KeywordMap)["row_major"] = EHTokRowMajor;
|
||||||
(*KeywordMap)["column_major"] = EHTokColumnMajor;
|
(*KeywordMap)["column_major"] = EHTokColumnMajor;
|
||||||
(*KeywordMap)["packoffset"] = EHTokPackOffset;
|
(*KeywordMap)["packoffset"] = EHTokPackOffset;
|
||||||
|
(*KeywordMap)["in"] = EHTokIn;
|
||||||
|
(*KeywordMap)["out"] = EHTokOut;
|
||||||
|
(*KeywordMap)["inout"] = EHTokInOut;
|
||||||
|
|
||||||
(*KeywordMap)["Buffer"] = EHTokBuffer;
|
(*KeywordMap)["Buffer"] = EHTokBuffer;
|
||||||
(*KeywordMap)["vector"] = EHTokVector;
|
(*KeywordMap)["vector"] = EHTokVector;
|
||||||
|
@ -449,6 +452,9 @@ EHlslTokenClass HlslScanContext::tokenizeIdentifier()
|
||||||
case EHTokRowMajor:
|
case EHTokRowMajor:
|
||||||
case EHTokColumnMajor:
|
case EHTokColumnMajor:
|
||||||
case EHTokPackOffset:
|
case EHTokPackOffset:
|
||||||
|
case EHTokIn:
|
||||||
|
case EHTokOut:
|
||||||
|
case EHTokInOut:
|
||||||
return keyword;
|
return keyword;
|
||||||
|
|
||||||
// template types
|
// template types
|
||||||
|
|
|
@ -61,6 +61,9 @@ enum EHlslTokenClass {
|
||||||
EHTokRowMajor,
|
EHTokRowMajor,
|
||||||
EHTokColumnMajor,
|
EHTokColumnMajor,
|
||||||
EHTokPackOffset,
|
EHTokPackOffset,
|
||||||
|
EHTokIn,
|
||||||
|
EHTokOut,
|
||||||
|
EHTokInOut,
|
||||||
|
|
||||||
// template types
|
// template types
|
||||||
EHTokBuffer,
|
EHTokBuffer,
|
||||||
|
|
Загрузка…
Ссылка в новой задаче