• 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
24SHADER vertex variant_vertex_shader PASSTHROUGH
25
26# variant_fragment_shader is derived from the following GLSL:
27# #version 320 es
28#
29# #define _int_1 _GLF_uniform_int_values[0]
30# #define _int_0 _GLF_uniform_int_values[1]
31# #define _int_2 _GLF_uniform_int_values[2]
32#
33# precision highp float;
34# precision highp int;
35#
36# // Contents of _GLF_uniform_int_values: [1, 0, 2]
37# layout(set = 0, binding = 0) uniform buf0
38# {
39#     int _GLF_uniform_int_values[3];
40# };
41#
42# layout(location = 0) out vec4 _GLF_color;
43#
44# void main()
45# {
46#     ivec4 v = ivec4(_int_1);
47#
48#     // Always true.
49#     if(_int_1 == 1)
50#     {
51#         // Iterates twice.
52#         for(int i = 2; i >= 1; i--)
53#         {
54#             // Iterates once when i = 2 and twice when i = 1.
55#             for(int j = _int_2; j >= i; j--)
56#             {
57#                 v[i]--;
58#             }
59#         }
60#     }
61#
62#     // Always true.
63#     if(v == ivec4(_int_1, -_int_1, _int_0, _int_1))
64#     {
65#         _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1);
66#     }
67#     else
68#     {
69#         _GLF_color = vec4(_int_0);
70#     }
71# }
72SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
73; SPIR-V
74; Version: 1.0
75; Generator: Khronos Glslang Reference Front End; 10
76; Bound: 95
77; Schema: 0
78               OpCapability Shader
79          %1 = OpExtInstImport "GLSL.std.450"
80               OpMemoryModel Logical GLSL450
81               OpEntryPoint Fragment %4 "main" %76
82               OpExecutionMode %4 OriginUpperLeft
83               OpSource ESSL 320
84               OpName %4 "main"
85               OpName %9 "v"
86               OpName %13 "buf0"
87               OpMemberName %13 0 "_GLF_uniform_int_values"
88               OpName %15 ""
89               OpName %29 "i"
90               OpName %38 "j"
91               OpName %76 "_GLF_color"
92               OpDecorate %12 ArrayStride 16
93               OpMemberDecorate %13 0 Offset 0
94               OpDecorate %13 Block
95               OpDecorate %15 DescriptorSet 0
96               OpDecorate %15 Binding 0
97               OpDecorate %76 Location 0
98          %2 = OpTypeVoid
99          %3 = OpTypeFunction %2
100          %6 = OpTypeInt 32 1
101          %7 = OpTypeVector %6 4
102          %8 = OpTypePointer Function %7
103         %10 = OpTypeInt 32 0
104         %11 = OpConstant %10 3
105         %12 = OpTypeArray %6 %11
106         %13 = OpTypeStruct %12
107         %14 = OpTypePointer Uniform %13
108         %15 = OpVariable %14 Uniform
109         %16 = OpConstant %6 0
110         %17 = OpTypePointer Uniform %6
111         %23 = OpConstant %6 1
112         %24 = OpTypeBool
113         %28 = OpTypePointer Function %6
114         %30 = OpConstant %6 2
115         %68 = OpTypeVector %24 4
116         %73 = OpTypeFloat 32
117         %74 = OpTypeVector %73 4
118         %75 = OpTypePointer Output %74
119         %76 = OpVariable %75 Output
120          %4 = OpFunction %2 None %3
121          %5 = OpLabel
122          %9 = OpVariable %8 Function
123         %29 = OpVariable %28 Function
124         %38 = OpVariable %28 Function
125         %18 = OpAccessChain %17 %15 %16 %16
126         %19 = OpLoad %6 %18
127         %20 = OpCompositeConstruct %7 %19 %19 %19 %19
128               OpStore %9 %20
129         %21 = OpAccessChain %17 %15 %16 %16
130         %22 = OpLoad %6 %21
131         %25 = OpIEqual %24 %22 %23
132               OpSelectionMerge %27 None
133               OpBranchConditional %25 %26 %27
134         %26 = OpLabel
135               OpStore %29 %30
136               OpBranch %31
137         %31 = OpLabel
138               OpLoopMerge %33 %34 None
139               OpBranch %35
140         %35 = OpLabel
141         %36 = OpLoad %6 %29
142         %37 = OpSGreaterThanEqual %24 %36 %23
143               OpBranchConditional %37 %32 %33
144         %32 = OpLabel
145         %39 = OpAccessChain %17 %15 %16 %30
146         %40 = OpLoad %6 %39
147               OpStore %38 %40
148               OpBranch %41
149         %41 = OpLabel
150               OpLoopMerge %43 %44 None
151               OpBranch %45
152         %45 = OpLabel
153         %46 = OpLoad %6 %38
154         %47 = OpLoad %6 %29
155         %48 = OpSGreaterThanEqual %24 %46 %47
156               OpBranchConditional %48 %42 %43
157         %42 = OpLabel
158         %49 = OpLoad %6 %29
159         %50 = OpAccessChain %28 %9 %49
160         %51 = OpLoad %6 %50
161         %52 = OpISub %6 %51 %23
162               OpStore %50 %52
163               OpBranch %44
164         %44 = OpLabel
165         %53 = OpLoad %6 %38
166         %54 = OpISub %6 %53 %23
167               OpStore %38 %54
168               OpBranch %41
169         %43 = OpLabel
170               OpBranch %34
171         %34 = OpLabel
172         %55 = OpLoad %6 %29
173         %56 = OpISub %6 %55 %23
174               OpStore %29 %56
175               OpBranch %31
176         %33 = OpLabel
177               OpBranch %27
178         %27 = OpLabel
179         %57 = OpLoad %7 %9
180         %58 = OpAccessChain %17 %15 %16 %16
181         %59 = OpLoad %6 %58
182         %60 = OpAccessChain %17 %15 %16 %16
183         %61 = OpLoad %6 %60
184         %62 = OpSNegate %6 %61
185         %63 = OpAccessChain %17 %15 %16 %23
186         %64 = OpLoad %6 %63
187         %65 = OpAccessChain %17 %15 %16 %16
188         %66 = OpLoad %6 %65
189         %67 = OpCompositeConstruct %7 %59 %62 %64 %66
190         %69 = OpIEqual %68 %57 %67
191         %70 = OpAll %24 %69
192               OpSelectionMerge %72 None
193               OpBranchConditional %70 %71 %90
194         %71 = OpLabel
195         %77 = OpAccessChain %17 %15 %16 %16
196         %78 = OpLoad %6 %77
197         %79 = OpConvertSToF %73 %78
198         %80 = OpAccessChain %17 %15 %16 %23
199         %81 = OpLoad %6 %80
200         %82 = OpConvertSToF %73 %81
201         %83 = OpAccessChain %17 %15 %16 %23
202         %84 = OpLoad %6 %83
203         %85 = OpConvertSToF %73 %84
204         %86 = OpAccessChain %17 %15 %16 %16
205         %87 = OpLoad %6 %86
206         %88 = OpConvertSToF %73 %87
207         %89 = OpCompositeConstruct %74 %79 %82 %85 %88
208               OpStore %76 %89
209               OpBranch %72
210         %90 = OpLabel
211         %91 = OpAccessChain %17 %15 %16 %23
212         %92 = OpLoad %6 %91
213         %93 = OpConvertSToF %73 %92
214         %94 = OpCompositeConstruct %74 %93 %93 %93 %93
215               OpStore %76 %94
216               OpBranch %72
217         %72 = OpLabel
218               OpReturn
219               OpFunctionEnd
220END
221
222# uniforms for variant
223
224# _GLF_uniform_int_values
225BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
226 1 0 2
227END
228
229BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
230
231PIPELINE graphics variant_pipeline
232  ATTACH variant_vertex_shader
233  ATTACH variant_fragment_shader
234  FRAMEBUFFER_SIZE 32 32
235  BIND BUFFER variant_framebuffer AS color LOCATION 0
236  BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 0
237END
238CLEAR_COLOR variant_pipeline 0 0 0 255
239
240CLEAR variant_pipeline
241RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 32 32
242
243EXPECT variant_framebuffer IDX 0 0 SIZE 32 32 EQ_RGBA 255 0 0 255
244