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