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