• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!amber
2
3# Copyright 2020 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: Covers specific instruction simplify and combine compare 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 310 es
28# #define _int_0 _GLF_uniform_int_values[0]
29# #define _int_10 _GLF_uniform_int_values[1]
30# #define _float_1_0 _GLF_uniform_float_values[0]
31# #define _float_0_25 _GLF_uniform_float_values[1]
32#
33# precision highp float;
34# precision highp int;
35#
36# // Contents of _GLF_uniform_float_values: [1.0, 0.25]
37# layout(set = 0, binding = 0) uniform buf0
38# {
39#     float _GLF_uniform_float_values[2];
40# };
41#
42# // Contents of _GLF_uniform_int_values: [0, 10]
43# layout(set = 0, binding = 1) uniform buf1
44# {
45#     int _GLF_uniform_int_values[2];
46# };
47#
48# layout(location = 0) out vec4 _GLF_color;
49#
50# void main()
51# {
52#     _GLF_color = vec4(_int_0);
53#     for (int i = _int_0; i < _int_10; i++)
54#     {
55#         // True when i = 0.
56#         if (!(_float_0_25 <= float(i)))
57#         {
58#             _GLF_color += vec4(_float_1_0, i, i, _float_1_0);
59#         }
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; 8
66; Bound: 64
67; Schema: 0
68               OpCapability Shader
69          %1 = OpExtInstImport "GLSL.std.450"
70               OpMemoryModel Logical GLSL450
71               OpEntryPoint Fragment %4 "main" %9
72               OpExecutionMode %4 OriginUpperLeft
73               OpSource ESSL 310
74               OpName %4 "main"
75               OpName %9 "_GLF_color"
76               OpName %14 "buf1"
77               OpMemberName %14 0 "_GLF_uniform_int_values"
78               OpName %16 ""
79               OpName %24 "i"
80               OpName %39 "buf0"
81               OpMemberName %39 0 "_GLF_uniform_float_values"
82               OpName %41 ""
83               OpDecorate %9 Location 0
84               OpDecorate %13 ArrayStride 16
85               OpMemberDecorate %14 0 Offset 0
86               OpDecorate %14 Block
87               OpDecorate %16 DescriptorSet 0
88               OpDecorate %16 Binding 1
89               OpDecorate %38 ArrayStride 16
90               OpMemberDecorate %39 0 Offset 0
91               OpDecorate %39 Block
92               OpDecorate %41 DescriptorSet 0
93               OpDecorate %41 Binding 0
94          %2 = OpTypeVoid
95          %3 = OpTypeFunction %2
96          %6 = OpTypeFloat 32
97          %7 = OpTypeVector %6 4
98          %8 = OpTypePointer Output %7
99          %9 = OpVariable %8 Output
100         %10 = OpTypeInt 32 1
101         %11 = OpTypeInt 32 0
102         %12 = OpConstant %11 2
103         %13 = OpTypeArray %10 %12
104         %14 = OpTypeStruct %13
105         %15 = OpTypePointer Uniform %14
106         %16 = OpVariable %15 Uniform
107         %17 = OpConstant %10 0
108         %18 = OpTypePointer Uniform %10
109         %23 = OpTypePointer Function %10
110         %33 = OpConstant %10 1
111         %36 = OpTypeBool
112         %38 = OpTypeArray %6 %12
113         %39 = OpTypeStruct %38
114         %40 = OpTypePointer Uniform %39
115         %41 = OpVariable %40 Uniform
116         %42 = OpTypePointer Uniform %6
117          %4 = OpFunction %2 None %3
118          %5 = OpLabel
119         %24 = OpVariable %23 Function
120         %19 = OpAccessChain %18 %16 %17 %17
121         %20 = OpLoad %10 %19
122         %21 = OpConvertSToF %6 %20
123         %22 = OpCompositeConstruct %7 %21 %21 %21 %21
124               OpStore %9 %22
125         %25 = OpAccessChain %18 %16 %17 %17
126         %26 = OpLoad %10 %25
127               OpStore %24 %26
128               OpBranch %27
129         %27 = OpLabel
130               OpLoopMerge %29 %30 None
131               OpBranch %31
132         %31 = OpLabel
133         %32 = OpLoad %10 %24
134         %34 = OpAccessChain %18 %16 %17 %33
135         %35 = OpLoad %10 %34
136         %37 = OpSLessThan %36 %32 %35
137               OpBranchConditional %37 %28 %29
138         %28 = OpLabel
139         %43 = OpAccessChain %42 %41 %17 %33
140         %44 = OpLoad %6 %43
141         %45 = OpLoad %10 %24
142         %46 = OpConvertSToF %6 %45
143         %47 = OpFOrdLessThanEqual %36 %44 %46
144         %48 = OpLogicalNot %36 %47
145               OpSelectionMerge %50 None
146               OpBranchConditional %48 %49 %50
147         %49 = OpLabel
148         %51 = OpAccessChain %42 %41 %17 %17
149         %52 = OpLoad %6 %51
150         %53 = OpLoad %10 %24
151         %54 = OpConvertSToF %6 %53
152         %55 = OpLoad %10 %24
153         %56 = OpConvertSToF %6 %55
154         %57 = OpAccessChain %42 %41 %17 %17
155         %58 = OpLoad %6 %57
156         %59 = OpCompositeConstruct %7 %52 %54 %56 %58
157         %60 = OpLoad %7 %9
158         %61 = OpFAdd %7 %60 %59
159               OpStore %9 %61
160               OpBranch %50
161         %50 = OpLabel
162               OpBranch %30
163         %30 = OpLabel
164         %62 = OpLoad %10 %24
165         %63 = OpIAdd %10 %62 %33
166               OpStore %24 %63
167               OpBranch %27
168         %29 = OpLabel
169               OpReturn
170               OpFunctionEnd
171END
172
173# uniforms for variant
174
175# _GLF_uniform_int_values
176BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
177 0 10
178END
179# _GLF_uniform_float_values
180BUFFER variant__GLF_uniform_float_values DATA_TYPE float[] STD140 DATA
181 1.0 0.25
182END
183
184BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
185
186PIPELINE graphics variant_pipeline
187  ATTACH variant_vertex_shader
188  ATTACH variant_fragment_shader
189  FRAMEBUFFER_SIZE 256 256
190  BIND BUFFER variant_framebuffer AS color LOCATION 0
191  BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 1
192  BIND BUFFER variant__GLF_uniform_float_values AS uniform DESCRIPTOR_SET 0 BINDING 0
193END
194CLEAR_COLOR variant_pipeline 0 0 0 255
195
196CLEAR variant_pipeline
197RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
198
199EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255
200