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