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_4 _GLF_uniform_int_values[0]
29 # #define _int_2 _GLF_uniform_int_values[1]
30 # #define _int_5 _GLF_uniform_int_values[2]
31 # #define _int_1 _GLF_uniform_int_values[3]
32 # #define _int_6 _GLF_uniform_int_values[4]
33 # #define _int_0 _GLF_uniform_int_values[5]
35 # precision highp float;
36 # precision highp int;
38 # // Contents of _GLF_uniform_int_values: [4, 2, 5, 1, 6, 0]
39 # layout(set = 0, binding = 0) uniform buf0
41 # int _GLF_uniform_int_values[6];
44 # layout(location = 0) out vec4 _GLF_color;
48 # int a = _int_1 << _int_6;
50 # return clamp(a >> _int_5, a >> _int_5, _int_4);
56 # if(func() == _int_2)
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" %52
75 OpExecutionMode %4 OriginUpperLeft
81 OpMemberName %15 0 "_GLF_uniform_int_values"
83 OpName %52 "_GLF_color"
84 OpDecorate %14 ArrayStride 16
85 OpMemberDecorate %15 0 Offset 0
87 OpDecorate %17 DescriptorSet 0
88 OpDecorate %17 Binding 0
89 OpDecorate %52 Location 0
91 %3 = OpTypeFunction %2
93 %7 = OpTypeFunction %6
94 %10 = OpTypePointer Function %6
96 %13 = OpConstant %12 6
97 %14 = OpTypeArray %6 %13
98 %15 = OpTypeStruct %14
99 %16 = OpTypePointer Uniform %15
100 %17 = OpVariable %16 Uniform
101 %18 = OpConstant %6 0
102 %19 = OpConstant %6 3
103 %20 = OpTypePointer Uniform %6
104 %23 = OpConstant %6 4
105 %28 = OpConstant %6 2
106 %42 = OpConstant %6 1
109 %50 = OpTypeVector %49 4
110 %51 = OpTypePointer Output %50
111 %52 = OpVariable %51 Output
112 %56 = OpConstant %6 5
113 %4 = OpFunction %2 None %3
115 %41 = OpFunctionCall %6 %8
116 %43 = OpAccessChain %20 %17 %18 %42
118 %46 = OpIEqual %45 %41 %44
119 OpSelectionMerge %48 None
120 OpBranchConditional %46 %47 %67
122 %53 = OpAccessChain %20 %17 %18 %19
124 %55 = OpConvertSToF %49 %54
125 %57 = OpAccessChain %20 %17 %18 %56
127 %59 = OpConvertSToF %49 %58
128 %60 = OpAccessChain %20 %17 %18 %56
130 %62 = OpConvertSToF %49 %61
131 %63 = OpAccessChain %20 %17 %18 %19
133 %65 = OpConvertSToF %49 %64
134 %66 = OpCompositeConstruct %50 %55 %59 %62 %65
138 %68 = OpAccessChain %20 %17 %18 %56
140 %70 = OpConvertSToF %49 %69
141 %71 = OpCompositeConstruct %50 %70 %70 %70 %70
147 %8 = OpFunction %6 None %7
149 %11 = OpVariable %10 Function
150 %21 = OpAccessChain %20 %17 %18 %19
152 %24 = OpAccessChain %20 %17 %18 %23
154 %26 = OpShiftLeftLogical %6 %22 %25
157 %29 = OpAccessChain %20 %17 %18 %28
159 %31 = OpShiftRightArithmetic %6 %27 %30
161 %33 = OpAccessChain %20 %17 %18 %28
163 %35 = OpShiftRightArithmetic %6 %32 %34
164 %36 = OpAccessChain %20 %17 %18 %18
166 %38 = OpExtInst %6 %1 SClamp %31 %35 %37
171 # uniforms for variant
173 # _GLF_uniform_int_values
174 BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
178 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
180 PIPELINE graphics variant_pipeline
181 ATTACH variant_vertex_shader
182 ATTACH variant_fragment_shader
183 FRAMEBUFFER_SIZE 32 32
184 BIND BUFFER variant_framebuffer AS color LOCATION 0
185 BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 0
187 CLEAR_COLOR variant_pipeline 0 0 0 255
189 CLEAR variant_pipeline
190 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 32 32
192 EXPECT variant_framebuffer IDX 0 0 SIZE 32 32 EQ_RGBA 255 0 0 255