3 # Copyright 2022 Google LLC
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
9 # http://www.apache.org/licenses/LICENSE-2.0
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.
18 # A test for a coverage-gap found by the GraphicsFuzz project.
20 # Short description: A fragment shader that covers specific LLVM code paths
22 # The test passes because the shader always writes red.
24 SHADER vertex variant_vertex_shader PASSTHROUGH
26 # variant_fragment_shader is derived from the following GLSL:
28 # #define _int_1 _GLF_uniform_int_values[0]
29 # #define _int_0 _GLF_uniform_int_values[1]
31 # precision highp int;
32 # precision highp float;
34 # // Contents of _GLF_uniform_int_values: [1, 0]
35 # layout(set = 0, binding = 0) uniform buf0
37 # int _GLF_uniform_int_values[2];
40 # // Contents of zero: 0
41 # layout(set = 0, binding = 1) uniform buf1
46 # layout(location = 0) out vec4 _GLF_color;
50 # _GLF_color = vec4(_int_1, _int_0, _int_0, 1);
53 # // Iterates until a reaches seven.
62 # vec4 v = _GLF_color;
64 # // The original value is always restored below.
65 # _GLF_color = vec4(a);
68 # if(gl_FragCoord.x >= 0.0)
73 # while(_int_1 > zero);
75 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
78 ; Generator: Khronos Glslang Reference Front End; 10
82 %1 = OpExtInstImport "GLSL.std.450"
83 OpMemoryModel Logical GLSL450
84 OpEntryPoint Fragment %4 "main" %9 %52
85 OpExecutionMode %4 OriginUpperLeft
88 OpName %9 "_GLF_color"
90 OpMemberName %14 0 "_GLF_uniform_int_values"
94 OpName %52 "gl_FragCoord"
96 OpMemberName %64 0 "zero"
98 OpDecorate %9 Location 0
99 OpDecorate %13 ArrayStride 16
100 OpMemberDecorate %14 0 Offset 0
102 OpDecorate %16 DescriptorSet 0
103 OpDecorate %16 Binding 0
104 OpDecorate %52 BuiltIn FragCoord
105 OpMemberDecorate %64 0 Offset 0
107 OpDecorate %66 DescriptorSet 0
108 OpDecorate %66 Binding 1
110 %3 = OpTypeFunction %2
112 %7 = OpTypeVector %6 4
113 %8 = OpTypePointer Output %7
114 %9 = OpVariable %8 Output
117 %12 = OpConstant %11 2
118 %13 = OpTypeArray %10 %12
119 %14 = OpTypeStruct %13
120 %15 = OpTypePointer Uniform %14
121 %16 = OpVariable %15 Uniform
122 %17 = OpConstant %10 0
123 %18 = OpTypePointer Uniform %10
124 %22 = OpConstant %10 1
125 %29 = OpConstant %6 1
126 %31 = OpTypePointer Function %10
127 %39 = OpConstant %10 7
129 %45 = OpTypePointer Function %7
130 %51 = OpTypePointer Input %7
131 %52 = OpVariable %51 Input
132 %53 = OpConstant %11 0
133 %54 = OpTypePointer Input %6
134 %57 = OpConstant %6 0
135 %64 = OpTypeStruct %10
136 %65 = OpTypePointer Uniform %64
137 %66 = OpVariable %65 Uniform
138 %4 = OpFunction %2 None %3
140 %32 = OpVariable %31 Function
141 %46 = OpVariable %45 Function
142 %19 = OpAccessChain %18 %16 %17 %17
144 %21 = OpConvertSToF %6 %20
145 %23 = OpAccessChain %18 %16 %17 %22
147 %25 = OpConvertSToF %6 %24
148 %26 = OpAccessChain %18 %16 %17 %22
150 %28 = OpConvertSToF %6 %27
151 %30 = OpCompositeConstruct %7 %21 %25 %28 %29
156 OpLoopMerge %35 %36 None
160 %38 = OpIAdd %10 %37 %22
162 %41 = OpSGreaterThanEqual %40 %37 %39
163 OpSelectionMerge %43 None
164 OpBranchConditional %41 %42 %43
171 %49 = OpConvertSToF %6 %48
172 %50 = OpCompositeConstruct %7 %49 %49 %49 %49
174 %55 = OpAccessChain %54 %52 %53
176 %58 = OpFOrdGreaterThanEqual %40 %56 %57
177 OpSelectionMerge %60 None
178 OpBranchConditional %58 %59 %60
186 %62 = OpAccessChain %18 %16 %17 %17
188 %67 = OpAccessChain %18 %66 %17
190 %69 = OpSGreaterThan %40 %63 %68
191 OpBranchConditional %69 %33 %35
197 # uniforms for variant
200 BUFFER variant_zero DATA_TYPE int32 STD140 DATA
203 # _GLF_uniform_int_values
204 BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
208 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
210 PIPELINE graphics variant_pipeline
211 ATTACH variant_vertex_shader
212 ATTACH variant_fragment_shader
213 FRAMEBUFFER_SIZE 32 32
214 BIND BUFFER variant_framebuffer AS color LOCATION 0
215 BIND BUFFER variant_zero AS uniform DESCRIPTOR_SET 0 BINDING 1
216 BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 0
218 CLEAR_COLOR variant_pipeline 0 0 0 255
220 CLEAR variant_pipeline
221 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 32 32
223 EXPECT variant_framebuffer IDX 0 0 SIZE 32 32 EQ_RGBA 255 0 0 255