3 # Copyright 2019 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 constant handling 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 # // Mixing (1, 1) and (1, 1) is still (1, 1).
39 # vec2 mixed = mix(vec2(1), one, 0.5);
41 # // If condition is always true.
42 # if (mixed == vec2(1))
43 # _GLF_color = vec4(mixed.x, 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" %32
57 OpExecutionMode %4 OriginUpperLeft
62 OpMemberName %12 0 "one"
64 OpName %32 "_GLF_color"
65 OpMemberDecorate %12 0 Offset 0
67 OpDecorate %14 DescriptorSet 0
68 OpDecorate %14 Binding 0
69 OpDecorate %32 Location 0
71 %3 = OpTypeFunction %2
73 %7 = OpTypeVector %6 2
74 %8 = OpTypePointer Function %7
76 %11 = OpConstantComposite %7 %10 %10
78 %13 = OpTypePointer Uniform %12
79 %14 = OpVariable %13 Uniform
81 %16 = OpConstant %15 0
82 %17 = OpTypePointer Uniform %7
83 %20 = OpConstant %6 0.5
85 %25 = OpTypeVector %24 2
86 %30 = OpTypeVector %6 4
87 %31 = OpTypePointer Output %30
88 %32 = OpVariable %31 Output
90 %34 = OpConstant %33 0
91 %35 = OpTypePointer Function %6
93 %41 = OpConstantComposite %30 %38 %38 %38 %38
94 %4 = OpFunction %2 None %3
96 %9 = OpVariable %8 Function
97 %18 = OpAccessChain %17 %14 %16
99 %21 = OpCompositeConstruct %7 %20 %20
100 %22 = OpExtInst %7 %1 FMix %11 %19 %21
103 %26 = OpFOrdEqual %25 %23 %11
105 OpSelectionMerge %29 None
106 OpBranchConditional %27 %28 %40
108 %36 = OpAccessChain %35 %9 %34
110 %39 = OpCompositeConstruct %30 %37 %38 %38 %10
121 # uniforms for variant
124 BUFFER variant_one DATA_TYPE vec2<float> DATA
128 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
130 PIPELINE 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
137 CLEAR_COLOR variant_pipeline 0 0 0 255
139 CLEAR variant_pipeline
140 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
142 EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255