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 value tracking path
22 # The test passes because the 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;
29 # precision highp int;
31 # layout(location = 0) out vec4 _GLF_color;
32 # layout(set = 0, binding = 0) uniform buf0
40 # for (int i = 0; i < 2; i++)
47 # _GLF_color = vec4(1, 0, 0, 1);
51 # _GLF_color = vec4(0);
54 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
57 ; Generator: Khronos Glslang Reference Front End; 8
61 %1 = OpExtInstImport "GLSL.std.450"
62 OpMemoryModel Logical GLSL450
63 OpEntryPoint Fragment %4 "main" %34
64 OpExecutionMode %4 OriginUpperLeft
69 OpName %34 "_GLF_color"
71 OpMemberName %40 0 "two"
73 OpDecorate %34 Location 0
74 OpMemberDecorate %40 0 Offset 0
76 OpDecorate %42 DescriptorSet 0
77 OpDecorate %42 Binding 0
79 %3 = OpTypeFunction %2
81 %7 = OpTypePointer Function %6
85 %21 = OpConstant %6 -2
88 %32 = OpTypeVector %31 4
89 %33 = OpTypePointer Output %32
90 %34 = OpVariable %33 Output
91 %35 = OpConstant %31 1
92 %36 = OpConstant %31 0
93 %37 = OpConstantComposite %32 %35 %36 %36 %35
94 %39 = OpConstantComposite %32 %36 %36 %36 %36
96 %41 = OpTypePointer Uniform %40
97 %42 = OpVariable %41 Uniform
98 %4 = OpFunction %2 None %3
100 %8 = OpVariable %7 Function
101 %10 = OpVariable %7 Function
106 OpLoopMerge %13 %14 None
110 %19 = OpSLessThan %18 %16 %17
111 OpBranchConditional %19 %12 %13
114 %22 = OpBitwiseOr %6 %20 %21
115 %24 = OpISub %6 %22 %23
120 %26 = OpIAdd %6 %25 %23
125 %28 = OpIEqual %18 %27 %21
126 OpSelectionMerge %30 None
127 OpBranchConditional %28 %29 %38
139 # uniforms for variant
142 BUFFER variant_two DATA_TYPE int32 DATA
146 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
148 PIPELINE graphics variant_pipeline
149 ATTACH variant_vertex_shader
150 ATTACH variant_fragment_shader
151 FRAMEBUFFER_SIZE 256 256
152 BIND BUFFER variant_framebuffer AS color LOCATION 0
153 BIND BUFFER variant_two AS uniform DESCRIPTOR_SET 0 BINDING 0
155 CLEAR_COLOR variant_pipeline 0 0 0 255
157 CLEAR variant_pipeline
158 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
160 EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255