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 BRW 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 # #define _int_0 _GLF_uniform_int_values[0]
31 # precision highp int;
32 # precision highp float;
34 # // Contents of _GLF_uniform_int_values: 0
35 # layout(set = 0, binding = 0) uniform buf0
37 # int _GLF_uniform_int_values[1];
40 # // Contents of one: 1
41 # layout(set = 0, binding = 1) uniform buf1
46 # layout(location = 0) out vec4 _GLF_color;
48 # // Function is missing return value at the end,
49 # // but this function is never called.
64 # if (gl_FragCoord.y < 0.0)
70 # if (packUnorm4x8(v) == 1u)
76 # if ((1u << one) == 2u)
78 # _GLF_color = vec4(1, 0, 0, 1);
82 # _GLF_color = vec4(_int_0);
85 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
88 ; Generator: Khronos Glslang Reference Front End; 10
92 %1 = OpExtInstImport "GLSL.std.450"
93 OpMemoryModel Logical GLSL450
94 OpEntryPoint Fragment %4 "main" %23 %55
95 OpExecutionMode %4 OriginUpperLeft
100 OpName %23 "gl_FragCoord"
102 OpMemberName %42 0 "one"
104 OpName %55 "_GLF_color"
106 OpMemberName %59 0 "_GLF_uniform_int_values"
108 OpDecorate %23 BuiltIn FragCoord
109 OpMemberDecorate %42 0 Offset 0
111 OpDecorate %44 DescriptorSet 0
112 OpDecorate %44 Binding 1
113 OpDecorate %55 Location 0
114 OpDecorate %58 ArrayStride 16
115 OpMemberDecorate %59 0 Offset 0
117 OpDecorate %61 DescriptorSet 0
118 OpDecorate %61 Binding 0
120 %3 = OpTypeFunction %2
122 %7 = OpTypeFunction %6
124 %11 = OpConstant %10 1
125 %14 = OpConstant %6 1
126 %18 = OpTypeVector %6 4
127 %19 = OpTypePointer Function %18
128 %21 = OpConstantComposite %18 %14 %14 %14 %14
129 %22 = OpTypePointer Input %18
130 %23 = OpVariable %22 Input
132 %25 = OpConstant %24 1
133 %26 = OpTypePointer Input %6
134 %29 = OpConstant %6 0
136 %42 = OpTypeStruct %24
137 %43 = OpTypePointer Uniform %42
138 %44 = OpVariable %43 Uniform
139 %45 = OpConstant %10 0
140 %46 = OpTypePointer Uniform %24
141 %50 = OpConstant %24 2
142 %54 = OpTypePointer Output %18
143 %55 = OpVariable %54 Output
144 %56 = OpConstantComposite %18 %14 %29 %29 %14
145 %58 = OpTypeArray %10 %25
146 %59 = OpTypeStruct %58
147 %60 = OpTypePointer Uniform %59
148 %61 = OpVariable %60 Uniform
149 %62 = OpTypePointer Uniform %10
150 %4 = OpFunction %2 None %3
152 %20 = OpVariable %19 Function
154 %27 = OpAccessChain %26 %23 %25
156 %31 = OpFOrdLessThan %30 %28 %29
157 OpSelectionMerge %33 None
158 OpBranchConditional %31 %32 %33
160 %34 = OpFunctionCall %6 %8
161 %35 = OpCompositeConstruct %18 %34 %34 %34 %34
166 %37 = OpExtInst %24 %1 PackUnorm4x8 %36
167 %38 = OpIEqual %30 %37 %25
168 OpSelectionMerge %40 None
169 OpBranchConditional %38 %39 %40
173 %47 = OpAccessChain %46 %44 %45
175 %49 = OpShiftLeftLogical %24 %25 %48
176 %51 = OpIEqual %30 %49 %50
177 OpSelectionMerge %53 None
178 OpBranchConditional %51 %52 %57
183 %63 = OpAccessChain %62 %61 %45 %45
185 %65 = OpConvertSToF %6 %64
186 %66 = OpCompositeConstruct %18 %65 %65 %65 %65
192 %8 = OpFunction %6 None %7
194 OpSelectionMerge %13 None
195 OpSwitch %11 %13 0 %12
204 # uniforms for variant
207 BUFFER variant_one DATA_TYPE uint32 STD140 DATA
210 # _GLF_uniform_int_values
211 BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
215 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
217 PIPELINE graphics variant_pipeline
218 ATTACH variant_vertex_shader
219 ATTACH variant_fragment_shader
220 FRAMEBUFFER_SIZE 256 256
221 BIND BUFFER variant_framebuffer AS color LOCATION 0
222 BIND BUFFER variant_one AS uniform DESCRIPTOR_SET 0 BINDING 1
223 BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 0
225 CLEAR_COLOR variant_pipeline 0 0 0 255
227 CLEAR variant_pipeline
228 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
230 EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255