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 specific value tracking and simplification paths
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
50 # // This will be overwritten later.
51 # _GLF_color = vec4(0, 1, 1, 0);
55 # // Increments a[2] to 4.
56 # a[clamp(++b, 0, 2)]++;
59 # _GLF_color = vec4(1, 0, 0, 1);
61 # _GLF_color = vec4(0);
63 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
66 ; Generator: Khronos Glslang Reference Front End; 8
70 %1 = OpExtInstImport "GLSL.std.450"
71 OpMemoryModel Logical GLSL450
72 OpEntryPoint Fragment %4 "main" %38
73 OpExecutionMode %4 OriginUpperLeft
80 OpMemberName %22 0 "one"
82 OpName %38 "_GLF_color"
83 OpMemberDecorate %22 0 Offset 0
85 OpDecorate %24 DescriptorSet 0
86 OpDecorate %24 Binding 0
87 OpDecorate %38 Location 0
89 %3 = OpTypeFunction %2
93 %9 = OpTypeArray %6 %8
94 %10 = OpTypePointer Function %9
97 %14 = OpTypePointer Function %6
100 %22 = OpTypeStruct %6
101 %23 = OpTypePointer Uniform %22
102 %24 = OpVariable %23 Uniform
103 %25 = OpTypePointer Uniform %6
106 %36 = OpTypeVector %35 4
107 %37 = OpTypePointer Output %36
108 %38 = OpVariable %37 Output
109 %39 = OpConstant %35 0
110 %40 = OpConstant %35 1
111 %41 = OpConstantComposite %36 %39 %40 %40 %39
112 %52 = OpConstant %6 4
113 %56 = OpConstantComposite %36 %40 %39 %39 %40
114 %58 = OpConstantComposite %36 %39 %39 %39 %39
115 %4 = OpFunction %2 None %3
117 %11 = OpVariable %10 Function
118 %20 = OpVariable %14 Function
119 %21 = OpVariable %14 Function
120 %15 = OpAccessChain %14 %11 %12
122 %17 = OpAccessChain %14 %11 %13
124 %19 = OpAccessChain %14 %11 %16
127 %26 = OpAccessChain %25 %24 %12
129 %28 = OpAccessChain %14 %11 %27
133 %32 = OpSGreaterThan %31 %30 %13
134 OpSelectionMerge %34 None
135 OpBranchConditional %32 %33 %34
139 %43 = OpIAdd %6 %42 %13
144 %45 = OpIAdd %6 %44 %13
146 %46 = OpExtInst %6 %1 SClamp %45 %12 %16
147 %47 = OpAccessChain %14 %11 %46
149 %49 = OpIAdd %6 %48 %13
151 %50 = OpAccessChain %14 %11 %16
153 %53 = OpIEqual %31 %51 %52
154 OpSelectionMerge %55 None
155 OpBranchConditional %53 %54 %57
167 # uniforms for variant
170 BUFFER variant_one DATA_TYPE int32 DATA
174 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
176 PIPELINE graphics variant_pipeline
177 ATTACH variant_vertex_shader
178 ATTACH variant_fragment_shader
179 FRAMEBUFFER_SIZE 256 256
180 BIND BUFFER variant_framebuffer AS color LOCATION 0
181 BIND BUFFER variant_one AS uniform DESCRIPTOR_SET 0 BINDING 0
183 CLEAR_COLOR variant_pipeline 0 0 0 255
185 CLEAR variant_pipeline
186 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
188 EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255