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