• 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 inst combine simplify demanded 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_0 _GLF_uniform_int_values[0]
29# #define _int_1 _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 int;
34#
35# precision highp float;
36#
37# // Contents of _GLF_uniform_float_values: [0.0, 1.0]
38# layout(set = 0, binding = 0) uniform buf0
39# {
40#     float _GLF_uniform_float_values[2];
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#     vec4 color = vec4(_float_0_0, _float_0_0, _float_0_0, _float_1_0);
54#     switch ((1 | _int_1) ^ 1)
55#     {
56#         case 0:
57#             color[_int_0] = _float_1_0;
58#             break;
59#     }
60#
61#     _GLF_color = color;
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; 10
67; Bound: 51
68; Schema: 0
69               OpCapability Shader
70          %1 = OpExtInstImport "GLSL.std.450"
71               OpMemoryModel Logical GLSL450
72               OpEntryPoint Fragment %4 "main" %49
73               OpExecutionMode %4 OriginUpperLeft
74               OpSource ESSL 310
75               OpName %4 "main"
76               OpName %9 "color"
77               OpName %13 "buf0"
78               OpMemberName %13 0 "_GLF_uniform_float_values"
79               OpName %15 ""
80               OpName %30 "buf1"
81               OpMemberName %30 0 "_GLF_uniform_int_values"
82               OpName %32 ""
83               OpName %49 "_GLF_color"
84               OpDecorate %12 ArrayStride 16
85               OpMemberDecorate %13 0 Offset 0
86               OpDecorate %13 Block
87               OpDecorate %15 DescriptorSet 0
88               OpDecorate %15 Binding 0
89               OpDecorate %29 ArrayStride 16
90               OpMemberDecorate %30 0 Offset 0
91               OpDecorate %30 Block
92               OpDecorate %32 DescriptorSet 0
93               OpDecorate %32 Binding 1
94               OpDecorate %49 Location 0
95          %2 = OpTypeVoid
96          %3 = OpTypeFunction %2
97          %6 = OpTypeFloat 32
98          %7 = OpTypeVector %6 4
99          %8 = OpTypePointer Function %7
100         %10 = OpTypeInt 32 0
101         %11 = OpConstant %10 2
102         %12 = OpTypeArray %6 %11
103         %13 = OpTypeStruct %12
104         %14 = OpTypePointer Uniform %13
105         %15 = OpVariable %14 Uniform
106         %16 = OpTypeInt 32 1
107         %17 = OpConstant %16 0
108         %18 = OpTypePointer Uniform %6
109         %25 = OpConstant %16 1
110         %29 = OpTypeArray %16 %11
111         %30 = OpTypeStruct %29
112         %31 = OpTypePointer Uniform %30
113         %32 = OpVariable %31 Uniform
114         %33 = OpTypePointer Uniform %16
115         %44 = OpTypePointer Function %6
116         %48 = OpTypePointer Output %7
117         %49 = OpVariable %48 Output
118          %4 = OpFunction %2 None %3
119          %5 = OpLabel
120          %9 = OpVariable %8 Function
121         %19 = OpAccessChain %18 %15 %17 %17
122         %20 = OpLoad %6 %19
123         %21 = OpAccessChain %18 %15 %17 %17
124         %22 = OpLoad %6 %21
125         %23 = OpAccessChain %18 %15 %17 %17
126         %24 = OpLoad %6 %23
127         %26 = OpAccessChain %18 %15 %17 %25
128         %27 = OpLoad %6 %26
129         %28 = OpCompositeConstruct %7 %20 %22 %24 %27
130               OpStore %9 %28
131         %34 = OpAccessChain %33 %32 %17 %25
132         %35 = OpLoad %16 %34
133         %36 = OpBitwiseOr %16 %25 %35
134         %37 = OpBitwiseXor %16 %36 %25
135               OpSelectionMerge %39 None
136               OpSwitch %37 %39 0 %38
137         %38 = OpLabel
138         %40 = OpAccessChain %33 %32 %17 %17
139         %41 = OpLoad %16 %40
140         %42 = OpAccessChain %18 %15 %17 %25
141         %43 = OpLoad %6 %42
142         %45 = OpAccessChain %44 %9 %41
143               OpStore %45 %43
144               OpBranch %39
145         %39 = OpLabel
146         %50 = OpLoad %7 %9
147               OpStore %49 %50
148               OpReturn
149               OpFunctionEnd
150END
151
152# uniforms for variant
153
154# _GLF_uniform_int_values
155BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
156 0 1
157END
158# _GLF_uniform_float_values
159BUFFER variant__GLF_uniform_float_values DATA_TYPE float[] STD140 DATA
160 0.0 1.0
161END
162
163BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
164
165PIPELINE graphics variant_pipeline
166  ATTACH variant_vertex_shader
167  ATTACH variant_fragment_shader
168  FRAMEBUFFER_SIZE 16 16
169  BIND BUFFER variant_framebuffer AS color LOCATION 0
170  BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 1
171  BIND BUFFER variant__GLF_uniform_float_values AS uniform DESCRIPTOR_SET 0 BINDING 0
172END
173CLEAR_COLOR variant_pipeline 0 0 0 255
174
175CLEAR variant_pipeline
176RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 16 16
177
178EXPECT variant_framebuffer IDX 0 0 SIZE 16 16 EQ_RGBA 255 0 0 255
179