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 NIR 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 # precision highp float;
29 # precision highp int;
31 # layout(set = 0, binding = 0) uniform buf0
36 # layout(location = 0) out highp vec4 _GLF_color;
43 # for (int i = 0; i < 5; i++)
48 # // intBitsToFloat produces NaN. Floor of NaN is undefined, but this
49 # // code is never executed.
50 # if (floor(intBitsToFloat(0xffc00000)) > 0.0)
62 # _GLF_color = vec4(1, 0, 0, 1);
64 # _GLF_color = vec4(0);
67 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
70 ; Generator: Khronos Glslang Reference Front End; 10
74 %1 = OpExtInstImport "GLSL.std.450"
75 OpMemoryModel Logical GLSL450
76 OpEntryPoint Fragment %4 "main" %50
77 OpExecutionMode %4 OriginUpperLeft
83 OpMemberName %20 0 "one"
85 OpName %50 "_GLF_color"
86 OpMemberDecorate %20 0 Offset 0
88 OpDecorate %22 DescriptorSet 0
89 OpDecorate %22 Binding 0
90 OpDecorate %50 Location 0
92 %3 = OpTypeFunction %2
94 %7 = OpTypePointer Function %6
99 %21 = OpTypePointer Uniform %20
100 %22 = OpVariable %21 Uniform
101 %23 = OpTypePointer Uniform %6
102 %29 = OpConstant %6 -4194304
104 %33 = OpConstant %30 0
105 %37 = OpConstant %6 -1
106 %40 = OpConstant %6 1
107 %48 = OpTypeVector %30 4
108 %49 = OpTypePointer Output %48
109 %50 = OpVariable %49 Output
110 %51 = OpConstant %30 1
111 %52 = OpConstantComposite %48 %51 %33 %33 %51
112 %54 = OpConstantComposite %48 %33 %33 %33 %33
113 %4 = OpFunction %2 None %3
115 %8 = OpVariable %7 Function
116 %10 = OpVariable %7 Function
121 OpLoopMerge %13 %14 None
125 %19 = OpSLessThan %18 %16 %17
126 OpBranchConditional %19 %12 %13
128 %24 = OpAccessChain %23 %22 %9
130 %26 = OpIEqual %18 %25 %9
131 OpSelectionMerge %28 None
132 OpBranchConditional %26 %27 %28
134 %31 = OpBitcast %30 %29
135 %32 = OpExtInst %30 %1 Floor %31
136 %34 = OpFOrdGreaterThan %18 %32 %33
137 OpSelectionMerge %36 None
138 OpBranchConditional %34 %35 %36
146 %41 = OpIAdd %6 %39 %40
151 %43 = OpIAdd %6 %42 %40
156 %45 = OpIEqual %18 %44 %17
157 OpSelectionMerge %47 None
158 OpBranchConditional %45 %46 %53
170 # uniforms for variant
173 BUFFER variant_one DATA_TYPE int32 STD140 DATA
177 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
179 PIPELINE graphics variant_pipeline
180 ATTACH variant_vertex_shader
181 ATTACH variant_fragment_shader
182 FRAMEBUFFER_SIZE 256 256
183 BIND BUFFER variant_framebuffer AS color LOCATION 0
184 BIND BUFFER variant_one AS uniform DESCRIPTOR_SET 0 BINDING 0
186 CLEAR_COLOR variant_pipeline 0 0 0 255
188 CLEAR variant_pipeline
189 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
191 EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255