• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!amber
2
3# Copyright 2022 Google LLC
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9#     http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16
17
18# A test for a coverage-gap found by the GraphicsFuzz project.
19
20# Short description: A fragment shader that covers specific LLVM code paths
21
22# The test passes because the shader always writes red.
23
24# Optimized using spirv-opt with the following arguments:
25# '--eliminate-dead-branches'
26# '--inline-entry-points-exhaustive'
27# '--reduce-load-size'
28# '--eliminate-local-single-block'
29# '--vector-dce'
30# '--eliminate-dead-branches'
31# '--simplify-instructions'
32# '--inline-entry-points-exhaustive'
33# '--if-conversion'
34# '--redundancy-elimination'
35# '--eliminate-local-single-block'
36# '--vector-dce'
37# '--eliminate-dead-branches'
38# '--vector-dce'
39# '--if-conversion'
40# '--vector-dce'
41# '--combine-access-chains'
42# '--simplify-instructions'
43# '--eliminate-dead-code-aggressive'
44# '--inline-entry-points-exhaustive'
45# '--eliminate-dead-inserts'
46# '--eliminate-local-single-store'
47# '--ccp'
48# '--reduce-load-size'
49# '--eliminate-dead-branches'
50# '--merge-blocks'
51# '--if-conversion'
52# '--combine-access-chains'
53# '--copy-propagate-arrays'
54# '--eliminate-dead-branches'
55# '--merge-return'
56# '--inline-entry-points-exhaustive'
57# spirv-opt commit hash: a0370efd589be33d5d9a85cfde2f85841b3755af
58
59
60
61SHADER vertex variant_vertex_shader PASSTHROUGH
62
63# variant_fragment_shader is derived from the following GLSL:
64# #version 320 es
65# #define _int_1 _GLF_uniform_int_values[0]
66# #define _int_0 _GLF_uniform_int_values[1]
67# #define _float_1_0 _GLF_uniform_float_values[0]
68# #define _float_0_0 _GLF_uniform_float_values[1]
69#
70# precision highp float;
71# precision highp int;
72#
73# // Contents of _GLF_uniform_float_values: [1.0, 0.0]
74# layout(set = 0, binding = 0) uniform buf0
75# {
76#     float _GLF_uniform_float_values[2];
77# };
78#
79# // Contents of _GLF_uniform_int_values: [1, 0]
80# layout(set = 0, binding = 1) uniform buf1
81# {
82#     int _GLF_uniform_int_values[2];
83# };
84#
85# layout(location = 0) out vec4 _GLF_color;
86#
87# vec3 func()
88# {
89#     int a = _int_1;
90#     // b becomes one.
91#     int b = int(max(ivec2(1, true ? a : _int_1), ivec2(1, true ? a : _int_1)));
92#     // Returns vec3(1, 1, 1).
93#     return vec3(max(_float_1_0, b == _int_1 ? _float_0_0 : _float_1_0));
94# }
95#
96# void main()
97# {
98#     // Always true.
99#     if(func() == vec3(_int_1))
100#     {
101#         _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1);
102#     }
103#     else
104#     {
105#         _GLF_color = vec4(_int_0);
106#     }
107# }
108SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
109; SPIR-V
110; Version: 1.0
111; Generator: Khronos Glslang Reference Front End; 10
112; Bound: 144
113; Schema: 0
114               OpCapability Shader
115          %1 = OpExtInstImport "GLSL.std.450"
116               OpMemoryModel Logical GLSL450
117               OpEntryPoint Fragment %4 "main" %86
118               OpExecutionMode %4 OriginUpperLeft
119               OpSource ESSL 320
120               OpName %4 "main"
121               OpName %17 "buf1"
122               OpMemberName %17 0 "_GLF_uniform_int_values"
123               OpName %19 ""
124               OpName %50 "buf0"
125               OpMemberName %50 0 "_GLF_uniform_float_values"
126               OpName %52 ""
127               OpName %86 "_GLF_color"
128               OpDecorate %16 ArrayStride 16
129               OpMemberDecorate %17 0 Offset 0
130               OpDecorate %17 Block
131               OpDecorate %19 DescriptorSet 0
132               OpDecorate %19 Binding 1
133               OpDecorate %49 ArrayStride 16
134               OpMemberDecorate %50 0 Offset 0
135               OpDecorate %50 Block
136               OpDecorate %52 DescriptorSet 0
137               OpDecorate %52 Binding 0
138               OpDecorate %86 Location 0
139          %2 = OpTypeVoid
140          %3 = OpTypeFunction %2
141          %6 = OpTypeFloat 32
142          %7 = OpTypeVector %6 3
143         %11 = OpTypeInt 32 1
144         %14 = OpTypeInt 32 0
145         %15 = OpConstant %14 2
146         %16 = OpTypeArray %11 %15
147         %17 = OpTypeStruct %16
148         %18 = OpTypePointer Uniform %17
149         %19 = OpVariable %18 Uniform
150         %20 = OpConstant %11 0
151         %21 = OpTypePointer Uniform %11
152         %25 = OpConstant %11 1
153         %26 = OpTypeBool
154         %36 = OpTypeVector %11 2
155         %49 = OpTypeArray %6 %15
156         %50 = OpTypeStruct %49
157         %51 = OpTypePointer Uniform %50
158         %52 = OpVariable %51 Uniform
159         %53 = OpTypePointer Uniform %6
160         %60 = OpTypePointer Function %6
161         %79 = OpTypeVector %26 3
162         %84 = OpTypeVector %6 4
163         %85 = OpTypePointer Output %84
164         %86 = OpVariable %85 Output
165        %143 = OpUndef %11
166          %4 = OpFunction %2 None %3
167          %5 = OpLabel
168        %109 = OpVariable %60 Function
169        %113 = OpAccessChain %21 %19 %20 %20
170        %114 = OpLoad %11 %113
171        %119 = OpCompositeConstruct %36 %25 %143
172        %125 = OpExtInst %36 %1 SMax %119 %119
173        %126 = OpCompositeExtract %11 %125 0
174        %127 = OpAccessChain %53 %52 %20 %20
175        %128 = OpLoad %6 %127
176        %132 = OpIEqual %26 %126 %114
177               OpSelectionMerge %139 None
178               OpBranchConditional %132 %136 %133
179        %133 = OpLabel
180               OpStore %109 %128
181               OpBranch %139
182        %136 = OpLabel
183        %137 = OpAccessChain %53 %52 %20 %25
184        %138 = OpLoad %6 %137
185               OpStore %109 %138
186               OpBranch %139
187        %139 = OpLabel
188        %140 = OpLoad %6 %109
189        %141 = OpExtInst %6 %1 FMax %128 %140
190        %142 = OpCompositeConstruct %7 %141 %141 %141
191         %77 = OpConvertSToF %6 %114
192         %78 = OpCompositeConstruct %7 %77 %77 %77
193         %80 = OpFOrdEqual %79 %142 %78
194         %81 = OpAll %26 %80
195               OpSelectionMerge %83 None
196               OpBranchConditional %81 %82 %100
197        %100 = OpLabel
198        %101 = OpAccessChain %21 %19 %20 %25
199        %102 = OpLoad %11 %101
200        %103 = OpConvertSToF %6 %102
201        %104 = OpCompositeConstruct %84 %103 %103 %103 %103
202               OpStore %86 %104
203               OpBranch %83
204         %82 = OpLabel
205         %90 = OpAccessChain %21 %19 %20 %25
206         %91 = OpLoad %11 %90
207         %92 = OpConvertSToF %6 %91
208         %99 = OpCompositeConstruct %84 %77 %92 %92 %77
209               OpStore %86 %99
210               OpBranch %83
211         %83 = OpLabel
212               OpReturn
213               OpFunctionEnd
214END
215
216# uniforms for variant
217
218# _GLF_uniform_int_values
219BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
220 1 0
221END
222# _GLF_uniform_float_values
223BUFFER variant__GLF_uniform_float_values DATA_TYPE float[] STD140 DATA
224 1.0 0.0
225END
226
227BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
228
229PIPELINE graphics variant_pipeline
230  ATTACH variant_vertex_shader
231  ATTACH variant_fragment_shader
232  FRAMEBUFFER_SIZE 32 32
233  BIND BUFFER variant_framebuffer AS color LOCATION 0
234  BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 1
235  BIND BUFFER variant__GLF_uniform_float_values AS uniform DESCRIPTOR_SET 0 BINDING 0
236END
237CLEAR_COLOR variant_pipeline 0 0 0 255
238
239CLEAR variant_pipeline
240RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 32 32
241
242EXPECT variant_framebuffer IDX 0 0 SIZE 32 32 EQ_RGBA 255 0 0 255
243