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