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 machine value type code 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;
29 # precision highp int;
31 # layout(location = 0) out vec4 _GLF_color;
33 # layout(set = 0, binding = 0) uniform buf0
35 # vec2 injectionSwitch;
41 # for(int i = 0; i < int(injectionSwitch.y); i++)
48 # a = ((int(injectionSwitch.y) * 2) / 2);
51 # if (a == 1) // Always true.
52 # _GLF_color = vec4(1, 0, 0, 1);
54 # _GLF_color = vec4(0);
56 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
59 ; Generator: Khronos Glslang Reference Front End; 8
63 %1 = OpExtInstImport "GLSL.std.450"
64 OpMemoryModel Logical GLSL450
65 OpEntryPoint Fragment %4 "main" %50
66 OpExecutionMode %4 OriginUpperLeft
72 OpMemberName %19 0 "injectionSwitch"
74 OpName %50 "_GLF_color"
75 OpMemberDecorate %19 0 Offset 0
77 OpDecorate %21 DescriptorSet 0
78 OpDecorate %21 Binding 0
79 OpDecorate %50 Location 0
81 %3 = OpTypeFunction %2
83 %7 = OpTypePointer Function %6
86 %18 = OpTypeVector %17 2
87 %19 = OpTypeStruct %18
88 %20 = OpTypePointer Uniform %19
89 %21 = OpVariable %20 Uniform
91 %23 = OpConstant %22 1
92 %24 = OpTypePointer Uniform %17
96 %48 = OpTypeVector %17 4
97 %49 = OpTypePointer Output %48
98 %50 = OpVariable %49 Output
99 %51 = OpConstant %17 1
100 %52 = OpConstant %17 0
101 %53 = OpConstantComposite %48 %51 %52 %52 %51
102 %55 = OpConstantComposite %48 %52 %52 %52 %52
103 %4 = OpFunction %2 None %3
105 %8 = OpVariable %7 Function
106 %10 = OpVariable %7 Function
111 OpLoopMerge %13 %14 None
115 %25 = OpAccessChain %24 %21 %9 %23
117 %27 = OpConvertFToS %6 %26
118 %29 = OpSLessThan %28 %16 %27
119 OpBranchConditional %29 %12 %13
122 %31 = OpSGreaterThan %28 %30 %9
123 OpSelectionMerge %33 None
124 OpBranchConditional %31 %32 %33
128 %35 = OpAccessChain %24 %21 %9 %23
130 %37 = OpConvertFToS %6 %36
131 %39 = OpIMul %6 %37 %38
132 %40 = OpSDiv %6 %39 %38
137 %43 = OpIAdd %6 %41 %42
142 %45 = OpIEqual %28 %44 %42
143 OpSelectionMerge %47 None
144 OpBranchConditional %45 %46 %54
156 # uniforms for variant
159 BUFFER variant_injectionSwitch DATA_TYPE vec2<float> DATA
163 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
165 PIPELINE graphics variant_pipeline
166 ATTACH variant_vertex_shader
167 ATTACH variant_fragment_shader
168 FRAMEBUFFER_SIZE 256 256
169 BIND BUFFER variant_framebuffer AS color LOCATION 0
170 BIND BUFFER variant_injectionSwitch AS uniform DESCRIPTOR_SET 0 BINDING 0
172 CLEAR_COLOR variant_pipeline 0 0 0 255
174 CLEAR variant_pipeline
175 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
177 EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255