• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!amber
2
3# Copyright 2022 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
24# Optimized using spirv-opt with the following arguments:
25# '-O'
26# spirv-opt commit hash: a0370efd589be33d5d9a85cfde2f85841b3755af
27
28
29
30SHADER vertex variant_vertex_shader PASSTHROUGH
31
32# variant_fragment_shader is derived from the following GLSL:
33# #version 320 es
34# #define _int_0 _GLF_uniform_int_values[0]
35# #define _int_1 _GLF_uniform_int_values[1]
36#
37# precision highp int;
38# precision highp float;
39#
40# // Contents of _GLF_uniform_int_values: [0, 1]
41# layout(set = 0, binding = 0) uniform buf0
42# {
43#     int _GLF_uniform_int_values[2];
44# };
45#
46# layout(location = 0) out vec4 _GLF_color;
47#
48# void main()
49# {
50#     // Test resolution is 32 which makes fragment coordinate ANDed with 256 always zero.
51#     int a = ((!(!((ivec2(gl_FragCoord.xy).y & 256) != 0))) ? 0 : ~0) | ((ivec2(gl_FragCoord.xy).y & 256) != 0 ? 0 : ~0);
52#
53#     // Always true.
54#     if(a == ~ _int_0)
55#     {
56#         _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1);
57#     }
58#     else
59#     {
60#         _GLF_color = vec4(_int_0);
61#     }
62# }
63SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
64; SPIR-V
65; Version: 1.0
66; Generator: Khronos Glslang Reference Front End; 10
67; Bound: 72
68; Schema: 0
69               OpCapability Shader
70          %1 = OpExtInstImport "GLSL.std.450"
71               OpMemoryModel Logical GLSL450
72               OpEntryPoint Fragment %4 "main" %12 %52
73               OpExecutionMode %4 OriginUpperLeft
74               OpSource ESSL 320
75               OpName %4 "main"
76               OpName %12 "gl_FragCoord"
77               OpName %41 "buf0"
78               OpMemberName %41 0 "_GLF_uniform_int_values"
79               OpName %43 ""
80               OpName %52 "_GLF_color"
81               OpDecorate %12 BuiltIn FragCoord
82               OpDecorate %40 ArrayStride 16
83               OpMemberDecorate %41 0 Offset 0
84               OpDecorate %41 Block
85               OpDecorate %43 DescriptorSet 0
86               OpDecorate %43 Binding 0
87               OpDecorate %52 Location 0
88          %2 = OpTypeVoid
89          %3 = OpTypeFunction %2
90          %6 = OpTypeInt 32 1
91          %9 = OpTypeFloat 32
92         %10 = OpTypeVector %9 4
93         %11 = OpTypePointer Input %10
94         %12 = OpVariable %11 Input
95         %13 = OpTypeVector %9 2
96         %16 = OpTypeVector %6 2
97         %18 = OpTypeInt 32 0
98         %21 = OpConstant %6 256
99         %23 = OpConstant %6 0
100         %24 = OpTypeBool
101         %28 = OpConstant %6 -1
102         %39 = OpConstant %18 2
103         %40 = OpTypeArray %6 %39
104         %41 = OpTypeStruct %40
105         %42 = OpTypePointer Uniform %41
106         %43 = OpVariable %42 Uniform
107         %44 = OpTypePointer Uniform %6
108         %51 = OpTypePointer Output %10
109         %52 = OpVariable %51 Output
110         %53 = OpConstant %6 1
111          %4 = OpFunction %2 None %3
112          %5 = OpLabel
113         %14 = OpLoad %10 %12
114         %15 = OpVectorShuffle %13 %14 %14 0 1
115         %17 = OpConvertFToS %16 %15
116         %20 = OpCompositeExtract %6 %17 1
117         %22 = OpBitwiseAnd %6 %20 %21
118         %25 = OpINotEqual %24 %22 %23
119         %26 = OpLogicalNot %24 %25
120         %27 = OpLogicalNot %24 %26
121         %29 = OpSelect %6 %27 %23 %28
122         %36 = OpSelect %6 %25 %23 %28
123         %37 = OpBitwiseOr %6 %29 %36
124         %45 = OpAccessChain %44 %43 %23 %23
125         %46 = OpLoad %6 %45
126         %47 = OpNot %6 %46
127         %48 = OpIEqual %24 %37 %47
128               OpSelectionMerge %50 None
129               OpBranchConditional %48 %49 %67
130         %49 = OpLabel
131         %54 = OpAccessChain %44 %43 %23 %53
132         %55 = OpLoad %6 %54
133         %56 = OpConvertSToF %9 %55
134         %59 = OpConvertSToF %9 %46
135         %66 = OpCompositeConstruct %10 %56 %59 %59 %56
136               OpStore %52 %66
137               OpBranch %50
138         %67 = OpLabel
139         %70 = OpConvertSToF %9 %46
140         %71 = OpCompositeConstruct %10 %70 %70 %70 %70
141               OpStore %52 %71
142               OpBranch %50
143         %50 = OpLabel
144               OpReturn
145               OpFunctionEnd
146END
147
148# uniforms for variant
149
150# _GLF_uniform_int_values
151BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
152 0 1
153END
154
155BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
156
157PIPELINE graphics variant_pipeline
158  ATTACH variant_vertex_shader
159  ATTACH variant_fragment_shader
160  FRAMEBUFFER_SIZE 32 32
161  BIND BUFFER variant_framebuffer AS color LOCATION 0
162  BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 0
163END
164CLEAR_COLOR variant_pipeline 0 0 0 255
165
166CLEAR variant_pipeline
167RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 32 32
168
169EXPECT variant_framebuffer IDX 0 0 SIZE 32 32 EQ_RGBA 255 0 0 255
170