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 arith builder code 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:
29 # #define _int_7 _GLF_uniform_int_values[0]
30 # #define _int_1 _GLF_uniform_int_values[1]
31 # #define _int_0 _GLF_uniform_int_values[2]
32 # #define _int_8 _GLF_uniform_int_values[3]
33 # #define _float_1_0 _GLF_uniform_float_values[0]
34 # #define _float_3_0 _GLF_uniform_float_values[1]
36 # precision highp float;
37 # precision highp int;
39 # // Contents of _GLF_uniform_int_values: [7, 1, 0, 8]
40 # layout(set = 0, binding = 0) uniform buf0
42 # int _GLF_uniform_int_values[4];
44 # // Contents of _GLF_uniform_float_values: [1.0, 3.0]
45 # layout(set = 0, binding = 1) uniform buf1
47 # float _GLF_uniform_float_values[2];
49 # layout(location = 0) out vec4 _GLF_color;
54 # float arr[10] = float[10](_float_1_0, _float_1_0, _float_1_0, _float_1_0, _float_1_0, _float_1_0, _float_1_0, pow(f, _float_3_0), _float_1_0, _float_1_0);
57 # if(int(arr[_int_7]) == _int_8)
59 # _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1);
63 # _GLF_color = vec4(_int_0);
66 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
69 ; Generator: Khronos Glslang Reference Front End; 10
73 %1 = OpExtInstImport "GLSL.std.450"
74 OpMemoryModel Logical GLSL450
75 OpEntryPoint Fragment %4 "main" %67
76 OpExecutionMode %4 OriginUpperLeft
82 OpMemberName %17 0 "_GLF_uniform_float_values"
85 OpMemberName %49 0 "_GLF_uniform_int_values"
87 OpName %67 "_GLF_color"
88 OpDecorate %16 ArrayStride 16
89 OpMemberDecorate %17 0 Offset 0
91 OpDecorate %19 DescriptorSet 0
92 OpDecorate %19 Binding 1
93 OpDecorate %48 ArrayStride 16
94 OpMemberDecorate %49 0 Offset 0
96 OpDecorate %51 DescriptorSet 0
97 OpDecorate %51 Binding 0
98 OpDecorate %67 Location 0
100 %3 = OpTypeFunction %2
102 %7 = OpTypePointer Function %6
105 %11 = OpConstant %10 10
106 %12 = OpTypeArray %6 %11
107 %13 = OpTypePointer Function %12
108 %15 = OpConstant %10 2
109 %16 = OpTypeArray %6 %15
110 %17 = OpTypeStruct %16
111 %18 = OpTypePointer Uniform %17
112 %19 = OpVariable %18 Uniform
114 %21 = OpConstant %20 0
115 %22 = OpTypePointer Uniform %6
116 %38 = OpConstant %20 1
117 %47 = OpConstant %10 4
118 %48 = OpTypeArray %20 %47
119 %49 = OpTypeStruct %48
120 %50 = OpTypePointer Uniform %49
121 %51 = OpVariable %50 Uniform
122 %52 = OpTypePointer Uniform %20
123 %58 = OpConstant %20 3
125 %65 = OpTypeVector %6 4
126 %66 = OpTypePointer Output %65
127 %67 = OpVariable %66 Output
128 %71 = OpConstant %20 2
129 %4 = OpFunction %2 None %3
131 %8 = OpVariable %7 Function
132 %14 = OpVariable %13 Function
134 %23 = OpAccessChain %22 %19 %21 %21
136 %25 = OpAccessChain %22 %19 %21 %21
138 %27 = OpAccessChain %22 %19 %21 %21
140 %29 = OpAccessChain %22 %19 %21 %21
142 %31 = OpAccessChain %22 %19 %21 %21
144 %33 = OpAccessChain %22 %19 %21 %21
146 %35 = OpAccessChain %22 %19 %21 %21
149 %39 = OpAccessChain %22 %19 %21 %38
151 %41 = OpExtInst %6 %1 Pow %37 %40
152 %42 = OpAccessChain %22 %19 %21 %21
154 %44 = OpAccessChain %22 %19 %21 %21
156 %46 = OpCompositeConstruct %12 %24 %26 %28 %30 %32 %34 %36 %41 %43 %45
158 %53 = OpAccessChain %52 %51 %21 %21
160 %55 = OpAccessChain %7 %14 %54
162 %57 = OpConvertFToS %20 %56
163 %59 = OpAccessChain %52 %51 %21 %58
165 %62 = OpIEqual %61 %57 %60
166 OpSelectionMerge %64 None
167 OpBranchConditional %62 %63 %82
169 %68 = OpAccessChain %52 %51 %21 %38
171 %70 = OpConvertSToF %6 %69
172 %72 = OpAccessChain %52 %51 %21 %71
174 %74 = OpConvertSToF %6 %73
175 %75 = OpAccessChain %52 %51 %21 %71
177 %77 = OpConvertSToF %6 %76
178 %78 = OpAccessChain %52 %51 %21 %38
180 %80 = OpConvertSToF %6 %79
181 %81 = OpCompositeConstruct %65 %70 %74 %77 %80
185 %83 = OpAccessChain %52 %51 %21 %71
187 %85 = OpConvertSToF %6 %84
188 %86 = OpCompositeConstruct %65 %85 %85 %85 %85
196 # uniforms for variant
198 # _GLF_uniform_float_values
199 BUFFER variant__GLF_uniform_float_values DATA_TYPE float[] STD140 DATA
202 # _GLF_uniform_int_values
203 BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
207 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
209 PIPELINE graphics variant_pipeline
210 ATTACH variant_vertex_shader
211 ATTACH variant_fragment_shader
212 FRAMEBUFFER_SIZE 256 256
213 BIND BUFFER variant_framebuffer AS color LOCATION 0
214 BIND BUFFER variant__GLF_uniform_float_values AS uniform DESCRIPTOR_SET 0 BINDING 1
215 BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 0
217 CLEAR_COLOR variant_pipeline 0 0 0 255
219 CLEAR variant_pipeline
220 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
222 EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255