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