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_0_0 _GLF_uniform_float_values[0]
32 # precision highp float;
33 # precision highp int;
35 # // Contents of _GLF_uniform_float_values: 0.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;
51 # // 1u unpacked as a half float is a number very close to zero.
52 # // Rounding it makes it exactly zero.
53 # return round(unpackHalf2x16(1u)).x;
59 # if(func() == _float_0_0)
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" %38
78 OpExecutionMode %4 OriginUpperLeft
83 OpMemberName %24 0 "_GLF_uniform_float_values"
85 OpName %38 "_GLF_color"
87 OpMemberName %41 0 "_GLF_uniform_int_values"
89 OpDecorate %14 RelaxedPrecision
90 OpDecorate %16 RelaxedPrecision
91 OpDecorate %23 ArrayStride 16
92 OpMemberDecorate %24 0 Offset 0
94 OpDecorate %26 DescriptorSet 0
95 OpDecorate %26 Binding 0
96 OpDecorate %38 Location 0
97 OpDecorate %40 ArrayStride 16
98 OpMemberDecorate %41 0 Offset 0
100 OpDecorate %43 DescriptorSet 0
101 OpDecorate %43 Binding 1
103 %3 = OpTypeFunction %2
105 %7 = OpTypeFunction %6
107 %11 = OpConstant %10 1
108 %12 = OpTypeVector %6 2
109 %15 = OpConstant %10 0
110 %17 = OpTypePointer Function %6
111 %23 = OpTypeArray %6 %11
112 %24 = OpTypeStruct %23
113 %25 = OpTypePointer Uniform %24
114 %26 = OpVariable %25 Uniform
116 %28 = OpConstant %27 0
117 %29 = OpTypePointer Uniform %6
119 %36 = OpTypeVector %6 4
120 %37 = OpTypePointer Output %36
121 %38 = OpVariable %37 Output
122 %39 = OpConstant %10 2
123 %40 = OpTypeArray %27 %39
124 %41 = OpTypeStruct %40
125 %42 = OpTypePointer Uniform %41
126 %43 = OpVariable %42 Uniform
127 %44 = OpConstant %27 1
128 %45 = OpTypePointer Uniform %27
129 %4 = OpFunction %2 None %3
131 %22 = OpFunctionCall %6 %8
132 %30 = OpAccessChain %29 %26 %28 %28
134 %33 = OpFOrdEqual %32 %22 %31
135 OpSelectionMerge %35 None
136 OpBranchConditional %33 %34 %59
138 %46 = OpAccessChain %45 %43 %28 %44
140 %48 = OpConvertSToF %6 %47
141 %49 = OpAccessChain %45 %43 %28 %28
143 %51 = OpConvertSToF %6 %50
144 %52 = OpAccessChain %45 %43 %28 %28
146 %54 = OpConvertSToF %6 %53
147 %55 = OpAccessChain %45 %43 %28 %44
149 %57 = OpConvertSToF %6 %56
150 %58 = OpCompositeConstruct %36 %48 %51 %54 %57
154 %60 = OpAccessChain %45 %43 %28 %28
156 %62 = OpConvertSToF %6 %61
157 %63 = OpCompositeConstruct %36 %62 %62 %62 %62
163 %8 = OpFunction %6 None %7
165 %18 = OpVariable %17 Function
166 %13 = OpExtInst %12 %1 UnpackHalf2x16 %11
167 %14 = OpExtInst %12 %1 Round %13
168 %16 = OpCompositeExtract %6 %14 0
175 # uniforms for variant
177 # _GLF_uniform_int_values
178 BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
181 # _GLF_uniform_float_values
182 BUFFER variant__GLF_uniform_float_values DATA_TYPE float[] STD140 DATA
186 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
188 PIPELINE graphics variant_pipeline
189 ATTACH variant_vertex_shader
190 ATTACH variant_fragment_shader
191 FRAMEBUFFER_SIZE 32 32
192 BIND BUFFER variant_framebuffer AS color LOCATION 0
193 BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 1
194 BIND BUFFER variant__GLF_uniform_float_values AS uniform DESCRIPTOR_SET 0 BINDING 0
196 CLEAR_COLOR variant_pipeline 0 0 0 255
198 CLEAR variant_pipeline
199 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 32 32
201 EXPECT variant_framebuffer IDX 0 0 SIZE 32 32 EQ_RGBA 255 0 0 255