/
spirv.shader_test
117 lines (114 loc) · 4.5 KB
/
spirv.shader_test
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
[vertex shader spirv]
OpCapability Shader
%1 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint Vertex %main "main" %_ %pos %norm_coord
OpSource GLSL 430
OpName %main "main"
OpName %gl_PerVertex "gl_PerVertex"
OpMemberName %gl_PerVertex 0 "gl_Position"
OpName %_ ""
OpName %pos "pos"
OpName %norm_coord "norm_coord"
OpMemberDecorate %gl_PerVertex 0 BuiltIn Position
OpDecorate %gl_PerVertex Block
OpDecorate %pos Location 0
OpDecorate %norm_coord Location 0
%void = OpTypeVoid
%3 = OpTypeFunction %void
%float = OpTypeFloat 32
%v4float = OpTypeVector %float 4
%uint = OpTypeInt 32 0
%uint_1 = OpConstant %uint 1
%_arr_float_uint_1 = OpTypeArray %float %uint_1
%gl_PerVertex = OpTypeStruct %v4float
%_ptr_Output_gl_PerVertex = OpTypePointer Output %gl_PerVertex
%_ = OpVariable %_ptr_Output_gl_PerVertex Output
%int = OpTypeInt 32 1
%int_0 = OpConstant %int 0
%_ptr_Input_v4float = OpTypePointer Input %v4float
%pos = OpVariable %_ptr_Input_v4float Input
%_ptr_Output_v4float = OpTypePointer Output %v4float
%norm_coord = OpVariable %_ptr_Output_v4float Output
%main = OpFunction %void None %3
%5 = OpLabel
%18 = OpLoad %v4float %pos
%20 = OpAccessChain %_ptr_Output_v4float %_ %int_0
OpStore %20 %18
OpStore %norm_coord %18
OpReturn
OpFunctionEnd
[fragment shader spirv]
OpCapability Shader
%1 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint Fragment %main "main" %color %norm_coord
OpExecutionMode %main OriginUpperLeft
OpSource GLSL 430
OpName %main "main"
OpName %color "color"
OpName %norm_coord "norm_coord"
OpDecorate %color Location 0
OpDecorate %norm_coord Location 0
%void = OpTypeVoid
%3 = OpTypeFunction %void
%float = OpTypeFloat 32
%v4float = OpTypeVector %float 4
%_ptr_Output_v4float = OpTypePointer Output %v4float
%color = OpVariable %_ptr_Output_v4float Output
%v2float = OpTypeVector %float 2
%float_1 = OpConstant %float 1
%12 = OpConstantComposite %v2float %float_1 %float_1
%bool = OpTypeBool
%_ptr_Input_v4float = OpTypePointer Input %v4float
%norm_coord = OpVariable %_ptr_Input_v4float Input
%uint = OpTypeInt 32 0
%uint_0 = OpConstant %uint 0
%_ptr_Input_float = OpTypePointer Input %float
%float_0_1 = OpConstant %float 0.1
%uint_1 = OpConstant %uint 1
%float_0 = OpConstant %float 0
%38 = OpConstantComposite %v2float %float_0 %float_0
%main = OpFunction %void None %3
%5 = OpLabel
%13 = OpLoad %v4float %color
%14 = OpVectorShuffle %v4float %13 %12 4 1 2 5
OpStore %color %14
%21 = OpAccessChain %_ptr_Input_float %norm_coord %uint_0
%22 = OpLoad %float %21
%23 = OpExtInst %float %1 FAbs %22
%25 = OpFOrdLessThan %bool %23 %float_0_1
%26 = OpLogicalNot %bool %25
OpSelectionMerge %28 None
OpBranchConditional %26 %27 %28
%27 = OpLabel
%30 = OpAccessChain %_ptr_Input_float %norm_coord %uint_1
%31 = OpLoad %float %30
%32 = OpExtInst %float %1 FAbs %31
%33 = OpFOrdLessThan %bool %32 %float_0_1
OpBranch %28
%28 = OpLabel
%34 = OpPhi %bool %25 %5 %33 %27
OpSelectionMerge %36 None
OpBranchConditional %34 %35 %41
%35 = OpLabel
%39 = OpLoad %v4float %color
%40 = OpVectorShuffle %v4float %39 %38 0 4 5 3
OpStore %color %40
OpBranch %36
%41 = OpLabel
%42 = OpLoad %v4float %color
%43 = OpVectorShuffle %v4float %42 %12 0 4 5 3
OpStore %color %43
OpBranch %36
%36 = OpLabel
OpReturn
OpFunctionEnd
[test]
draw rect -1 -1 2 2
probe rect rgba (0, 0, 11, 11) (1, 1, 1, 1)
probe rect rgba (138, 0, 112, 11) (1, 1, 1, 1)
probe rect rgba (0, 138, 11, 112) (1, 1, 1, 1)
probe rect rgba (138, 138, 112, 112) (1, 1, 1, 1)
probe rect rgba (114, 0, 23, 250) (1, 0, 0, 1)
probe rect rgba (0, 114, 250, 23) (1, 0, 0, 1)