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