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 the GraphicsFuzz project.
20 # Short description: A fragment shader that covers a specific const folding path
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_10 _GLF_uniform_int_values[0]
29 # #define _int_0 _GLF_uniform_int_values[1]
30 # #define _int_1 _GLF_uniform_int_values[2]
31 # #define _float_9_0 _GLF_uniform_float_values[0]
33 # precision highp float;
34 # precision highp int;
36 # // Contents of _GLF_uniform_float_values: 9.0
37 # layout(set = 0, binding = 0) uniform buf0
39 # float _GLF_uniform_float_values[1];
42 # // Contents of _GLF_uniform_int_values: [10, 0, 1]
43 # layout(set = 0, binding = 1) uniform buf1
45 # int _GLF_uniform_int_values[3];
48 # layout(location = 0) out vec4 _GLF_color;
53 # for (int i = _int_0; i < _int_10; i++)
58 # float f = arr[bitfieldInsert(9, 0, 0, 0) / 1];
59 # if (f == _float_9_0)
61 # _GLF_color = vec4(_int_1, _int_0, _int_0, 1);
65 # _GLF_color = vec4(0);
68 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
71 ; Generator: Khronos Glslang Reference Front End; 8
75 %1 = OpExtInstImport "GLSL.std.450"
76 OpMemoryModel Logical GLSL450
77 OpEntryPoint Fragment %4 "main" %62
78 OpExecutionMode %4 OriginUpperLeft
83 OpMemberName %12 0 "_GLF_uniform_int_values"
88 OpMemberName %51 0 "_GLF_uniform_float_values"
90 OpName %62 "_GLF_color"
91 OpDecorate %11 ArrayStride 16
92 OpMemberDecorate %12 0 Offset 0
94 OpDecorate %14 DescriptorSet 0
95 OpDecorate %14 Binding 1
96 OpDecorate %50 ArrayStride 16
97 OpMemberDecorate %51 0 Offset 0
99 OpDecorate %53 DescriptorSet 0
100 OpDecorate %53 Binding 0
101 OpDecorate %62 Location 0
103 %3 = OpTypeFunction %2
105 %7 = OpTypePointer Function %6
107 %10 = OpConstant %9 3
108 %11 = OpTypeArray %6 %10
109 %12 = OpTypeStruct %11
110 %13 = OpTypePointer Uniform %12
111 %14 = OpVariable %13 Uniform
112 %15 = OpConstant %6 0
113 %16 = OpConstant %6 1
114 %17 = OpTypePointer Uniform %6
117 %31 = OpConstant %9 10
118 %32 = OpTypeArray %30 %31
119 %33 = OpTypePointer Function %32
120 %38 = OpTypePointer Function %30
121 %43 = OpConstant %6 9
122 %49 = OpConstant %9 1
123 %50 = OpTypeArray %30 %49
124 %51 = OpTypeStruct %50
125 %52 = OpTypePointer Uniform %51
126 %53 = OpVariable %52 Uniform
127 %54 = OpTypePointer Uniform %30
128 %60 = OpTypeVector %30 4
129 %61 = OpTypePointer Output %60
130 %62 = OpVariable %61 Output
131 %63 = OpConstant %6 2
132 %73 = OpConstant %30 1
133 %76 = OpConstant %30 0
134 %77 = OpConstantComposite %60 %76 %76 %76 %76
135 %4 = OpFunction %2 None %3
137 %8 = OpVariable %7 Function
138 %34 = OpVariable %33 Function
139 %42 = OpVariable %38 Function
140 %18 = OpAccessChain %17 %14 %15 %16
145 OpLoopMerge %22 %23 None
149 %26 = OpAccessChain %17 %14 %15 %15
151 %29 = OpSLessThan %28 %25 %27
152 OpBranchConditional %29 %21 %22
156 %37 = OpConvertSToF %30 %36
157 %39 = OpAccessChain %38 %34 %35
162 %41 = OpIAdd %6 %40 %16
166 %44 = OpBitFieldInsert %6 %43 %15 %15 %15
167 %45 = OpSDiv %6 %44 %16
168 %46 = OpAccessChain %38 %34 %45
172 %55 = OpAccessChain %54 %53 %15 %15
174 %57 = OpFOrdEqual %28 %48 %56
175 OpSelectionMerge %59 None
176 OpBranchConditional %57 %58 %75
178 %64 = OpAccessChain %17 %14 %15 %63
180 %66 = OpConvertSToF %30 %65
181 %67 = OpAccessChain %17 %14 %15 %16
183 %69 = OpConvertSToF %30 %68
184 %70 = OpAccessChain %17 %14 %15 %16
186 %72 = OpConvertSToF %30 %71
187 %74 = OpCompositeConstruct %60 %66 %69 %72 %73
198 # uniforms for variant
200 # _GLF_uniform_int_values
201 BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
204 # _GLF_uniform_float_values
205 BUFFER variant__GLF_uniform_float_values DATA_TYPE float[] STD140 DATA
209 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
211 PIPELINE graphics variant_pipeline
212 ATTACH variant_vertex_shader
213 ATTACH variant_fragment_shader
214 FRAMEBUFFER_SIZE 256 256
215 BIND BUFFER variant_framebuffer AS color LOCATION 0
216 BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 1
217 BIND BUFFER variant__GLF_uniform_float_values AS uniform DESCRIPTOR_SET 0 BINDING 0
219 CLEAR_COLOR variant_pipeline 0 0 0 255
221 CLEAR variant_pipeline
222 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
224 EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255