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 simplification code 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;
33 # layout(set = 0, binding = 0) uniform buf0
43 # _GLF_color = vec4(1, 0, 0, 1);
45 # _GLF_color = vec4(0);
48 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
51 ; Generator: Khronos Glslang Reference Front End; 8
55 %1 = OpExtInstImport "GLSL.std.450"
56 OpMemoryModel Logical GLSL450
57 OpEntryPoint Fragment %4 "main" %28
58 OpExecutionMode %4 OriginUpperLeft
63 OpMemberName %9 0 "two"
65 OpName %28 "_GLF_color"
66 OpMemberDecorate %9 0 Offset 0
68 OpDecorate %11 DescriptorSet 0
69 OpDecorate %11 Binding 0
70 OpDecorate %28 Location 0
72 %3 = OpTypeFunction %2
74 %7 = OpTypePointer Function %6
76 %10 = OpTypePointer Uniform %9
77 %11 = OpVariable %10 Uniform
79 %13 = OpConstant %12 0
80 %14 = OpTypePointer Uniform %6
85 %26 = OpTypeVector %25 4
86 %27 = OpTypePointer Output %26
87 %28 = OpVariable %27 Output
88 %29 = OpConstant %25 1
89 %30 = OpConstant %25 0
90 %31 = OpConstantComposite %26 %29 %30 %30 %29
91 %33 = OpConstantComposite %26 %30 %30 %30 %30
92 %4 = OpFunction %2 None %3
94 %8 = OpVariable %7 Function
95 %15 = OpAccessChain %14 %11 %13
97 %18 = OpUDiv %6 %16 %17
100 %22 = OpIEqual %21 %19 %20
101 OpSelectionMerge %24 None
102 OpBranchConditional %22 %23 %32
114 # uniforms for variant
117 BUFFER variant_two DATA_TYPE uint32 DATA
121 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
123 PIPELINE graphics variant_pipeline
124 ATTACH variant_vertex_shader
125 ATTACH variant_fragment_shader
126 FRAMEBUFFER_SIZE 256 256
127 BIND BUFFER variant_framebuffer AS color LOCATION 0
128 BIND BUFFER variant_two AS uniform DESCRIPTOR_SET 0 BINDING 0
130 CLEAR_COLOR variant_pipeline 0 0 0 255
132 CLEAR variant_pipeline
133 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
135 EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255