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: Covers a specific X86 ISel lowering and DAG selection 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]
31 # precision highp float;
32 # precision highp int;
34 # // Contents of _GLF_uniform_int_values: [1, 0]
35 # layout(set = 0, binding = 0) uniform buf0
37 # int _GLF_uniform_int_values[2];
40 # layout(location = 0) out vec4 _GLF_color;
52 # A[_int_0] = S(_int_0, _int_0, _int_0);
53 # A[_int_1] = S(_int_0, _int_0, _int_0);
56 # if (A[_int_0].b == _int_0)
58 # // A[1].b becomes 1.
59 # A[clamp(_int_0, 1, 2)].b = _int_1;
62 # if (A[_int_1].b == _int_1)
64 # _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1);
68 # _GLF_color = vec4(_int_1);
71 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
74 ; Generator: Khronos Glslang Reference Front End; 8
78 %1 = OpExtInstImport "GLSL.std.450"
79 OpMemoryModel Logical GLSL450
80 OpEntryPoint Fragment %4 "main" %71
81 OpExecutionMode %4 OriginUpperLeft
90 OpMemberName %14 0 "_GLF_uniform_int_values"
92 OpName %71 "_GLF_color"
93 OpDecorate %13 ArrayStride 16
94 OpMemberDecorate %14 0 Offset 0
96 OpDecorate %16 DescriptorSet 0
97 OpDecorate %16 Binding 0
98 OpDecorate %71 Location 0
100 %3 = OpTypeFunction %2
102 %7 = OpTypeStruct %6 %6 %6
105 %10 = OpTypeArray %7 %9
106 %11 = OpTypePointer Function %10
107 %13 = OpTypeArray %6 %9
108 %14 = OpTypeStruct %13
109 %15 = OpTypePointer Uniform %14
110 %16 = OpVariable %15 Uniform
111 %17 = OpConstant %6 0
112 %18 = OpConstant %6 1
113 %19 = OpTypePointer Uniform %6
114 %29 = OpTypePointer Function %7
115 %43 = OpTypePointer Function %6
117 %54 = OpConstant %6 2
119 %69 = OpTypeVector %68 4
120 %70 = OpTypePointer Output %69
121 %71 = OpVariable %70 Output
122 %4 = OpFunction %2 None %3
124 %12 = OpVariable %11 Function
125 %20 = OpAccessChain %19 %16 %17 %18
127 %22 = OpAccessChain %19 %16 %17 %18
129 %24 = OpAccessChain %19 %16 %17 %18
131 %26 = OpAccessChain %19 %16 %17 %18
133 %28 = OpCompositeConstruct %7 %23 %25 %27
134 %30 = OpAccessChain %29 %12 %21
136 %31 = OpAccessChain %19 %16 %17 %17
138 %33 = OpAccessChain %19 %16 %17 %18
140 %35 = OpAccessChain %19 %16 %17 %18
142 %37 = OpAccessChain %19 %16 %17 %18
144 %39 = OpCompositeConstruct %7 %34 %36 %38
145 %40 = OpAccessChain %29 %12 %32
147 %41 = OpAccessChain %19 %16 %17 %18
149 %44 = OpAccessChain %43 %12 %42 %18
151 %46 = OpAccessChain %19 %16 %17 %18
153 %49 = OpIEqual %48 %45 %47
154 OpSelectionMerge %51 None
155 OpBranchConditional %49 %50 %51
157 %52 = OpAccessChain %19 %16 %17 %18
159 %55 = OpExtInst %6 %1 SClamp %53 %18 %54
160 %56 = OpAccessChain %19 %16 %17 %17
162 %58 = OpAccessChain %43 %12 %55 %18
166 %59 = OpAccessChain %19 %16 %17 %17
168 %61 = OpAccessChain %43 %12 %60 %18
170 %63 = OpAccessChain %19 %16 %17 %17
172 %65 = OpIEqual %48 %62 %64
173 OpSelectionMerge %67 None
174 OpBranchConditional %65 %66 %85
176 %72 = OpAccessChain %19 %16 %17 %17
178 %74 = OpConvertSToF %68 %73
179 %75 = OpAccessChain %19 %16 %17 %18
181 %77 = OpConvertSToF %68 %76
182 %78 = OpAccessChain %19 %16 %17 %18
184 %80 = OpConvertSToF %68 %79
185 %81 = OpAccessChain %19 %16 %17 %17
187 %83 = OpConvertSToF %68 %82
188 %84 = OpCompositeConstruct %69 %74 %77 %80 %83
192 %86 = OpAccessChain %19 %16 %17 %17
194 %88 = OpConvertSToF %68 %87
195 %89 = OpCompositeConstruct %69 %88 %88 %88 %88
203 # uniforms for variant
205 # _GLF_uniform_int_values
206 BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
210 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
212 PIPELINE graphics variant_pipeline
213 ATTACH variant_vertex_shader
214 ATTACH variant_fragment_shader
215 FRAMEBUFFER_SIZE 256 256
216 BIND BUFFER variant_framebuffer AS color LOCATION 0
217 BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 0
219 CLEAR_COLOR variant_pipeline 0 0 0 255
221 CLEAR variant_pipeline
222 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
224 EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255