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 SPIR-V reader 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]
30 # #define _int_1 _GLF_uniform_int_values[1]
31 # #define _float_1_0 _GLF_uniform_float_values[0]
33 # precision highp int;
34 # precision highp float;
36 # // Contents of _GLF_uniform_int_values: [0, 1]
37 # layout(set = 0, binding = 0) uniform buf0
39 # int _GLF_uniform_int_values[2];
41 # // Contents of _GLF_uniform_float_values: 1.0
42 # layout(set = 0, binding = 1) uniform buf1
44 # float _GLF_uniform_float_values[1];
46 # layout(location = 0) out vec4 _GLF_color;
48 # // Contents of m: [1.0, 5.0, 3.0, 7.0, 9.0, 6.0, 7.0, 8.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0]
49 # layout(push_constant) uniform buf_push
57 # if(m[_int_0][_int_0] == _float_1_0)
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" %41
76 OpExecutionMode %4 OriginUpperLeft
83 OpMemberName %17 0 "_GLF_uniform_int_values"
86 OpMemberName %30 0 "_GLF_uniform_float_values"
88 OpName %41 "_GLF_color"
89 OpMemberDecorate %9 0 ColMajor
90 OpMemberDecorate %9 0 Offset 0
91 OpMemberDecorate %9 0 MatrixStride 16
93 OpDecorate %16 ArrayStride 16
94 OpMemberDecorate %17 0 Offset 0
96 OpDecorate %19 DescriptorSet 0
97 OpDecorate %19 Binding 0
98 OpDecorate %29 ArrayStride 16
99 OpMemberDecorate %30 0 Offset 0
101 OpDecorate %32 DescriptorSet 0
102 OpDecorate %32 Binding 1
103 OpDecorate %41 Location 0
105 %3 = OpTypeFunction %2
107 %7 = OpTypeVector %6 4
108 %8 = OpTypeMatrix %7 4
110 %10 = OpTypePointer PushConstant %9
111 %11 = OpVariable %10 PushConstant
113 %13 = OpConstant %12 0
115 %15 = OpConstant %14 2
116 %16 = OpTypeArray %12 %15
117 %17 = OpTypeStruct %16
118 %18 = OpTypePointer Uniform %17
119 %19 = OpVariable %18 Uniform
120 %20 = OpTypePointer Uniform %12
121 %25 = OpTypePointer PushConstant %6
122 %28 = OpConstant %14 1
123 %29 = OpTypeArray %6 %28
124 %30 = OpTypeStruct %29
125 %31 = OpTypePointer Uniform %30
126 %32 = OpVariable %31 Uniform
127 %33 = OpTypePointer Uniform %6
129 %40 = OpTypePointer Output %7
130 %41 = OpVariable %40 Output
131 %42 = OpConstant %12 1
132 %4 = OpFunction %2 None %3
134 %21 = OpAccessChain %20 %19 %13 %13
136 %23 = OpAccessChain %20 %19 %13 %13
138 %26 = OpAccessChain %25 %11 %13 %22 %24
140 %34 = OpAccessChain %33 %32 %13 %13
142 %37 = OpFOrdEqual %36 %27 %35
143 OpSelectionMerge %39 None
144 OpBranchConditional %37 %38 %56
146 %43 = OpAccessChain %20 %19 %13 %42
148 %45 = OpConvertSToF %6 %44
149 %46 = OpAccessChain %20 %19 %13 %13
151 %48 = OpConvertSToF %6 %47
152 %49 = OpAccessChain %20 %19 %13 %13
154 %51 = OpConvertSToF %6 %50
155 %52 = OpAccessChain %20 %19 %13 %42
157 %54 = OpConvertSToF %6 %53
158 %55 = OpCompositeConstruct %7 %45 %48 %51 %54
162 %57 = OpAccessChain %20 %19 %13 %13
164 %59 = OpConvertSToF %6 %58
165 %60 = OpCompositeConstruct %7 %59 %59 %59 %59
173 # uniforms for variant
176 BUFFER variant_m DATA_TYPE mat4x4<float>[] STD140 DATA
177 1.0 5.0 3.0 7.0 9.0 6.0 7.0 8.0 1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0
179 # _GLF_uniform_float_values
180 BUFFER variant__GLF_uniform_float_values DATA_TYPE float[] STD140 DATA
183 # _GLF_uniform_int_values
184 BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
188 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
190 PIPELINE graphics variant_pipeline
191 ATTACH variant_vertex_shader
192 ATTACH variant_fragment_shader
193 FRAMEBUFFER_SIZE 256 256
194 BIND BUFFER variant_framebuffer AS color LOCATION 0
195 BIND BUFFER variant_m AS push_constant
196 BIND BUFFER variant__GLF_uniform_float_values AS uniform DESCRIPTOR_SET 0 BINDING 1
197 BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 0
199 CLEAR_COLOR variant_pipeline 0 0 0 255
201 CLEAR variant_pipeline
202 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
204 EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255