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