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