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