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 float;
32 # precision highp int;
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 # layout(location = 0) out vec4 _GLF_color;
44 # int a = (int(gl_FragCoord.y) & 1) != 0 ? 0 : ~ 0;
46 # // b becomes one: regardless of what a is, (a | ~a) always produces an integer with all bits on.
47 # int b = _int_1 & (a | ~a);
52 # _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1);
56 # _GLF_color = vec4(_int_0);
59 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
62 ; Generator: Khronos Glslang Reference Front End; 10
66 %1 = OpExtInstImport "GLSL.std.450"
67 OpMemoryModel Logical GLSL450
68 OpEntryPoint Fragment %4 "main" %12 %47
69 OpExecutionMode %4 OriginUpperLeft
73 OpName %12 "gl_FragCoord"
76 OpMemberName %29 0 "_GLF_uniform_int_values"
78 OpName %47 "_GLF_color"
79 OpDecorate %12 BuiltIn FragCoord
80 OpDecorate %28 ArrayStride 16
81 OpMemberDecorate %29 0 Offset 0
83 OpDecorate %31 DescriptorSet 0
84 OpDecorate %31 Binding 0
85 OpDecorate %47 Location 0
87 %3 = OpTypeFunction %2
89 %7 = OpTypePointer Function %6
91 %10 = OpTypeVector %9 4
92 %11 = OpTypePointer Input %10
93 %12 = OpVariable %11 Input
95 %14 = OpConstant %13 1
96 %15 = OpTypePointer Input %9
100 %24 = OpConstant %6 -1
101 %27 = OpConstant %13 2
102 %28 = OpTypeArray %6 %27
103 %29 = OpTypeStruct %28
104 %30 = OpTypePointer Uniform %29
105 %31 = OpVariable %30 Uniform
106 %32 = OpTypePointer Uniform %6
107 %46 = OpTypePointer Output %10
108 %47 = OpVariable %46 Output
109 %4 = OpFunction %2 None %3
111 %8 = OpVariable %7 Function
112 %26 = OpVariable %7 Function
113 %16 = OpAccessChain %15 %12 %14
115 %18 = OpConvertFToS %6 %17
116 %20 = OpBitwiseAnd %6 %18 %19
117 %23 = OpINotEqual %22 %20 %21
118 %25 = OpSelect %6 %23 %21 %24
120 %33 = OpAccessChain %32 %31 %21 %21
125 %38 = OpBitwiseOr %6 %35 %37
126 %39 = OpBitwiseAnd %6 %34 %38
129 %41 = OpAccessChain %32 %31 %21 %21
131 %43 = OpIEqual %22 %40 %42
132 OpSelectionMerge %45 None
133 OpBranchConditional %43 %44 %61
135 %48 = OpAccessChain %32 %31 %21 %21
137 %50 = OpConvertSToF %9 %49
138 %51 = OpAccessChain %32 %31 %21 %19
140 %53 = OpConvertSToF %9 %52
141 %54 = OpAccessChain %32 %31 %21 %19
143 %56 = OpConvertSToF %9 %55
144 %57 = OpAccessChain %32 %31 %21 %21
146 %59 = OpConvertSToF %9 %58
147 %60 = OpCompositeConstruct %10 %50 %53 %56 %59
151 %62 = OpAccessChain %32 %31 %21 %19
153 %64 = OpConvertSToF %9 %63
154 %65 = OpCompositeConstruct %10 %64 %64 %64 %64
162 # uniforms for variant
164 # _GLF_uniform_int_values
165 BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
169 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
171 PIPELINE graphics variant_pipeline
172 ATTACH variant_vertex_shader
173 ATTACH variant_fragment_shader
174 FRAMEBUFFER_SIZE 32 32
175 BIND BUFFER variant_framebuffer AS color LOCATION 0
176 BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 0
178 CLEAR_COLOR variant_pipeline 0 0 0 255
180 CLEAR variant_pipeline
181 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 32 32
183 EXPECT variant_framebuffer IDX 0 0 SIZE 32 32 EQ_RGBA 255 0 0 255