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