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:
28 # #define _int_1 _GLF_uniform_int_values[0]
29 # #define _int_0 _GLF_uniform_int_values[1]
30 # #define _float_2_0 _GLF_uniform_float_values[0]
31 # #define _float_1_0 _GLF_uniform_float_values[1]
33 # precision highp int;
34 # precision highp float;
36 # // Contents of _GLF_uniform_int_values: [1, 0]
37 # layout(set = 0, binding = 0) uniform buf0
39 # int _GLF_uniform_int_values[2];
42 # // Contents of _GLF_uniform_float_values: [2.0, 1.0]
43 # layout(set = 0, binding = 1) uniform buf1
45 # float _GLF_uniform_float_values[2];
48 # layout(location = 0) out vec4 _GLF_color;
52 # // (1, 1 - (-0)) dot (1, 1) = (1, 1) dot (1, 1) = 1 * 1 + 1 * 1 = 2
53 # float f = dot(vec2(_float_1_0, _float_1_0 - (- 0.0)), vec2(_float_1_0));
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" %40
75 OpExecutionMode %4 OriginUpperLeft
80 OpMemberName %12 0 "_GLF_uniform_float_values"
82 OpName %40 "_GLF_color"
84 OpMemberName %42 0 "_GLF_uniform_int_values"
86 OpDecorate %11 ArrayStride 16
87 OpMemberDecorate %12 0 Offset 0
89 OpDecorate %14 DescriptorSet 0
90 OpDecorate %14 Binding 1
91 OpDecorate %40 Location 0
92 OpDecorate %41 ArrayStride 16
93 OpMemberDecorate %42 0 Offset 0
95 OpDecorate %44 DescriptorSet 0
96 OpDecorate %44 Binding 0
98 %3 = OpTypeFunction %2
100 %7 = OpTypePointer Function %6
102 %10 = OpConstant %9 2
103 %11 = OpTypeArray %6 %10
104 %12 = OpTypeStruct %11
105 %13 = OpTypePointer Uniform %12
106 %14 = OpVariable %13 Uniform
108 %16 = OpConstant %15 0
109 %17 = OpConstant %15 1
110 %18 = OpTypePointer Uniform %6
111 %23 = OpConstant %6 -0
112 %25 = OpTypeVector %6 2
114 %38 = OpTypeVector %6 4
115 %39 = OpTypePointer Output %38
116 %40 = OpVariable %39 Output
117 %41 = OpTypeArray %15 %10
118 %42 = OpTypeStruct %41
119 %43 = OpTypePointer Uniform %42
120 %44 = OpVariable %43 Uniform
121 %45 = OpTypePointer Uniform %15
122 %4 = OpFunction %2 None %3
124 %8 = OpVariable %7 Function
125 %19 = OpAccessChain %18 %14 %16 %17
127 %21 = OpAccessChain %18 %14 %16 %17
129 %24 = OpFSub %6 %22 %23
130 %26 = OpCompositeConstruct %25 %20 %24
131 %27 = OpAccessChain %18 %14 %16 %17
133 %29 = OpCompositeConstruct %25 %28 %28
134 %30 = OpDot %6 %26 %29
137 %32 = OpAccessChain %18 %14 %16 %16
139 %35 = OpFOrdEqual %34 %31 %33
140 OpSelectionMerge %37 None
141 OpBranchConditional %35 %36 %59
143 %46 = OpAccessChain %45 %44 %16 %16
145 %48 = OpConvertSToF %6 %47
146 %49 = OpAccessChain %45 %44 %16 %17
148 %51 = OpConvertSToF %6 %50
149 %52 = OpAccessChain %45 %44 %16 %17
151 %54 = OpConvertSToF %6 %53
152 %55 = OpAccessChain %45 %44 %16 %16
154 %57 = OpConvertSToF %6 %56
155 %58 = OpCompositeConstruct %38 %48 %51 %54 %57
159 %60 = OpAccessChain %45 %44 %16 %17
161 %62 = OpConvertSToF %6 %61
162 %63 = OpCompositeConstruct %38 %62 %62 %62 %62
170 # uniforms for variant
172 # _GLF_uniform_float_values
173 BUFFER variant__GLF_uniform_float_values DATA_TYPE float[] STD140 DATA
176 # _GLF_uniform_int_values
177 BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
181 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
183 PIPELINE graphics variant_pipeline
184 ATTACH variant_vertex_shader
185 ATTACH variant_fragment_shader
186 FRAMEBUFFER_SIZE 256 256
187 BIND BUFFER variant_framebuffer AS color LOCATION 0
188 BIND BUFFER variant__GLF_uniform_float_values AS uniform DESCRIPTOR_SET 0 BINDING 1
189 BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 0
191 CLEAR_COLOR variant_pipeline 0 0 0 255
193 CLEAR variant_pipeline
194 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
196 EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255