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 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:
29 # #define _int_0 _GLF_uniform_int_values[0]
30 # #define _int_1 _GLF_uniform_int_values[1]
31 # #define _float_0_0 _GLF_uniform_float_values[0]
33 # precision highp int;
34 # precision highp float;
36 # // Contents of _GLF_uniform_int_values: [0, 1]
37 # layout(set = 0, binding = 0) uniform buf0
39 # int _GLF_uniform_int_values[2];
42 # // Contents of _GLF_uniform_float_values: 0.0
43 # layout(set = 0, binding = 1) uniform buf1
45 # float _GLF_uniform_float_values[1];
48 # layout(location = 0) out vec4 _GLF_color;
52 # // fract(trunc(x)) is always 0.
53 # float f = fract(trunc(float(_int_1)));
58 # _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1);
62 # _GLF_color = vec4(_int_0);
65 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
68 ; Generator: Khronos Glslang Reference Front End; 10
72 %1 = OpExtInstImport "GLSL.std.450"
73 OpMemoryModel Logical GLSL450
74 OpEntryPoint Fragment %4 "main" %39
75 OpExecutionMode %4 OriginUpperLeft
80 OpMemberName %13 0 "_GLF_uniform_int_values"
83 OpMemberName %27 0 "_GLF_uniform_float_values"
85 OpName %39 "_GLF_color"
86 OpDecorate %12 ArrayStride 16
87 OpMemberDecorate %13 0 Offset 0
89 OpDecorate %15 DescriptorSet 0
90 OpDecorate %15 Binding 0
91 OpDecorate %26 ArrayStride 16
92 OpMemberDecorate %27 0 Offset 0
94 OpDecorate %29 DescriptorSet 0
95 OpDecorate %29 Binding 1
96 OpDecorate %39 Location 0
98 %3 = OpTypeFunction %2
100 %7 = OpTypePointer Function %6
103 %11 = OpConstant %10 2
104 %12 = OpTypeArray %9 %11
105 %13 = OpTypeStruct %12
106 %14 = OpTypePointer Uniform %13
107 %15 = OpVariable %14 Uniform
108 %16 = OpConstant %9 0
109 %17 = OpConstant %9 1
110 %18 = OpTypePointer Uniform %9
111 %25 = OpConstant %10 1
112 %26 = OpTypeArray %6 %25
113 %27 = OpTypeStruct %26
114 %28 = OpTypePointer Uniform %27
115 %29 = OpVariable %28 Uniform
116 %30 = OpTypePointer Uniform %6
118 %37 = OpTypeVector %6 4
119 %38 = OpTypePointer Output %37
120 %39 = OpVariable %38 Output
121 %4 = OpFunction %2 None %3
123 %8 = OpVariable %7 Function
124 %19 = OpAccessChain %18 %15 %16 %17
126 %21 = OpConvertSToF %6 %20
127 %22 = OpExtInst %6 %1 Trunc %21
128 %23 = OpExtInst %6 %1 Fract %22
131 %31 = OpAccessChain %30 %29 %16 %16
133 %34 = OpFOrdEqual %33 %24 %32
134 OpSelectionMerge %36 None
135 OpBranchConditional %34 %35 %53
137 %40 = OpAccessChain %18 %15 %16 %17
139 %42 = OpConvertSToF %6 %41
140 %43 = OpAccessChain %18 %15 %16 %16
142 %45 = OpConvertSToF %6 %44
143 %46 = OpAccessChain %18 %15 %16 %16
145 %48 = OpConvertSToF %6 %47
146 %49 = OpAccessChain %18 %15 %16 %17
148 %51 = OpConvertSToF %6 %50
149 %52 = OpCompositeConstruct %37 %42 %45 %48 %51
153 %54 = OpAccessChain %18 %15 %16 %16
155 %56 = OpConvertSToF %6 %55
156 %57 = OpCompositeConstruct %37 %56 %56 %56 %56
164 # uniforms for variant
166 # _GLF_uniform_float_values
167 BUFFER variant__GLF_uniform_float_values DATA_TYPE float[] STD140 DATA
170 # _GLF_uniform_int_values
171 BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
175 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
177 PIPELINE graphics variant_pipeline
178 ATTACH variant_vertex_shader
179 ATTACH variant_fragment_shader
180 FRAMEBUFFER_SIZE 256 256
181 BIND BUFFER variant_framebuffer AS color LOCATION 0
182 BIND BUFFER variant__GLF_uniform_float_values AS uniform DESCRIPTOR_SET 0 BINDING 1
183 BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 0
185 CLEAR_COLOR variant_pipeline 0 0 0 255
187 CLEAR variant_pipeline
188 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
190 EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255