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 IR builder 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;
32 # layout(set = 0, binding = 0) uniform buf0
39 # mat4 m = mat4(1.0, 1.0, 0.0, 1.0,
42 # 0.0, 0.0, 0.0, 0.0);
44 # if(abs(determinant(m)) < 0.01)
45 # _GLF_color = vec4(1, 0, 0, 1);
47 # _GLF_color = vec4(0);
49 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
52 ; Generator: Khronos Glslang Reference Front End; 8
56 %1 = OpExtInstImport "GLSL.std.450"
57 OpMemoryModel Logical GLSL450
58 OpEntryPoint Fragment %4 "main" %35
59 OpExecutionMode %4 OriginUpperLeft
64 OpMemberName %13 0 "one"
66 OpName %35 "_GLF_color"
67 OpMemberDecorate %13 0 Offset 0
69 OpDecorate %15 DescriptorSet 0
70 OpDecorate %15 Binding 0
71 OpDecorate %35 Location 0
73 %3 = OpTypeFunction %2
75 %7 = OpTypeVector %6 4
76 %8 = OpTypeMatrix %7 4
77 %9 = OpTypePointer Function %8
81 %14 = OpTypePointer Uniform %13
82 %15 = OpVariable %14 Uniform
84 %17 = OpConstant %16 0
85 %18 = OpTypePointer Uniform %6
86 %29 = OpConstant %6 0.00999999978
88 %34 = OpTypePointer Output %7
89 %35 = OpVariable %34 Output
90 %36 = OpConstantComposite %7 %11 %12 %12 %11
91 %38 = OpConstantComposite %7 %12 %12 %12 %12
92 %4 = OpFunction %2 None %3
94 %10 = OpVariable %9 Function
95 %19 = OpAccessChain %18 %15 %17
97 %21 = OpCompositeConstruct %7 %11 %11 %12 %11
98 %22 = OpCompositeConstruct %7 %12 %12 %11 %11
99 %23 = OpCompositeConstruct %7 %12 %12 %20 %12
100 %24 = OpCompositeConstruct %7 %12 %12 %12 %12
101 %25 = OpCompositeConstruct %8 %21 %22 %23 %24
104 %27 = OpExtInst %6 %1 Determinant %26
105 %28 = OpExtInst %6 %1 FAbs %27
106 %31 = OpFOrdLessThan %30 %28 %29
107 OpSelectionMerge %33 None
108 OpBranchConditional %31 %32 %37
120 # uniforms for variant
123 BUFFER variant_one DATA_TYPE float DATA
127 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
129 PIPELINE graphics variant_pipeline
130 ATTACH variant_vertex_shader
131 ATTACH variant_fragment_shader
132 FRAMEBUFFER_SIZE 256 256
133 BIND BUFFER variant_framebuffer AS color LOCATION 0
134 BIND BUFFER variant_one AS uniform DESCRIPTOR_SET 0 BINDING 0
136 CLEAR_COLOR variant_pipeline 0 0 0 255
138 CLEAR variant_pipeline
139 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
141 EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255