• 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 GraphicsFuzz.
19
20# Short description: A fragment shader that covers a specific instruction simplification 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# precision highp float;
29#
30# layout(set = 0, binding = 0) uniform buf0
31# {
32#     float one;
33# };
34# layout(location = 0) out vec4 _GLF_color;
35#
36# void main()
37# {
38#     vec4 v = vec4(8.4, -864.665, 945.420, 1.0);
39#     // Multiplying with an identity matrix returns the original vector.
40#     vec4 res = mat4(one) * v;
41#
42#     if (distance(v, res) < 0.01)
43#         _GLF_color = vec4(1, 0, 0, 1);
44#     else
45#         _GLF_color = vec4(0);
46# }
47SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
48; SPIR-V
49; Version: 1.0
50; Generator: Khronos Glslang Reference Front End; 8
51; Bound: 46
52; Schema: 0
53               OpCapability Shader
54          %1 = OpExtInstImport "GLSL.std.450"
55               OpMemoryModel Logical GLSL450
56               OpEntryPoint Fragment %4 "main" %42
57               OpExecutionMode %4 OriginUpperLeft
58               OpSource ESSL 310
59               OpName %4 "main"
60               OpName %9 "v"
61               OpName %15 "res"
62               OpName %16 "buf0"
63               OpMemberName %16 0 "one"
64               OpName %18 ""
65               OpName %42 "_GLF_color"
66               OpMemberDecorate %16 0 Offset 0
67               OpDecorate %16 Block
68               OpDecorate %18 DescriptorSet 0
69               OpDecorate %18 Binding 0
70               OpDecorate %42 Location 0
71          %2 = OpTypeVoid
72          %3 = OpTypeFunction %2
73          %6 = OpTypeFloat 32
74          %7 = OpTypeVector %6 4
75          %8 = OpTypePointer Function %7
76         %10 = OpConstant %6 8.39999962
77         %11 = OpConstant %6 -864.664978
78         %12 = OpConstant %6 945.419983
79         %13 = OpConstant %6 1
80         %14 = OpConstantComposite %7 %10 %11 %12 %13
81         %16 = OpTypeStruct %6
82         %17 = OpTypePointer Uniform %16
83         %18 = OpVariable %17 Uniform
84         %19 = OpTypeInt 32 1
85         %20 = OpConstant %19 0
86         %21 = OpTypePointer Uniform %6
87         %24 = OpTypeMatrix %7 4
88         %25 = OpConstant %6 0
89         %36 = OpConstant %6 0.00999999978
90         %37 = OpTypeBool
91         %41 = OpTypePointer Output %7
92         %42 = OpVariable %41 Output
93         %43 = OpConstantComposite %7 %13 %25 %25 %13
94         %45 = OpConstantComposite %7 %25 %25 %25 %25
95          %4 = OpFunction %2 None %3
96          %5 = OpLabel
97          %9 = OpVariable %8 Function
98         %15 = OpVariable %8 Function
99               OpStore %9 %14
100         %22 = OpAccessChain %21 %18 %20
101         %23 = OpLoad %6 %22
102         %26 = OpCompositeConstruct %7 %23 %25 %25 %25
103         %27 = OpCompositeConstruct %7 %25 %23 %25 %25
104         %28 = OpCompositeConstruct %7 %25 %25 %23 %25
105         %29 = OpCompositeConstruct %7 %25 %25 %25 %23
106         %30 = OpCompositeConstruct %24 %26 %27 %28 %29
107         %31 = OpLoad %7 %9
108         %32 = OpMatrixTimesVector %7 %30 %31
109               OpStore %15 %32
110         %33 = OpLoad %7 %9
111         %34 = OpLoad %7 %15
112         %35 = OpExtInst %6 %1 Distance %33 %34
113         %38 = OpFOrdLessThan %37 %35 %36
114               OpSelectionMerge %40 None
115               OpBranchConditional %38 %39 %44
116         %39 = OpLabel
117               OpStore %42 %43
118               OpBranch %40
119         %44 = OpLabel
120               OpStore %42 %45
121               OpBranch %40
122         %40 = OpLabel
123               OpReturn
124               OpFunctionEnd
125END
126
127# uniforms for variant
128
129# one
130BUFFER variant_one DATA_TYPE float DATA
131 1.0
132END
133
134BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
135
136PIPELINE graphics variant_pipeline
137  ATTACH variant_vertex_shader
138  ATTACH variant_fragment_shader
139  FRAMEBUFFER_SIZE 256 256
140  BIND BUFFER variant_framebuffer AS color LOCATION 0
141  BIND BUFFER variant_one AS uniform DESCRIPTOR_SET 0 BINDING 0
142END
143CLEAR_COLOR variant_pipeline 0 0 0 255
144
145CLEAR variant_pipeline
146RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
147
148EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255
149