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