3 # Copyright 2021 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 NIR 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_1_58 _GLF_uniform_float_values[0]
31 # #define _float_1_55 _GLF_uniform_float_values[1]
33 # precision highp float;
34 # precision highp int;
36 # // Contents of _GLF_uniform_float_values: [1.58, 1.55]
37 # layout(set = 0, binding = 0) uniform buf0
39 # float _GLF_uniform_float_values[2];
42 # // Contents of _GLF_uniform_int_values: [0, 1]
43 # layout(set = 0, binding = 1) uniform buf1 {
44 # int _GLF_uniform_int_values[2];
47 # layout(location = 0) out vec4 _GLF_color;
51 # vec4 v = vec4(_int_0, _int_0, -621.596, _int_0);
52 # float f = atan(trunc(v)).z;
55 # if(f > - _float_1_58 && f < - _float_1_55)
57 # _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1);
61 # _GLF_color = vec4(_int_0);
64 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
67 ; Generator: Khronos Glslang Reference Front End; 10
71 %1 = OpExtInstImport "GLSL.std.450"
72 OpMemoryModel Logical GLSL450
73 OpEntryPoint Fragment %4 "main" %59
74 OpExecutionMode %4 OriginUpperLeft
79 OpMemberName %14 0 "_GLF_uniform_int_values"
83 OpMemberName %39 0 "_GLF_uniform_float_values"
85 OpName %59 "_GLF_color"
86 OpDecorate %13 ArrayStride 16
87 OpMemberDecorate %14 0 Offset 0
89 OpDecorate %16 DescriptorSet 0
90 OpDecorate %16 Binding 1
91 OpDecorate %38 ArrayStride 16
92 OpMemberDecorate %39 0 Offset 0
94 OpDecorate %41 DescriptorSet 0
95 OpDecorate %41 Binding 0
96 OpDecorate %59 Location 0
98 %3 = OpTypeFunction %2
100 %7 = OpTypeVector %6 4
101 %8 = OpTypePointer Function %7
104 %12 = OpConstant %11 2
105 %13 = OpTypeArray %10 %12
106 %14 = OpTypeStruct %13
107 %15 = OpTypePointer Uniform %14
108 %16 = OpVariable %15 Uniform
109 %17 = OpConstant %10 0
110 %18 = OpTypePointer Uniform %10
111 %25 = OpConstant %6 -621.596008
112 %30 = OpTypePointer Function %6
114 %38 = OpTypeArray %6 %12
115 %39 = OpTypeStruct %38
116 %40 = OpTypePointer Uniform %39
117 %41 = OpVariable %40 Uniform
118 %42 = OpTypePointer Uniform %6
119 %50 = OpConstant %10 1
120 %58 = OpTypePointer Output %7
121 %59 = OpVariable %58 Output
122 %4 = OpFunction %2 None %3
124 %9 = OpVariable %8 Function
125 %31 = OpVariable %30 Function
126 %19 = OpAccessChain %18 %16 %17 %17
128 %21 = OpConvertSToF %6 %20
129 %22 = OpAccessChain %18 %16 %17 %17
131 %24 = OpConvertSToF %6 %23
132 %26 = OpAccessChain %18 %16 %17 %17
134 %28 = OpConvertSToF %6 %27
135 %29 = OpCompositeConstruct %7 %21 %24 %25 %28
138 %33 = OpExtInst %7 %1 Trunc %32
139 %34 = OpExtInst %7 %1 Atan %33
140 %35 = OpCompositeExtract %6 %34 2
143 %43 = OpAccessChain %42 %41 %17 %17
145 %45 = OpFNegate %6 %44
146 %46 = OpFOrdGreaterThan %36 %37 %45
147 OpSelectionMerge %48 None
148 OpBranchConditional %46 %47 %48
151 %51 = OpAccessChain %42 %41 %17 %50
153 %53 = OpFNegate %6 %52
154 %54 = OpFOrdLessThan %36 %49 %53
157 %55 = OpPhi %36 %46 %5 %54 %47
158 OpSelectionMerge %57 None
159 OpBranchConditional %55 %56 %73
161 %60 = OpAccessChain %18 %16 %17 %50
163 %62 = OpConvertSToF %6 %61
164 %63 = OpAccessChain %18 %16 %17 %17
166 %65 = OpConvertSToF %6 %64
167 %66 = OpAccessChain %18 %16 %17 %17
169 %68 = OpConvertSToF %6 %67
170 %69 = OpAccessChain %18 %16 %17 %50
172 %71 = OpConvertSToF %6 %70
173 %72 = OpCompositeConstruct %7 %62 %65 %68 %71
177 %74 = OpAccessChain %18 %16 %17 %17
179 %76 = OpConvertSToF %6 %75
180 %77 = OpCompositeConstruct %7 %76 %76 %76 %76
188 # uniforms for variant
190 # _GLF_uniform_int_values
191 BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
194 # _GLF_uniform_float_values
195 BUFFER variant__GLF_uniform_float_values DATA_TYPE float[] STD140 DATA
199 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
201 PIPELINE graphics variant_pipeline
202 ATTACH variant_vertex_shader
203 ATTACH variant_fragment_shader
204 FRAMEBUFFER_SIZE 256 256
205 BIND BUFFER variant_framebuffer AS color LOCATION 0
206 BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 1
207 BIND BUFFER variant__GLF_uniform_float_values AS uniform DESCRIPTOR_SET 0 BINDING 0
209 CLEAR_COLOR variant_pipeline 0 0 0 255
211 CLEAR variant_pipeline
212 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
214 EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255