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_1 _GLF_uniform_int_values[0]
29 # #define _int_0 _GLF_uniform_int_values[1]
30 # #define _int_2 _GLF_uniform_int_values[2]
32 # precision highp float;
33 # precision highp int;
35 # // Contents of _GLF_uniform_int_values: [1, 0, 2]
36 # layout(set = 0, binding = 0) uniform buf0
38 # int _GLF_uniform_int_values[3];
41 # layout(location = 0) out vec4 _GLF_color;
45 # int arr[10] = int[10](30989, 0, 0, 0, 0, 0, 0, 0, 0, 1);
52 # // The first iteration sets i to arr[0] = 30989, and the second iteration sets i to arr[9] = 1.
53 # i = arr[clamp(i, 0, 10 - 1)];
60 # _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1);
64 # _GLF_color = vec4(_int_0);
67 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
70 ; Generator: Khronos Glslang Reference Front End; 10
74 %1 = OpExtInstImport "GLSL.std.450"
75 OpMemoryModel Logical GLSL450
76 OpEntryPoint Fragment %4 "main" %52
77 OpExecutionMode %4 OriginUpperLeft
84 OpMemberName %21 0 "_GLF_uniform_int_values"
86 OpName %52 "_GLF_color"
87 OpDecorate %20 ArrayStride 16
88 OpMemberDecorate %21 0 Offset 0
90 OpDecorate %23 DescriptorSet 0
91 OpDecorate %23 Binding 0
92 OpDecorate %52 Location 0
94 %3 = OpTypeFunction %2
98 %9 = OpTypeArray %6 %8
99 %10 = OpTypePointer Function %9
100 %12 = OpConstant %6 30989
101 %13 = OpConstant %6 0
102 %14 = OpConstant %6 1
103 %15 = OpConstantComposite %9 %12 %13 %13 %13 %13 %13 %13 %13 %13 %14
104 %16 = OpTypePointer Function %6
105 %19 = OpConstant %7 3
106 %20 = OpTypeArray %6 %19
107 %21 = OpTypeStruct %20
108 %22 = OpTypePointer Uniform %21
109 %23 = OpVariable %22 Uniform
110 %24 = OpTypePointer Uniform %6
112 %36 = OpConstant %6 9
113 %43 = OpConstant %6 2
115 %50 = OpTypeVector %49 4
116 %51 = OpTypePointer Output %50
117 %52 = OpVariable %51 Output
118 %4 = OpFunction %2 None %3
120 %11 = OpVariable %10 Function
121 %17 = OpVariable %16 Function
122 %18 = OpVariable %16 Function
125 %25 = OpAccessChain %24 %23 %13 %14
130 OpLoopMerge %29 %30 None
134 %34 = OpINotEqual %33 %32 %14
135 OpBranchConditional %34 %28 %29
138 %37 = OpExtInst %6 %1 SClamp %35 %13 %36
139 %38 = OpAccessChain %16 %11 %37
143 %41 = OpIAdd %6 %40 %14
150 %44 = OpAccessChain %24 %23 %13 %43
152 %46 = OpIEqual %33 %42 %45
153 OpSelectionMerge %48 None
154 OpBranchConditional %46 %47 %66
156 %53 = OpAccessChain %24 %23 %13 %13
158 %55 = OpConvertSToF %49 %54
159 %56 = OpAccessChain %24 %23 %13 %14
161 %58 = OpConvertSToF %49 %57
162 %59 = OpAccessChain %24 %23 %13 %14
164 %61 = OpConvertSToF %49 %60
165 %62 = OpAccessChain %24 %23 %13 %13
167 %64 = OpConvertSToF %49 %63
168 %65 = OpCompositeConstruct %50 %55 %58 %61 %64
172 %67 = OpAccessChain %24 %23 %13 %14
174 %69 = OpConvertSToF %49 %68
175 %70 = OpCompositeConstruct %50 %69 %69 %69 %69
183 # uniforms for variant
185 # _GLF_uniform_int_values
186 BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
190 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
192 PIPELINE graphics variant_pipeline
193 ATTACH variant_vertex_shader
194 ATTACH variant_fragment_shader
195 FRAMEBUFFER_SIZE 32 32
196 BIND BUFFER variant_framebuffer AS color LOCATION 0
197 BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 0
199 CLEAR_COLOR variant_pipeline 0 0 0 255
201 CLEAR variant_pipeline
202 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 32 32
204 EXPECT variant_framebuffer IDX 0 0 SIZE 32 32 EQ_RGBA 255 0 0 255