• 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 folding path.
21
22# The test passes because 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# precision highp int;
30#
31# layout(location = 0) out vec4 _GLF_color;
32#
33# layout(set = 0, binding = 0) uniform buf0
34# {
35#     int one;
36# };
37#
38# void main()
39# {
40#     int x = -(5 - one);
41#
42#     if (x == -4)
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: 34
52; Schema: 0
53               OpCapability Shader
54          %1 = OpExtInstImport "GLSL.std.450"
55               OpMemoryModel Logical GLSL450
56               OpEntryPoint Fragment %4 "main" %28
57               OpExecutionMode %4 OriginUpperLeft
58               OpSource ESSL 310
59               OpName %4 "main"
60               OpName %8 "x"
61               OpName %10 "buf0"
62               OpMemberName %10 0 "one"
63               OpName %12 ""
64               OpName %28 "_GLF_color"
65               OpMemberDecorate %10 0 Offset 0
66               OpDecorate %10 Block
67               OpDecorate %12 DescriptorSet 0
68               OpDecorate %12 Binding 0
69               OpDecorate %28 Location 0
70          %2 = OpTypeVoid
71          %3 = OpTypeFunction %2
72          %6 = OpTypeInt 32 1
73          %7 = OpTypePointer Function %6
74          %9 = OpConstant %6 5
75         %10 = OpTypeStruct %6
76         %11 = OpTypePointer Uniform %10
77         %12 = OpVariable %11 Uniform
78         %13 = OpConstant %6 0
79         %14 = OpTypePointer Uniform %6
80         %20 = OpConstant %6 -4
81         %21 = OpTypeBool
82         %25 = OpTypeFloat 32
83         %26 = OpTypeVector %25 4
84         %27 = OpTypePointer Output %26
85         %28 = OpVariable %27 Output
86         %29 = OpConstant %25 1
87         %30 = OpConstant %25 0
88         %31 = OpConstantComposite %26 %29 %30 %30 %29
89         %33 = OpConstantComposite %26 %30 %30 %30 %30
90          %4 = OpFunction %2 None %3
91          %5 = OpLabel
92          %8 = OpVariable %7 Function
93         %15 = OpAccessChain %14 %12 %13
94         %16 = OpLoad %6 %15
95         %17 = OpISub %6 %9 %16
96         %18 = OpSNegate %6 %17
97               OpStore %8 %18
98         %19 = OpLoad %6 %8
99         %22 = OpIEqual %21 %19 %20
100               OpSelectionMerge %24 None
101               OpBranchConditional %22 %23 %32
102         %23 = OpLabel
103               OpStore %28 %31
104               OpBranch %24
105         %32 = OpLabel
106               OpStore %28 %33
107               OpBranch %24
108         %24 = OpLabel
109               OpReturn
110               OpFunctionEnd
111END
112
113# uniforms for variant
114
115# one
116BUFFER variant_one DATA_TYPE int32 DATA
117 1
118END
119
120BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
121
122PIPELINE graphics variant_pipeline
123  ATTACH variant_vertex_shader
124  ATTACH variant_fragment_shader
125  FRAMEBUFFER_SIZE 256 256
126  BIND BUFFER variant_framebuffer AS color LOCATION 0
127  BIND BUFFER variant_one AS uniform DESCRIPTOR_SET 0 BINDING 0
128END
129CLEAR_COLOR variant_pipeline 0 0 0 255
130
131CLEAR variant_pipeline
132RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
133
134EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255
135