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