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:
29 # precision highp int;
30 # precision highp float;
32 # layout(location = 0) out vec4 _GLF_color;
34 # // Contents of one: 1.0
35 # layout(set = 0, binding = 0) uniform buf0
44 # // Iterated until the break is executed.
45 # while(int(one) >= 1)
49 # _GLF_color = vec4(1, 0, 0, 1);
54 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
57 ; Generator: Khronos Glslang Reference Front End; 10
61 %1 = OpExtInstImport "GLSL.std.450"
62 OpMemoryModel Logical GLSL450
63 OpEntryPoint Fragment %4 "main" %34
64 OpExecutionMode %4 OriginUpperLeft
69 OpMemberName %16 0 "one"
71 OpName %34 "_GLF_color"
72 OpMemberDecorate %16 0 Offset 0
74 OpDecorate %18 DescriptorSet 0
75 OpDecorate %18 Binding 0
76 OpDecorate %34 Location 0
78 %3 = OpTypeFunction %2
80 %7 = OpTypePointer Function %6
83 %16 = OpTypeStruct %15
84 %17 = OpTypePointer Uniform %16
85 %18 = OpVariable %17 Uniform
87 %20 = OpTypePointer Uniform %15
90 %32 = OpTypeVector %15 4
91 %33 = OpTypePointer Output %32
92 %34 = OpVariable %33 Output
93 %35 = OpConstant %15 1
94 %36 = OpConstant %15 0
95 %37 = OpConstantComposite %32 %35 %36 %36 %35
96 %4 = OpFunction %2 None %3
98 %8 = OpVariable %7 Function
102 OpLoopMerge %12 %13 None
105 %21 = OpAccessChain %20 %18 %19
107 %23 = OpConvertFToS %6 %22
108 %25 = OpSGreaterThanEqual %24 %23 %9
109 OpBranchConditional %25 %11 %12
112 %27 = OpIAdd %6 %26 %9
114 %29 = OpSGreaterThanEqual %24 %26 %28
115 OpSelectionMerge %31 None
116 OpBranchConditional %29 %30 %31
129 # uniforms for variant
132 BUFFER variant_one DATA_TYPE float STD140 DATA
136 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
138 PIPELINE graphics variant_pipeline
139 ATTACH variant_vertex_shader
140 ATTACH variant_fragment_shader
141 FRAMEBUFFER_SIZE 256 256
142 BIND BUFFER variant_framebuffer AS color LOCATION 0
143 BIND BUFFER variant_one AS uniform DESCRIPTOR_SET 0 BINDING 0
145 CLEAR_COLOR variant_pipeline 0 0 0 255
147 CLEAR variant_pipeline
148 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
150 EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255