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 # // Depending on the pixel location a has either all or none bits enabled.
45 # int a = (int(gl_FragCoord.x) & 1) != 0 ? 0 : ~0;
48 # // ~(a | 1) = ~1 != 1
51 # // ~(a | 1) = ~(~0)) = 0 != 1
52 # if(~(a | _int_1) != _int_1)
54 # _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1);
58 # _GLF_color = vec4(_int_0);
61 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
64 ; Generator: Khronos Glslang Reference Front End; 10
68 %1 = OpExtInstImport "GLSL.std.450"
69 OpMemoryModel Logical GLSL450
70 OpEntryPoint Fragment %4 "main" %12 %43
71 OpExecutionMode %4 OriginUpperLeft
75 OpName %12 "gl_FragCoord"
77 OpMemberName %29 0 "_GLF_uniform_int_values"
79 OpName %43 "_GLF_color"
80 OpDecorate %12 BuiltIn FragCoord
81 OpDecorate %28 ArrayStride 16
82 OpMemberDecorate %29 0 Offset 0
84 OpDecorate %31 DescriptorSet 0
85 OpDecorate %31 Binding 0
86 OpDecorate %43 Location 0
88 %3 = OpTypeFunction %2
90 %7 = OpTypePointer Function %6
92 %10 = OpTypeVector %9 4
93 %11 = OpTypePointer Input %10
94 %12 = OpVariable %11 Input
96 %14 = OpConstant %13 0
97 %15 = OpTypePointer Input %9
101 %24 = OpConstant %6 -1
102 %27 = OpConstant %13 2
103 %28 = OpTypeArray %6 %27
104 %29 = OpTypeStruct %28
105 %30 = OpTypePointer Uniform %29
106 %31 = OpVariable %30 Uniform
107 %32 = OpTypePointer Uniform %6
108 %42 = OpTypePointer Output %10
109 %43 = OpVariable %42 Output
110 %4 = OpFunction %2 None %3
112 %8 = 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
121 %33 = OpAccessChain %32 %31 %21 %21
123 %35 = OpBitwiseOr %6 %26 %34
125 %37 = OpAccessChain %32 %31 %21 %21
127 %39 = OpINotEqual %22 %36 %38
128 OpSelectionMerge %41 None
129 OpBranchConditional %39 %40 %57
131 %44 = OpAccessChain %32 %31 %21 %21
133 %46 = OpConvertSToF %9 %45
134 %47 = OpAccessChain %32 %31 %21 %19
136 %49 = OpConvertSToF %9 %48
137 %50 = OpAccessChain %32 %31 %21 %19
139 %52 = OpConvertSToF %9 %51
140 %53 = OpAccessChain %32 %31 %21 %21
142 %55 = OpConvertSToF %9 %54
143 %56 = OpCompositeConstruct %10 %46 %49 %52 %55
147 %58 = OpAccessChain %32 %31 %21 %19
149 %60 = OpConvertSToF %9 %59
150 %61 = OpCompositeConstruct %10 %60 %60 %60 %60
158 # uniforms for variant
160 # _GLF_uniform_int_values
161 BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
165 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
167 PIPELINE graphics variant_pipeline
168 ATTACH variant_vertex_shader
169 ATTACH variant_fragment_shader
170 FRAMEBUFFER_SIZE 32 32
171 BIND BUFFER variant_framebuffer AS color LOCATION 0
172 BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 0
174 CLEAR_COLOR variant_pipeline 0 0 0 255
176 CLEAR variant_pipeline
177 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 32 32
179 EXPECT variant_framebuffer IDX 0 0 SIZE 32 32 EQ_RGBA 255 0 0 255