Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
glslang
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
glslang
Commits
93a162a8
Commit
93a162a8
authored
Jun 17, 2016
by
John Kessenich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
HLSL: Handle "." for structure dereference and swizzle.
parent
5aa59e20
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
201 additions
and
45 deletions
+201
-45
hlsl.struct.frag.out
Test/baseResults/hlsl.struct.frag.out
+70
-44
hlsl.swizzle.frag.out
Test/baseResults/hlsl.swizzle.frag.out
+113
-0
hlsl.struct.frag
Test/hlsl.struct.frag
+2
-0
hlsl.swizzle.frag
Test/hlsl.swizzle.frag
+6
-0
Hlsl.FromFile.cpp
gtests/Hlsl.FromFile.cpp
+1
-0
hlslGrammar.cpp
hlsl/hlslGrammar.cpp
+9
-1
No files found.
Test/baseResults/hlsl.struct.frag.out
View file @
93a162a8
...
@@ -2,15 +2,24 @@ hlsl.struct.frag
...
@@ -2,15 +2,24 @@ hlsl.struct.frag
Shader version: 450
Shader version: 450
gl_FragCoord origin is upper left
gl_FragCoord origin is upper left
0:? Sequence
0:? Sequence
0:
39
Function Definition: PixelShaderFunction(vf4; (temp 4-component vector of float)
0:
40
Function Definition: PixelShaderFunction(vf4; (temp 4-component vector of float)
0:31 Function Parameters:
0:31 Function Parameters:
0:31 'input' (in 4-component vector of float)
0:31 'input' (in 4-component vector of float)
0:? Sequence
0:? Sequence
0:36 Compare Equal (temp bool)
0:36 Compare Equal (temp bool)
0:36 's3' (temp structure{temp 3-component vector of bool b3})
0:36 's3' (temp structure{temp 3-component vector of bool b3})
0:36 's3' (temp structure{temp 3-component vector of bool b3})
0:36 's3' (temp structure{temp 3-component vector of bool b3})
0:38 Branch: Return with expression
0:37 move second child to first child (temp 4-component vector of float)
0:38 'input' (in 4-component vector of float)
0:37 i: direct index for structure (temp 4-component vector of float)
0:37 's2' (temp 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' (temp 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 Constant:
0:37 7 (const int)
0:39 Branch: Return with expression
0:39 'input' (in 4-component vector of float)
0:? Linker Objects
0:? Linker Objects
0:? 's1' (temp structure{temp bool b, temp bool c, temp 4-component vector of float a, temp 4-component vector of float d})
0:? 's1' (temp structure{temp bool b, temp bool c, temp 4-component vector of float a, temp 4-component vector of float d})
0:? 's2' (temp structure{temp 4-component vector of float i})
0:? 's2' (temp structure{temp 4-component vector of float i})
...
@@ -23,15 +32,24 @@ Linked fragment stage:
...
@@ -23,15 +32,24 @@ Linked fragment stage:
Shader version: 450
Shader version: 450
gl_FragCoord origin is upper left
gl_FragCoord origin is upper left
0:? Sequence
0:? Sequence
0:
39
Function Definition: PixelShaderFunction(vf4; (temp 4-component vector of float)
0:
40
Function Definition: PixelShaderFunction(vf4; (temp 4-component vector of float)
0:31 Function Parameters:
0:31 Function Parameters:
0:31 'input' (in 4-component vector of float)
0:31 'input' (in 4-component vector of float)
0:? Sequence
0:? Sequence
0:36 Compare Equal (temp bool)
0:36 Compare Equal (temp bool)
0:36 's3' (temp structure{temp 3-component vector of bool b3})
0:36 's3' (temp structure{temp 3-component vector of bool b3})
0:36 's3' (temp structure{temp 3-component vector of bool b3})
0:36 's3' (temp structure{temp 3-component vector of bool b3})
0:38 Branch: Return with expression
0:37 move second child to first child (temp 4-component vector of float)
0:38 'input' (in 4-component vector of float)
0:37 i: direct index for structure (temp 4-component vector of float)
0:37 's2' (temp 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' (temp 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 Constant:
0:37 7 (const int)
0:39 Branch: Return with expression
0:39 'input' (in 4-component vector of float)
0:? Linker Objects
0:? Linker Objects
0:? 's1' (temp structure{temp bool b, temp bool c, temp 4-component vector of float a, temp 4-component vector of float d})
0:? 's1' (temp structure{temp bool b, temp bool c, temp 4-component vector of float a, temp 4-component vector of float d})
0:? 's2' (temp structure{temp 4-component vector of float i})
0:? 's2' (temp structure{temp 4-component vector of float i})
...
@@ -39,40 +57,40 @@ gl_FragCoord origin is upper left
...
@@ -39,40 +57,40 @@ gl_FragCoord origin is upper left
// Module Version 10000
// Module Version 10000
// Generated by (magic number): 80001
// Generated by (magic number): 80001
// Id's are bound by
33
// Id's are bound by
40
Capability Shader
Capability Shader
1: ExtInstImport "GLSL.std.450"
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
MemoryModel Logical GLSL450
EntryPoint Fragment 4 "PixelShaderFunction"
20
EntryPoint Fragment 4 "PixelShaderFunction"
34
ExecutionMode 4 OriginUpperLeft
ExecutionMode 4 OriginUpperLeft
Source HLSL 450
Source HLSL 450
Name 4 "PixelShaderFunction"
Name 4 "PixelShaderFunction"
Name 8 "FS"
Name 8 "FS"
MemberName 8(FS) 0 "b3"
MemberName 8(FS) 0 "b3"
Name 10 "s3"
Name 10 "s3"
Name
20 "input
"
Name
19 "
"
Name 23 "myS
"
MemberName 19 0 "i
"
MemberName 23(myS) 0 "b
"
Name 21 "s2
"
MemberName 23(myS) 1 "c
"
Name 25 "
"
MemberName 2
3(myS) 2
"a"
MemberName 2
5 0
"a"
MemberName 2
3(myS) 3 "d
"
MemberName 2
5 1 "b
"
Name 25 "s1
"
MemberName 25 2 "c
"
Name 26 "
"
MemberName 25 3 "d
"
MemberName 2
6 0 "i
"
MemberName 2
5 4 "ff1
"
Name 28 "s
2"
MemberName 25 5 "ff
2"
Name 30 "
"
MemberName 25 6 "ff3
"
MemberName
30 0 "a
"
MemberName
25 7 "ff4
"
MemberName 30 1 "b
"
Name 27 "s4
"
MemberName 30 2 "c
"
Name 34 "input
"
MemberName 30 3 "d
"
Name 37 "myS
"
MemberName 3
0 4 "ff1
"
MemberName 3
7(myS) 0 "b
"
MemberName 3
0 5 "ff2
"
MemberName 3
7(myS) 1 "c
"
MemberName 3
0 6 "ff3
"
MemberName 3
7(myS) 2 "a
"
MemberName 3
0 7 "ff4
"
MemberName 3
7(myS) 3 "d
"
Name 3
2 "s4
"
Name 3
9 "s1
"
MemberDecorate
30
4 BuiltIn FrontFacing
MemberDecorate
25
4 BuiltIn FrontFacing
MemberDecorate
30
7 BuiltIn FragCoord
MemberDecorate
25
7 BuiltIn FragCoord
2: TypeVoid
2: TypeVoid
3: TypeFunction 2
3: TypeFunction 2
6: TypeBool
6: TypeBool
...
@@ -81,27 +99,35 @@ gl_FragCoord origin is upper left
...
@@ -81,27 +99,35 @@ gl_FragCoord origin is upper left
9: TypePointer Function 8(FS)
9: TypePointer Function 8(FS)
17: TypeFloat 32
17: TypeFloat 32
18: TypeVector 17(float) 4
18: TypeVector 17(float) 4
19: TypePointer Input 18(fvec4)
19: TypeStruct 18(fvec4)
20(input): 19(ptr) Variable Input
20: TypePointer Function 19(struct)
23(myS): TypeStruct 6(bool) 6(bool) 18(fvec4) 18(fvec4)
22: TypeInt 32 1
24: TypePointer Function 23(myS)
23: 22(int) Constant 0
26: TypeStruct 18(fvec4)
24: TypeVector 17(float) 2
27: TypePointer Function 26(struct)
25: TypeStruct 18(fvec4) 6(bool) 17(float) 24(fvec2) 6(bool) 6(bool) 6(bool) 18(fvec4)
29: TypeVector 17(float) 2
26: TypePointer Function 25(struct)
30: TypeStruct 18(fvec4) 6(bool) 17(float) 29(fvec2) 6(bool) 6(bool) 6(bool) 18(fvec4)
28: 22(int) Constant 7
31: TypePointer Function 30(struct)
29: TypePointer Function 18(fvec4)
33: TypePointer Input 18(fvec4)
34(input): 33(ptr) Variable Input
37(myS): TypeStruct 6(bool) 6(bool) 18(fvec4) 18(fvec4)
38: TypePointer Function 37(myS)
4(PixelShaderFunction): 2 Function None 3
4(PixelShaderFunction): 2 Function None 3
5: Label
5: Label
10(s3): 9(ptr) Variable Function
10(s3): 9(ptr) Variable Function
2
5(s1): 24
(ptr) Variable Function
2
1(s2): 20
(ptr) Variable Function
2
8(s2): 27
(ptr) Variable Function
2
7(s4): 26
(ptr) Variable Function
3
2(s4): 31
(ptr) Variable Function
3
9(s1): 38
(ptr) Variable Function
11: 8(FS) Load 10(s3)
11: 8(FS) Load 10(s3)
12: 8(FS) Load 10(s3)
12: 8(FS) Load 10(s3)
13: 7(bvec3) CompositeExtract 11 0
13: 7(bvec3) CompositeExtract 11 0
14: 7(bvec3) CompositeExtract 12 0
14: 7(bvec3) CompositeExtract 12 0
15: 7(bvec3) LogicalEqual 13 14
15: 7(bvec3) LogicalEqual 13 14
16: 6(bool) All 15
16: 6(bool) All 15
21: 18(fvec4) Load 20(input)
30: 29(ptr) AccessChain 27(s4) 28
ReturnValue 21
31: 18(fvec4) Load 30
32: 29(ptr) AccessChain 21(s2) 23
Store 32 31
35: 18(fvec4) Load 34(input)
ReturnValue 35
FunctionEnd
FunctionEnd
Test/baseResults/hlsl.swizzle.frag.out
0 → 100755
View file @
93a162a8
hlsl.swizzle.frag
Shader version: 450
gl_FragCoord origin is upper left
0:? Sequence
0:1 move second child to first child (temp 4-component vector of float)
0:1 'AmbientColor' (temp 4-component vector of float)
0:? Constant:
0:? 1.000000
0:? 0.500000
0:? 0.000000
0:? 1.000000
0:7 Function Definition: ShaderFunction(vf4; (temp 4-component vector of float)
0:4 Function Parameters:
0:4 'input' (in 4-component vector of float)
0:? Sequence
0:5 Branch: Return with expression
0:5 component-wise multiply (temp 4-component vector of float)
0:5 vector swizzle (temp 4-component vector of float)
0:5 'input' (in 4-component vector of float)
0:5 Sequence
0:5 Constant:
0:5 3 (const int)
0:5 Constant:
0:5 3 (const int)
0:5 Constant:
0:5 1 (const int)
0:5 Constant:
0:5 0 (const int)
0:5 Construct vec4 (temp 4-component vector of float)
0:5 direct index (temp float)
0:5 'AmbientColor' (temp 4-component vector of float)
0:5 Constant:
0:5 2 (const int)
0:? Linker Objects
0:? 'AmbientColor' (temp 4-component vector of float)
Linked fragment stage:
Shader version: 450
gl_FragCoord origin is upper left
0:? Sequence
0:1 move second child to first child (temp 4-component vector of float)
0:1 'AmbientColor' (temp 4-component vector of float)
0:? Constant:
0:? 1.000000
0:? 0.500000
0:? 0.000000
0:? 1.000000
0:7 Function Definition: ShaderFunction(vf4; (temp 4-component vector of float)
0:4 Function Parameters:
0:4 'input' (in 4-component vector of float)
0:? Sequence
0:5 Branch: Return with expression
0:5 component-wise multiply (temp 4-component vector of float)
0:5 vector swizzle (temp 4-component vector of float)
0:5 'input' (in 4-component vector of float)
0:5 Sequence
0:5 Constant:
0:5 3 (const int)
0:5 Constant:
0:5 3 (const int)
0:5 Constant:
0:5 1 (const int)
0:5 Constant:
0:5 0 (const int)
0:5 Construct vec4 (temp 4-component vector of float)
0:5 direct index (temp float)
0:5 'AmbientColor' (temp 4-component vector of float)
0:5 Constant:
0:5 2 (const int)
0:? Linker Objects
0:? 'AmbientColor' (temp 4-component vector of float)
// Module Version 10000
// Generated by (magic number): 80001
// Id's are bound by 25
Capability Shader
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint Fragment 4 "PixelShaderFunction"
ExecutionMode 4 OriginUpperLeft
Source HLSL 450
Name 4 "PixelShaderFunction"
Name 11 "ShaderFunction(vf4;"
Name 10 "input"
Name 15 "AmbientColor"
2: TypeVoid
3: TypeFunction 2
6: TypeFloat 32
7: TypeVector 6(float) 4
8: TypePointer Function 7(fvec4)
9: TypeFunction 7(fvec4) 8(ptr)
16: TypeInt 32 0
17: 16(int) Constant 2
18: TypePointer Function 6(float)
4(PixelShaderFunction): 2 Function None 3
5: Label
FunctionEnd
11(ShaderFunction(vf4;): 7(fvec4) Function None 9
10(input): 8(ptr) FunctionParameter
12: Label
15(AmbientColor): 8(ptr) Variable Function
13: 7(fvec4) Load 10(input)
14: 7(fvec4) VectorShuffle 13 13 3 3 1 0
19: 18(ptr) AccessChain 15(AmbientColor) 17
20: 6(float) Load 19
21: 7(fvec4) CompositeConstruct 20 20 20 20
22: 7(fvec4) FMul 14 21
ReturnValue 22
FunctionEnd
Test/hlsl.struct.frag
View file @
93a162a8
...
@@ -34,6 +34,7 @@ float4 PixelShaderFunction(float4 input) : COLOR0
...
@@ -34,6 +34,7 @@ float4 PixelShaderFunction(float4 input) : COLOR0
}
s3
;
}
s3
;
s3
==
s3
;
s3
==
s3
;
s2
.
i
=
s4
.
ff4
;
return
input
;
return
input
;
}
}
\ No newline at end of file
Test/hlsl.swizzle.frag
0 → 100644
View file @
93a162a8
float4
AmbientColor
=
float4
(
1
,
0
.
5
,
0
,
1
);
float4
ShaderFunction
(
float4
input
)
:
COLOR0
{
return
input
.
wwyx
*
float4
(
AmbientColor
.
z
);
}
gtests/Hlsl.FromFile.cpp
View file @
93a162a8
...
@@ -93,6 +93,7 @@ INSTANTIATE_TEST_CASE_P(
...
@@ -93,6 +93,7 @@ INSTANTIATE_TEST_CASE_P(
{
"hlsl.scope.frag"
,
"PixelShaderFunction"
},
{
"hlsl.scope.frag"
,
"PixelShaderFunction"
},
{
"hlsl.sin.frag"
,
"PixelShaderFunction"
},
{
"hlsl.sin.frag"
,
"PixelShaderFunction"
},
{
"hlsl.struct.frag"
,
"PixelShaderFunction"
},
{
"hlsl.struct.frag"
,
"PixelShaderFunction"
},
{
"hlsl.swizzle.frag"
,
"PixelShaderFunction"
},
{
"hlsl.whileLoop.frag"
,
"PixelShaderFunction"
},
{
"hlsl.whileLoop.frag"
,
"PixelShaderFunction"
},
{
"hlsl.void.frag"
,
"PixelShaderFunction"
},
{
"hlsl.void.frag"
,
"PixelShaderFunction"
},
}),
}),
...
...
hlsl/hlslGrammar.cpp
View file @
93a162a8
...
@@ -1097,8 +1097,16 @@ bool HlslGrammar::acceptPostfixExpression(TIntermTyped*& node)
...
@@ -1097,8 +1097,16 @@ bool HlslGrammar::acceptPostfixExpression(TIntermTyped*& node)
// We have a valid post-unary operator, process it.
// We have a valid post-unary operator, process it.
switch
(
postOp
)
{
switch
(
postOp
)
{
case
EOpIndexDirectStruct
:
case
EOpIndexDirectStruct
:
// todo
{
// includes swizzles
HlslToken
field
;
if
(
!
acceptIdentifier
(
field
))
{
expected
(
"swizzle or member"
);
return
false
;
}
node
=
parseContext
.
handleDotDereference
(
field
.
loc
,
node
,
*
field
.
string
);
break
;
break
;
}
case
EOpIndexIndirect
:
case
EOpIndexIndirect
:
{
{
TIntermTyped
*
indexNode
=
nullptr
;
TIntermTyped
*
indexNode
=
nullptr
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment