3 # Copyright 2020 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 a specific instruction combine compare code path
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_0_0 _GLF_uniform_float_values[0]
31 # #define _float_1_0 _GLF_uniform_float_values[1]
32 # #define _float_2_0 _GLF_uniform_float_values[2]
33 # #define _float_3_0 _GLF_uniform_float_values[3]
35 # precision highp float;
36 # precision highp int;
38 # // Contents of _GLF_uniform_float_values: [0.0, 1.0, 2.0, 3.0]
39 # layout(set = 0, binding = 0) uniform buf0
41 # float _GLF_uniform_float_values[4];
44 # // Contents of _GLF_uniform_int_values: [1, 0]
45 # layout(set = 0, binding = 1) uniform buf1
47 # int _GLF_uniform_int_values[2];
50 # layout(location = 0) out vec4 _GLF_color;
55 # int a = (gl_FragCoord.y >= _float_0_0) ? 0 : 2;
57 # float b = vec3(_float_1_0, _float_2_0, _float_3_0)[a];
59 # if (b == _float_1_0)
61 # _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1);
65 # _GLF_color = vec4(_int_1);
68 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
71 ; Generator: Khronos Glslang Reference Front End; 8
75 %1 = OpExtInstImport "GLSL.std.450"
76 OpMemoryModel Logical GLSL450
77 OpEntryPoint Fragment %4 "main" %12 %52
78 OpExecutionMode %4 OriginUpperLeft
82 OpName %12 "gl_FragCoord"
84 OpMemberName %20 0 "_GLF_uniform_float_values"
87 OpName %52 "_GLF_color"
89 OpMemberName %55 0 "_GLF_uniform_int_values"
91 OpDecorate %12 BuiltIn FragCoord
92 OpDecorate %19 ArrayStride 16
93 OpMemberDecorate %20 0 Offset 0
95 OpDecorate %22 DescriptorSet 0
96 OpDecorate %22 Binding 0
97 OpDecorate %52 Location 0
98 OpDecorate %54 ArrayStride 16
99 OpMemberDecorate %55 0 Offset 0
101 OpDecorate %57 DescriptorSet 0
102 OpDecorate %57 Binding 1
104 %3 = OpTypeFunction %2
106 %7 = OpTypePointer Function %6
108 %10 = OpTypeVector %9 4
109 %11 = OpTypePointer Input %10
110 %12 = OpVariable %11 Input
112 %14 = OpConstant %13 1
113 %15 = OpTypePointer Input %9
114 %18 = OpConstant %13 4
115 %19 = OpTypeArray %9 %18
116 %20 = OpTypeStruct %19
117 %21 = OpTypePointer Uniform %20
118 %22 = OpVariable %21 Uniform
119 %23 = OpConstant %6 0
120 %24 = OpTypePointer Uniform %9
122 %29 = OpConstant %6 2
123 %31 = OpTypePointer Function %9
124 %33 = OpConstant %6 1
125 %38 = OpConstant %6 3
126 %41 = OpTypeVector %9 3
127 %51 = OpTypePointer Output %10
128 %52 = OpVariable %51 Output
129 %53 = OpConstant %13 2
130 %54 = OpTypeArray %6 %53
131 %55 = OpTypeStruct %54
132 %56 = OpTypePointer Uniform %55
133 %57 = OpVariable %56 Uniform
134 %58 = OpTypePointer Uniform %6
135 %4 = OpFunction %2 None %3
137 %8 = OpVariable %7 Function
138 %32 = OpVariable %31 Function
139 %16 = OpAccessChain %15 %12 %14
141 %25 = OpAccessChain %24 %22 %23 %23
143 %28 = OpFOrdGreaterThanEqual %27 %17 %26
144 %30 = OpSelect %6 %28 %23 %29
146 %34 = OpAccessChain %24 %22 %23 %33
148 %36 = OpAccessChain %24 %22 %23 %29
150 %39 = OpAccessChain %24 %22 %23 %38
152 %42 = OpCompositeConstruct %41 %35 %37 %40
154 %44 = OpVectorExtractDynamic %9 %42 %43
157 %46 = OpAccessChain %24 %22 %23 %33
159 %48 = OpFOrdEqual %27 %45 %47
160 OpSelectionMerge %50 None
161 OpBranchConditional %48 %49 %72
163 %59 = OpAccessChain %58 %57 %23 %23
165 %61 = OpConvertSToF %9 %60
166 %62 = OpAccessChain %58 %57 %23 %33
168 %64 = OpConvertSToF %9 %63
169 %65 = OpAccessChain %58 %57 %23 %33
171 %67 = OpConvertSToF %9 %66
172 %68 = OpAccessChain %58 %57 %23 %23
174 %70 = OpConvertSToF %9 %69
175 %71 = OpCompositeConstruct %10 %61 %64 %67 %70
179 %73 = OpAccessChain %58 %57 %23 %23
181 %75 = OpConvertSToF %9 %74
182 %76 = OpCompositeConstruct %10 %75 %75 %75 %75
190 # uniforms for variant
192 # _GLF_uniform_int_values
193 BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
196 # _GLF_uniform_float_values
197 BUFFER variant__GLF_uniform_float_values DATA_TYPE float[] STD140 DATA
201 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
203 PIPELINE graphics variant_pipeline
204 ATTACH variant_vertex_shader
205 ATTACH variant_fragment_shader
206 FRAMEBUFFER_SIZE 256 256
207 BIND BUFFER variant_framebuffer AS color LOCATION 0
208 BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 1
209 BIND BUFFER variant__GLF_uniform_float_values AS uniform DESCRIPTOR_SET 0 BINDING 0
211 CLEAR_COLOR variant_pipeline 0 0 0 255
213 CLEAR variant_pipeline
214 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
216 EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255