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