3 # Copyright 2020 Google LLC
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
9 # http://www.apache.org/licenses/LICENSE-2.0
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.
18 # A test for a coverage-gap found by GraphicsFuzz.
20 # Short description: A fragment shader that covers a specific instruction folding path.
22 # The test passes because shader always writes red.
24 SHADER vertex variant_vertex_shader PASSTHROUGH
26 # variant_fragment_shader is derived from the following GLSL:
28 # precision highp float;
30 # layout(location = 0) out vec4 _GLF_color;
31 # layout(set = 0, binding = 0) uniform buf0
38 # // Since zeroOne is (0, 1) the results will be (2, 5).
39 # vec2 v = mix(vec2(2, 3), vec2(4, 5), zeroOne);
40 # float d = distance(v, vec2(2, 5));
43 # _GLF_color = vec4(v.x - 1.0, v.y - 5.0, 0, 1);
45 # _GLF_color = vec4(0);
47 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
50 ; Generator: Khronos Glslang Reference Front End; 8
54 %1 = OpExtInstImport "GLSL.std.450"
55 OpMemoryModel Logical GLSL450
56 OpEntryPoint Fragment %4 "main" %38
57 OpExecutionMode %4 OriginUpperLeft
62 OpMemberName %16 0 "zeroOne"
65 OpName %38 "_GLF_color"
66 OpMemberDecorate %16 0 Offset 0
68 OpDecorate %18 DescriptorSet 0
69 OpDecorate %18 Binding 0
70 OpDecorate %38 Location 0
72 %3 = OpTypeFunction %2
74 %7 = OpTypeVector %6 2
75 %8 = OpTypePointer Function %7
78 %12 = OpConstantComposite %7 %10 %11
81 %15 = OpConstantComposite %7 %13 %14
83 %17 = OpTypePointer Uniform %16
84 %18 = OpVariable %17 Uniform
86 %20 = OpConstant %19 0
87 %21 = OpTypePointer Uniform %7
88 %25 = OpTypePointer Function %6
89 %28 = OpConstantComposite %7 %10 %14
90 %31 = OpConstant %6 0.100000001
92 %36 = OpTypeVector %6 4
93 %37 = OpTypePointer Output %36
94 %38 = OpVariable %37 Output
96 %40 = OpConstant %39 0
98 %45 = OpConstant %39 1
100 %52 = OpConstantComposite %36 %49 %49 %49 %49
101 %4 = OpFunction %2 None %3
103 %9 = OpVariable %8 Function
104 %26 = OpVariable %25 Function
105 %22 = OpAccessChain %21 %18 %20
107 %24 = OpExtInst %7 %1 FMix %12 %15 %23
110 %29 = OpExtInst %6 %1 Distance %27 %28
113 %33 = OpFOrdLessThan %32 %30 %31
114 OpSelectionMerge %35 None
115 OpBranchConditional %33 %34 %51
117 %41 = OpAccessChain %25 %9 %40
119 %44 = OpFSub %6 %42 %43
120 %46 = OpAccessChain %25 %9 %45
122 %48 = OpFSub %6 %47 %14
123 %50 = OpCompositeConstruct %36 %44 %48 %49 %43
134 # uniforms for variant
137 BUFFER variant_zeroOne DATA_TYPE vec2<float> DATA
141 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
143 PIPELINE graphics variant_pipeline
144 ATTACH variant_vertex_shader
145 ATTACH variant_fragment_shader
146 FRAMEBUFFER_SIZE 256 256
147 BIND BUFFER variant_framebuffer AS color LOCATION 0
148 BIND BUFFER variant_zeroOne AS uniform DESCRIPTOR_SET 0 BINDING 0
150 CLEAR_COLOR variant_pipeline 0 0 0 255
152 CLEAR variant_pipeline
153 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
155 EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255