• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!amber
2
3# Copyright 2021 Google LLC
4#
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
8#
9#     http://www.apache.org/licenses/LICENSE-2.0
10#
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.
16
17
18# A test for a coverage-gap found by the GraphicsFuzz project.
19
20# Short description: A fragment shader that covers specific LLVM code paths
21
22# The test passes because the shader always writes red.
23
24SHADER vertex variant_vertex_shader PASSTHROUGH
25
26# variant_fragment_shader is derived from the following GLSL:
27# #version 320 es
28# #define _int_1 _GLF_uniform_int_values[0]
29# #define _int_0 _GLF_uniform_int_values[1]
30#
31# precision highp float;
32# precision highp int;
33#
34# // Contents of _GLF_uniform_int_values: [1, 0]
35# layout(set = 0, binding = 0) uniform buf0
36# {
37#     int _GLF_uniform_int_values[2];
38# };
39#
40# layout(location = 0) out vec4 _GLF_color;
41#
42# void main()
43# {
44#     int a = _int_0;
45#
46#     // Never iterated.
47#     for(int i = _int_0; (_int_1 | i) < 1; i++)
48#     {
49#         a++;
50#     }
51#
52#     // Always true.
53#     if(a == _int_0)
54#     {
55#         _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1);
56#     }
57#     else
58#     {
59#         _GLF_color = vec4(_int_0);
60#     }
61# }
62SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
63; SPIR-V
64; Version: 1.0
65; Generator: Khronos Glslang Reference Front End; 10
66; Bound: 66
67; Schema: 0
68               OpCapability Shader
69          %1 = OpExtInstImport "GLSL.std.450"
70               OpMemoryModel Logical GLSL450
71               OpEntryPoint Fragment %4 "main" %47
72               OpExecutionMode %4 OriginUpperLeft
73               OpSource ESSL 320
74               OpName %4 "main"
75               OpName %8 "a"
76               OpName %12 "buf0"
77               OpMemberName %12 0 "_GLF_uniform_int_values"
78               OpName %14 ""
79               OpName %20 "i"
80               OpName %47 "_GLF_color"
81               OpDecorate %11 ArrayStride 16
82               OpMemberDecorate %12 0 Offset 0
83               OpDecorate %12 Block
84               OpDecorate %14 DescriptorSet 0
85               OpDecorate %14 Binding 0
86               OpDecorate %47 Location 0
87          %2 = OpTypeVoid
88          %3 = OpTypeFunction %2
89          %6 = OpTypeInt 32 1
90          %7 = OpTypePointer Function %6
91          %9 = OpTypeInt 32 0
92         %10 = OpConstant %9 2
93         %11 = OpTypeArray %6 %10
94         %12 = OpTypeStruct %11
95         %13 = OpTypePointer Uniform %12
96         %14 = OpVariable %13 Uniform
97         %15 = OpConstant %6 0
98         %16 = OpConstant %6 1
99         %17 = OpTypePointer Uniform %6
100         %32 = OpTypeBool
101         %44 = OpTypeFloat 32
102         %45 = OpTypeVector %44 4
103         %46 = OpTypePointer Output %45
104         %47 = OpVariable %46 Output
105          %4 = OpFunction %2 None %3
106          %5 = OpLabel
107          %8 = OpVariable %7 Function
108         %20 = OpVariable %7 Function
109         %18 = OpAccessChain %17 %14 %15 %16
110         %19 = OpLoad %6 %18
111               OpStore %8 %19
112         %21 = OpAccessChain %17 %14 %15 %16
113         %22 = OpLoad %6 %21
114               OpStore %20 %22
115               OpBranch %23
116         %23 = OpLabel
117               OpLoopMerge %25 %26 None
118               OpBranch %27
119         %27 = OpLabel
120         %28 = OpAccessChain %17 %14 %15 %15
121         %29 = OpLoad %6 %28
122         %30 = OpLoad %6 %20
123         %31 = OpBitwiseOr %6 %29 %30
124         %33 = OpSLessThan %32 %31 %16
125               OpBranchConditional %33 %24 %25
126         %24 = OpLabel
127         %34 = OpLoad %6 %8
128         %35 = OpIAdd %6 %34 %16
129               OpStore %8 %35
130               OpBranch %26
131         %26 = OpLabel
132         %36 = OpLoad %6 %20
133         %37 = OpIAdd %6 %36 %16
134               OpStore %20 %37
135               OpBranch %23
136         %25 = OpLabel
137         %38 = OpLoad %6 %8
138         %39 = OpAccessChain %17 %14 %15 %16
139         %40 = OpLoad %6 %39
140         %41 = OpIEqual %32 %38 %40
141               OpSelectionMerge %43 None
142               OpBranchConditional %41 %42 %61
143         %42 = OpLabel
144         %48 = OpAccessChain %17 %14 %15 %15
145         %49 = OpLoad %6 %48
146         %50 = OpConvertSToF %44 %49
147         %51 = OpAccessChain %17 %14 %15 %16
148         %52 = OpLoad %6 %51
149         %53 = OpConvertSToF %44 %52
150         %54 = OpAccessChain %17 %14 %15 %16
151         %55 = OpLoad %6 %54
152         %56 = OpConvertSToF %44 %55
153         %57 = OpAccessChain %17 %14 %15 %15
154         %58 = OpLoad %6 %57
155         %59 = OpConvertSToF %44 %58
156         %60 = OpCompositeConstruct %45 %50 %53 %56 %59
157               OpStore %47 %60
158               OpBranch %43
159         %61 = OpLabel
160         %62 = OpAccessChain %17 %14 %15 %16
161         %63 = OpLoad %6 %62
162         %64 = OpConvertSToF %44 %63
163         %65 = OpCompositeConstruct %45 %64 %64 %64 %64
164               OpStore %47 %65
165               OpBranch %43
166         %43 = OpLabel
167               OpReturn
168               OpFunctionEnd
169END
170
171# uniforms for variant
172
173# _GLF_uniform_int_values
174BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
175 1 0
176END
177
178BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
179
180PIPELINE graphics variant_pipeline
181  ATTACH variant_vertex_shader
182  ATTACH variant_fragment_shader
183  FRAMEBUFFER_SIZE 256 256
184  BIND BUFFER variant_framebuffer AS color LOCATION 0
185  BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 0
186END
187CLEAR_COLOR variant_pipeline 0 0 0 255
188
189CLEAR variant_pipeline
190RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
191
192EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255
193