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_0 _GLF_uniform_int_values[0]
29 # #define _int_1 _GLF_uniform_int_values[1]
30 # #define _float_10_0 _GLF_uniform_float_values[0]
32 # precision highp float;
33 # precision highp int;
35 # // Contents of _GLF_uniform_float_values: 10.0
36 # layout(set = 0, binding = 0) uniform buf0
38 # float _GLF_uniform_float_values[1];
41 # // Contents of _GLF_uniform_int_values: [0, 1]
42 # layout(set = 0, binding = 1) uniform buf1
44 # int _GLF_uniform_int_values[2];
47 # layout(location = 0) out vec4 _GLF_color;
53 # if(gl_FragCoord.y < _float_10_0)
58 # // Here a is either 0 or -1. Both will return -1 when input to findMSB.
59 # if(findMSB(a) == -_int_1)
61 # _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1);
65 # _GLF_color = vec4(_int_0);
68 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
71 ; Generator: Khronos Glslang Reference Front End; 10
75 %1 = OpExtInstImport "GLSL.std.450"
76 OpMemoryModel Logical GLSL450
77 OpEntryPoint Fragment %4 "main" %13 %48
78 OpExecutionMode %4 OriginUpperLeft
82 OpName %13 "gl_FragCoord"
84 OpMemberName %20 0 "_GLF_uniform_float_values"
87 OpMemberName %37 0 "_GLF_uniform_int_values"
89 OpName %48 "_GLF_color"
90 OpDecorate %13 BuiltIn FragCoord
91 OpDecorate %19 ArrayStride 16
92 OpMemberDecorate %20 0 Offset 0
94 OpDecorate %22 DescriptorSet 0
95 OpDecorate %22 Binding 0
96 OpDecorate %36 ArrayStride 16
97 OpMemberDecorate %37 0 Offset 0
99 OpDecorate %39 DescriptorSet 0
100 OpDecorate %39 Binding 1
101 OpDecorate %48 Location 0
103 %3 = OpTypeFunction %2
105 %7 = OpTypePointer Function %6
108 %11 = OpTypeVector %10 4
109 %12 = OpTypePointer Input %11
110 %13 = OpVariable %12 Input
112 %15 = OpConstant %14 1
113 %16 = OpTypePointer Input %10
114 %19 = OpTypeArray %10 %15
115 %20 = OpTypeStruct %19
116 %21 = OpTypePointer Uniform %20
117 %22 = OpVariable %21 Uniform
118 %23 = OpTypePointer Uniform %10
120 %31 = OpConstant %6 1
121 %35 = OpConstant %14 2
122 %36 = OpTypeArray %6 %35
123 %37 = OpTypeStruct %36
124 %38 = OpTypePointer Uniform %37
125 %39 = OpVariable %38 Uniform
126 %40 = OpTypePointer Uniform %6
127 %47 = OpTypePointer Output %11
128 %48 = OpVariable %47 Output
129 %4 = OpFunction %2 None %3
131 %8 = OpVariable %7 Function
133 %17 = OpAccessChain %16 %13 %15
135 %24 = OpAccessChain %23 %22 %9 %9
137 %27 = OpFOrdLessThan %26 %18 %25
138 OpSelectionMerge %29 None
139 OpBranchConditional %27 %28 %29
142 %32 = OpISub %6 %30 %31
147 %34 = OpExtInst %6 %1 FindSMsb %33
148 %41 = OpAccessChain %40 %39 %9 %31
150 %43 = OpSNegate %6 %42
151 %44 = OpIEqual %26 %34 %43
152 OpSelectionMerge %46 None
153 OpBranchConditional %44 %45 %62
155 %49 = OpAccessChain %40 %39 %9 %31
157 %51 = OpConvertSToF %10 %50
158 %52 = OpAccessChain %40 %39 %9 %9
160 %54 = OpConvertSToF %10 %53
161 %55 = OpAccessChain %40 %39 %9 %9
163 %57 = OpConvertSToF %10 %56
164 %58 = OpAccessChain %40 %39 %9 %31
166 %60 = OpConvertSToF %10 %59
167 %61 = OpCompositeConstruct %11 %51 %54 %57 %60
171 %63 = OpAccessChain %40 %39 %9 %9
173 %65 = OpConvertSToF %10 %64
174 %66 = OpCompositeConstruct %11 %65 %65 %65 %65
182 # uniforms for variant
184 # _GLF_uniform_int_values
185 BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
188 # _GLF_uniform_float_values
189 BUFFER variant__GLF_uniform_float_values DATA_TYPE float[] STD140 DATA
193 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
195 PIPELINE graphics variant_pipeline
196 ATTACH variant_vertex_shader
197 ATTACH variant_fragment_shader
198 FRAMEBUFFER_SIZE 32 32
199 BIND BUFFER variant_framebuffer AS color LOCATION 0
200 BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 1
201 BIND BUFFER variant__GLF_uniform_float_values AS uniform DESCRIPTOR_SET 0 BINDING 0
203 CLEAR_COLOR variant_pipeline 0 0 0 255
205 CLEAR variant_pipeline
206 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 32 32
208 EXPECT variant_framebuffer IDX 0 0 SIZE 32 32 EQ_RGBA 255 0 0 255