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