3 # Copyright 2021 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 the GraphicsFuzz project.
20 # Short description: A fragment shader that covers specific LLVM code 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 # #define _int_1 _GLF_uniform_int_values[0]
29 # #define _int_0 _GLF_uniform_int_values[1]
31 # precision highp float;
32 # precision highp int;
34 # // Contents of _GLF_uniform_int_values: [1, 0]
35 # layout(set = 0, binding = 0) uniform buf0
37 # int _GLF_uniform_int_values[2];
40 # layout(location = 0) out vec4 _GLF_color;
46 # if(gl_FragCoord.y > 10.0)
51 # // Before division a is either 0 or 1. In both cases integer division results in zero.
57 # _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1);
61 # _GLF_color = vec4(_int_0);
64 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
67 ; Generator: Khronos Glslang Reference Front End; 10
71 %1 = OpExtInstImport "GLSL.std.450"
72 OpMemoryModel Logical GLSL450
73 OpEntryPoint Fragment %4 "main" %13 %35
74 OpExecutionMode %4 OriginUpperLeft
78 OpName %13 "gl_FragCoord"
79 OpName %35 "_GLF_color"
81 OpMemberName %38 0 "_GLF_uniform_int_values"
83 OpDecorate %13 BuiltIn FragCoord
84 OpDecorate %35 Location 0
85 OpDecorate %37 ArrayStride 16
86 OpMemberDecorate %38 0 Offset 0
88 OpDecorate %40 DescriptorSet 0
89 OpDecorate %40 Binding 0
91 %3 = OpTypeFunction %2
93 %7 = OpTypePointer Function %6
96 %11 = OpTypeVector %10 4
97 %12 = OpTypePointer Input %11
98 %13 = OpVariable %12 Input
100 %15 = OpConstant %14 1
101 %16 = OpTypePointer Input %10
102 %19 = OpConstant %10 10
104 %25 = OpConstant %6 1
105 %27 = OpConstant %6 2
106 %34 = OpTypePointer Output %11
107 %35 = OpVariable %34 Output
108 %36 = OpConstant %14 2
109 %37 = OpTypeArray %6 %36
110 %38 = OpTypeStruct %37
111 %39 = OpTypePointer Uniform %38
112 %40 = OpVariable %39 Uniform
113 %41 = OpTypePointer Uniform %6
114 %4 = OpFunction %2 None %3
116 %8 = OpVariable %7 Function
118 %17 = OpAccessChain %16 %13 %15
120 %21 = OpFOrdGreaterThan %20 %18 %19
121 OpSelectionMerge %23 None
122 OpBranchConditional %21 %22 %23
125 %26 = OpIAdd %6 %24 %25
130 %29 = OpSDiv %6 %28 %27
133 %31 = OpIEqual %20 %30 %9
134 OpSelectionMerge %33 None
135 OpBranchConditional %31 %32 %55
137 %42 = OpAccessChain %41 %40 %9 %9
139 %44 = OpConvertSToF %10 %43
140 %45 = OpAccessChain %41 %40 %9 %25
142 %47 = OpConvertSToF %10 %46
143 %48 = OpAccessChain %41 %40 %9 %25
145 %50 = OpConvertSToF %10 %49
146 %51 = OpAccessChain %41 %40 %9 %9
148 %53 = OpConvertSToF %10 %52
149 %54 = OpCompositeConstruct %11 %44 %47 %50 %53
153 %56 = OpAccessChain %41 %40 %9 %25
155 %58 = OpConvertSToF %10 %57
156 %59 = OpCompositeConstruct %11 %58 %58 %58 %58
164 # uniforms for variant
166 # _GLF_uniform_int_values
167 BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
171 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
173 PIPELINE graphics variant_pipeline
174 ATTACH variant_vertex_shader
175 ATTACH variant_fragment_shader
176 FRAMEBUFFER_SIZE 256 256
177 BIND BUFFER variant_framebuffer AS color LOCATION 0
178 BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 0
180 CLEAR_COLOR variant_pipeline 0 0 0 255
182 CLEAR variant_pipeline
183 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
185 EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255