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