• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!amber
2
3# Copyright 2021 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 VTN 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 320 es
28#
29# precision highp float;
30# precision highp int;
31#
32# layout(location = 0) out vec4 _GLF_color;
33#
34# void main()
35# {
36#     mat2 m = transpose(mat2(1, 2, 3, 4)) / 2.0;
37#
38#     if (m == mat2(0.5, 1.5, 1.0, 2.0))
39#         _GLF_color = vec4(1, 0, 0, 1);
40#     else
41#         _GLF_color = vec4(0);
42# }
43SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
44; SPIR-V
45; Version: 1.0
46; Generator: Khronos Glslang Reference Front End; 10
47; Bound: 46
48; Schema: 0
49               OpCapability Shader
50          %1 = OpExtInstImport "GLSL.std.450"
51               OpMemoryModel Logical GLSL450
52               OpEntryPoint Fragment %4 "main" %41
53               OpExecutionMode %4 OriginUpperLeft
54               OpSource ESSL 320
55               OpName %4 "main"
56               OpName %10 "m"
57               OpName %41 "_GLF_color"
58               OpDecorate %41 Location 0
59          %2 = OpTypeVoid
60          %3 = OpTypeFunction %2
61          %6 = OpTypeFloat 32
62          %7 = OpTypeVector %6 2
63          %8 = OpTypeMatrix %7 2
64          %9 = OpTypePointer Function %8
65         %11 = OpConstant %6 1
66         %12 = OpConstant %6 2
67         %13 = OpConstantComposite %7 %11 %12
68         %14 = OpConstant %6 3
69         %15 = OpConstant %6 4
70         %16 = OpConstantComposite %7 %14 %15
71         %17 = OpConstantComposite %8 %13 %16
72         %22 = OpConstant %6 0.5
73         %23 = OpConstant %6 1.5
74         %24 = OpConstantComposite %7 %22 %23
75         %25 = OpConstantComposite %8 %24 %13
76         %26 = OpTypeBool
77         %29 = OpTypeVector %26 2
78         %39 = OpTypeVector %6 4
79         %40 = OpTypePointer Output %39
80         %41 = OpVariable %40 Output
81         %42 = OpConstant %6 0
82         %43 = OpConstantComposite %39 %11 %42 %42 %11
83         %45 = OpConstantComposite %39 %42 %42 %42 %42
84          %4 = OpFunction %2 None %3
85          %5 = OpLabel
86         %10 = OpVariable %9 Function
87         %18 = OpTranspose %8 %17
88         %19 = OpFDiv %6 %11 %12
89         %20 = OpMatrixTimesScalar %8 %18 %19
90               OpStore %10 %20
91         %21 = OpLoad %8 %10
92         %27 = OpCompositeExtract %7 %21 0
93         %28 = OpCompositeExtract %7 %25 0
94         %30 = OpFOrdEqual %29 %27 %28
95         %31 = OpAll %26 %30
96         %32 = OpCompositeExtract %7 %21 1
97         %33 = OpCompositeExtract %7 %25 1
98         %34 = OpFOrdEqual %29 %32 %33
99         %35 = OpAll %26 %34
100         %36 = OpLogicalAnd %26 %31 %35
101               OpSelectionMerge %38 None
102               OpBranchConditional %36 %37 %44
103         %37 = OpLabel
104               OpStore %41 %43
105               OpBranch %38
106         %44 = OpLabel
107               OpStore %41 %45
108               OpBranch %38
109         %38 = OpLabel
110               OpReturn
111               OpFunctionEnd
112END
113
114
115BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
116
117PIPELINE graphics variant_pipeline
118  ATTACH variant_vertex_shader
119  ATTACH variant_fragment_shader
120  FRAMEBUFFER_SIZE 256 256
121  BIND BUFFER variant_framebuffer AS color LOCATION 0
122END
123CLEAR_COLOR variant_pipeline 0 0 0 255
124
125CLEAR variant_pipeline
126RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
127
128EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255
129