Files
Vulkan-CTS-bin/vulkan/amber/graphicsfuzz/cov-function-loops-vector-mul-matrix-never-executed.amber
2026-05-06 23:44:13 +02:00

591 lines
18 KiB
Plaintext

#!amber
# Copyright 2022 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# A test for a coverage-gap found by the GraphicsFuzz project.
# Short description: A fragment shader that covers specific LLVM code paths
# The test passes because the shader always writes red.
SHADER vertex variant_vertex_shader PASSTHROUGH
# variant_fragment_shader is derived from the following GLSL:
# #version 320 es
#
# #define _int_1 _GLF_uniform_int_values[0]
# #define _int_0 _GLF_uniform_int_values[1]
# #define _int_2 _GLF_uniform_int_values[2]
# #define _int_4 _GLF_uniform_int_values[3]
# #define _float_1_0 _GLF_uniform_float_values[0]
# #define _float_0_0 _GLF_uniform_float_values[1]
# #define _float_2_0 _GLF_uniform_float_values[2]
#
# precision highp float;
# precision highp int;
#
# // Contents of _GLF_uniform_float_values: [1.0, 0.0, 2.0]
# layout(set = 0, binding = 0) uniform buf0
# {
# float _GLF_uniform_float_values[3];
# };
#
# // Contents of _GLF_uniform_int_values: [1, 0, 2, 4]
# layout(set = 0, binding = 1) uniform buf1
# {
# int _GLF_uniform_int_values[4];
# };
#
# // Contents of injectionSwitch: [0.0, 1.0]
# layout(set = 0, binding = 2) uniform buf2
# {
# highp vec2 injectionSwitch;
# };
#
# layout(location = 0) out vec4 _GLF_color;
#
# ivec4 func()
# {
# ivec4 v = ivec4(_int_1);
# int a = _int_1;
#
# // Iterates twice.
# for(int b = 0; b < 2; b++)
# {
# int c = 0;
#
# // Iterates three times.
# for(int d = _int_1; c < 3; d++)
# {
# // Always false.
# if(gl_FragCoord.x < _float_0_0)
# {
# if(injectionSwitch.y > _float_0_0)
# {
# vec2 v0 = vec2(_float_1_0) * mat2(_float_1_0);
# for(int i = _int_1; i >= 1; i--) { }
#
# vec2 v1 = vec2(_float_1_0) * mat2(_float_1_0);
# for(int i = _int_1; i >= 1; i--) { }
#
# vec2 v2 = vec2(_float_1_0) * mat2(_float_1_0);
# for(int i = _int_1; i >= 0; i--) { }
# }
# }
# else
# {
# c++;
# }
#
# // Same as a += d.
# for(int i = _int_0; i < d; i++)
# {
# a++;
# }
#
# a *= _int_2;
#
# // v = vec4(a);
# for(int i = _int_0; i < _int_4; i++)
# {
# v[i] = a;
# }
# }
# }
#
# return v;
# }
#
# // Same as func(), but manually simplified.
# ivec4 funcSimplified()
# {
# ivec4 v = ivec4(1);
# int a = 1;
#
# for(int b = 0; b < 2; b++)
# {
# for(int d = 1; d < 4; d++)
# {
# a = (a + d) * 2;
# }
# }
#
# return ivec4(a);
# }
#
# void main()
# {
# // Always true.
# if(func() == funcSimplified())
# {
# _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1);
# }
# else
# {
# _GLF_color = vec4(_int_0);
# }
# }
SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
; SPIR-V
; Version: 1.0
; Generator: Khronos Glslang Reference Front End; 10
; Bound: 259
; Schema: 0
OpCapability Shader
%1 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint Fragment %4 "main" %55 %240
OpExecutionMode %4 OriginUpperLeft
OpSource ESSL 320
OpName %4 "main"
OpName %9 "func("
OpName %11 "funcSimplified("
OpName %14 "v"
OpName %18 "buf1"
OpMemberName %18 0 "_GLF_uniform_int_values"
OpName %20 ""
OpName %27 "a"
OpName %30 "b"
OpName %40 "c"
OpName %41 "d"
OpName %55 "gl_FragCoord"
OpName %62 "buf0"
OpMemberName %62 0 "_GLF_uniform_float_values"
OpName %64 ""
OpName %73 "buf2"
OpMemberName %73 0 "injectionSwitch"
OpName %75 ""
OpName %85 "v0"
OpName %98 "i"
OpName %110 "v1"
OpName %120 "i"
OpName %132 "v2"
OpName %142 "i"
OpName %157 "i"
OpName %176 "i"
OpName %200 "v"
OpName %202 "a"
OpName %203 "b"
OpName %211 "d"
OpName %240 "_GLF_color"
OpDecorate %17 ArrayStride 16
OpMemberDecorate %18 0 Offset 0
OpDecorate %18 Block
OpDecorate %20 DescriptorSet 0
OpDecorate %20 Binding 1
OpDecorate %55 BuiltIn FragCoord
OpDecorate %61 ArrayStride 16
OpMemberDecorate %62 0 Offset 0
OpDecorate %62 Block
OpDecorate %64 DescriptorSet 0
OpDecorate %64 Binding 0
OpMemberDecorate %73 0 Offset 0
OpDecorate %73 Block
OpDecorate %75 DescriptorSet 0
OpDecorate %75 Binding 2
OpDecorate %240 Location 0
%2 = OpTypeVoid
%3 = OpTypeFunction %2
%6 = OpTypeInt 32 1
%7 = OpTypeVector %6 4
%8 = OpTypeFunction %7
%13 = OpTypePointer Function %7
%15 = OpTypeInt 32 0
%16 = OpConstant %15 4
%17 = OpTypeArray %6 %16
%18 = OpTypeStruct %17
%19 = OpTypePointer Uniform %18
%20 = OpVariable %19 Uniform
%21 = OpConstant %6 0
%22 = OpTypePointer Uniform %6
%26 = OpTypePointer Function %6
%37 = OpConstant %6 2
%38 = OpTypeBool
%50 = OpConstant %6 3
%52 = OpTypeFloat 32
%53 = OpTypeVector %52 4
%54 = OpTypePointer Input %53
%55 = OpVariable %54 Input
%56 = OpConstant %15 0
%57 = OpTypePointer Input %52
%60 = OpConstant %15 3
%61 = OpTypeArray %52 %60
%62 = OpTypeStruct %61
%63 = OpTypePointer Uniform %62
%64 = OpVariable %63 Uniform
%65 = OpConstant %6 1
%66 = OpTypePointer Uniform %52
%72 = OpTypeVector %52 2
%73 = OpTypeStruct %72
%74 = OpTypePointer Uniform %73
%75 = OpVariable %74 Uniform
%76 = OpConstant %15 1
%84 = OpTypePointer Function %72
%91 = OpTypeMatrix %72 2
%92 = OpConstant %52 1
%93 = OpConstant %52 0
%201 = OpConstantComposite %7 %65 %65 %65 %65
%218 = OpConstant %6 4
%234 = OpTypeVector %38 4
%239 = OpTypePointer Output %53
%240 = OpVariable %239 Output
%4 = OpFunction %2 None %3
%5 = OpLabel
%232 = OpFunctionCall %7 %9
%233 = OpFunctionCall %7 %11
%235 = OpIEqual %234 %232 %233
%236 = OpAll %38 %235
OpSelectionMerge %238 None
OpBranchConditional %236 %237 %254
%237 = OpLabel
%241 = OpAccessChain %22 %20 %21 %21
%242 = OpLoad %6 %241
%243 = OpConvertSToF %52 %242
%244 = OpAccessChain %22 %20 %21 %65
%245 = OpLoad %6 %244
%246 = OpConvertSToF %52 %245
%247 = OpAccessChain %22 %20 %21 %65
%248 = OpLoad %6 %247
%249 = OpConvertSToF %52 %248
%250 = OpAccessChain %22 %20 %21 %21
%251 = OpLoad %6 %250
%252 = OpConvertSToF %52 %251
%253 = OpCompositeConstruct %53 %243 %246 %249 %252
OpStore %240 %253
OpBranch %238
%254 = OpLabel
%255 = OpAccessChain %22 %20 %21 %65
%256 = OpLoad %6 %255
%257 = OpConvertSToF %52 %256
%258 = OpCompositeConstruct %53 %257 %257 %257 %257
OpStore %240 %258
OpBranch %238
%238 = OpLabel
OpReturn
OpFunctionEnd
%9 = OpFunction %7 None %8
%10 = OpLabel
%14 = OpVariable %13 Function
%27 = OpVariable %26 Function
%30 = OpVariable %26 Function
%40 = OpVariable %26 Function
%41 = OpVariable %26 Function
%85 = OpVariable %84 Function
%98 = OpVariable %26 Function
%110 = OpVariable %84 Function
%120 = OpVariable %26 Function
%132 = OpVariable %84 Function
%142 = OpVariable %26 Function
%157 = OpVariable %26 Function
%176 = OpVariable %26 Function
%23 = OpAccessChain %22 %20 %21 %21
%24 = OpLoad %6 %23
%25 = OpCompositeConstruct %7 %24 %24 %24 %24
OpStore %14 %25
%28 = OpAccessChain %22 %20 %21 %21
%29 = OpLoad %6 %28
OpStore %27 %29
OpStore %30 %21
OpBranch %31
%31 = OpLabel
OpLoopMerge %33 %34 None
OpBranch %35
%35 = OpLabel
%36 = OpLoad %6 %30
%39 = OpSLessThan %38 %36 %37
OpBranchConditional %39 %32 %33
%32 = OpLabel
OpStore %40 %21
%42 = OpAccessChain %22 %20 %21 %21
%43 = OpLoad %6 %42
OpStore %41 %43
OpBranch %44
%44 = OpLabel
OpLoopMerge %46 %47 None
OpBranch %48
%48 = OpLabel
%49 = OpLoad %6 %40
%51 = OpSLessThan %38 %49 %50
OpBranchConditional %51 %45 %46
%45 = OpLabel
%58 = OpAccessChain %57 %55 %56
%59 = OpLoad %52 %58
%67 = OpAccessChain %66 %64 %21 %65
%68 = OpLoad %52 %67
%69 = OpFOrdLessThan %38 %59 %68
OpSelectionMerge %71 None
OpBranchConditional %69 %70 %154
%70 = OpLabel
%77 = OpAccessChain %66 %75 %21 %76
%78 = OpLoad %52 %77
%79 = OpAccessChain %66 %64 %21 %65
%80 = OpLoad %52 %79
%81 = OpFOrdGreaterThan %38 %78 %80
OpSelectionMerge %83 None
OpBranchConditional %81 %82 %83
%82 = OpLabel
%86 = OpAccessChain %66 %64 %21 %21
%87 = OpLoad %52 %86
%88 = OpCompositeConstruct %72 %87 %87
%89 = OpAccessChain %66 %64 %21 %21
%90 = OpLoad %52 %89
%94 = OpCompositeConstruct %72 %90 %93
%95 = OpCompositeConstruct %72 %93 %90
%96 = OpCompositeConstruct %91 %94 %95
%97 = OpVectorTimesMatrix %72 %88 %96
OpStore %85 %97
%99 = OpAccessChain %22 %20 %21 %21
%100 = OpLoad %6 %99
OpStore %98 %100
OpBranch %101
%101 = OpLabel
OpLoopMerge %103 %104 None
OpBranch %105
%105 = OpLabel
%106 = OpLoad %6 %98
%107 = OpSGreaterThanEqual %38 %106 %65
OpBranchConditional %107 %102 %103
%102 = OpLabel
OpBranch %104
%104 = OpLabel
%108 = OpLoad %6 %98
%109 = OpISub %6 %108 %65
OpStore %98 %109
OpBranch %101
%103 = OpLabel
%111 = OpAccessChain %66 %64 %21 %21
%112 = OpLoad %52 %111
%113 = OpCompositeConstruct %72 %112 %112
%114 = OpAccessChain %66 %64 %21 %21
%115 = OpLoad %52 %114
%116 = OpCompositeConstruct %72 %115 %93
%117 = OpCompositeConstruct %72 %93 %115
%118 = OpCompositeConstruct %91 %116 %117
%119 = OpVectorTimesMatrix %72 %113 %118
OpStore %110 %119
%121 = OpAccessChain %22 %20 %21 %21
%122 = OpLoad %6 %121
OpStore %120 %122
OpBranch %123
%123 = OpLabel
OpLoopMerge %125 %126 None
OpBranch %127
%127 = OpLabel
%128 = OpLoad %6 %120
%129 = OpSGreaterThanEqual %38 %128 %65
OpBranchConditional %129 %124 %125
%124 = OpLabel
OpBranch %126
%126 = OpLabel
%130 = OpLoad %6 %120
%131 = OpISub %6 %130 %65
OpStore %120 %131
OpBranch %123
%125 = OpLabel
%133 = OpAccessChain %66 %64 %21 %21
%134 = OpLoad %52 %133
%135 = OpCompositeConstruct %72 %134 %134
%136 = OpAccessChain %66 %64 %21 %21
%137 = OpLoad %52 %136
%138 = OpCompositeConstruct %72 %137 %93
%139 = OpCompositeConstruct %72 %93 %137
%140 = OpCompositeConstruct %91 %138 %139
%141 = OpVectorTimesMatrix %72 %135 %140
OpStore %132 %141
%143 = OpAccessChain %22 %20 %21 %21
%144 = OpLoad %6 %143
OpStore %142 %144
OpBranch %145
%145 = OpLabel
OpLoopMerge %147 %148 None
OpBranch %149
%149 = OpLabel
%150 = OpLoad %6 %142
%151 = OpSGreaterThanEqual %38 %150 %21
OpBranchConditional %151 %146 %147
%146 = OpLabel
OpBranch %148
%148 = OpLabel
%152 = OpLoad %6 %142
%153 = OpISub %6 %152 %65
OpStore %142 %153
OpBranch %145
%147 = OpLabel
OpBranch %83
%83 = OpLabel
OpBranch %71
%154 = OpLabel
%155 = OpLoad %6 %40
%156 = OpIAdd %6 %155 %65
OpStore %40 %156
OpBranch %71
%71 = OpLabel
%158 = OpAccessChain %22 %20 %21 %65
%159 = OpLoad %6 %158
OpStore %157 %159
OpBranch %160
%160 = OpLabel
OpLoopMerge %162 %163 None
OpBranch %164
%164 = OpLabel
%165 = OpLoad %6 %157
%166 = OpLoad %6 %41
%167 = OpSLessThan %38 %165 %166
OpBranchConditional %167 %161 %162
%161 = OpLabel
%168 = OpLoad %6 %27
%169 = OpIAdd %6 %168 %65
OpStore %27 %169
OpBranch %163
%163 = OpLabel
%170 = OpLoad %6 %157
%171 = OpIAdd %6 %170 %65
OpStore %157 %171
OpBranch %160
%162 = OpLabel
%172 = OpAccessChain %22 %20 %21 %37
%173 = OpLoad %6 %172
%174 = OpLoad %6 %27
%175 = OpIMul %6 %174 %173
OpStore %27 %175
%177 = OpAccessChain %22 %20 %21 %65
%178 = OpLoad %6 %177
OpStore %176 %178
OpBranch %179
%179 = OpLabel
OpLoopMerge %181 %182 None
OpBranch %183
%183 = OpLabel
%184 = OpLoad %6 %176
%185 = OpAccessChain %22 %20 %21 %50
%186 = OpLoad %6 %185
%187 = OpSLessThan %38 %184 %186
OpBranchConditional %187 %180 %181
%180 = OpLabel
%188 = OpLoad %6 %176
%189 = OpLoad %6 %27
%190 = OpAccessChain %26 %14 %188
OpStore %190 %189
OpBranch %182
%182 = OpLabel
%191 = OpLoad %6 %176
%192 = OpIAdd %6 %191 %65
OpStore %176 %192
OpBranch %179
%181 = OpLabel
OpBranch %47
%47 = OpLabel
%193 = OpLoad %6 %41
%194 = OpIAdd %6 %193 %65
OpStore %41 %194
OpBranch %44
%46 = OpLabel
OpBranch %34
%34 = OpLabel
%195 = OpLoad %6 %30
%196 = OpIAdd %6 %195 %65
OpStore %30 %196
OpBranch %31
%33 = OpLabel
%197 = OpLoad %7 %14
OpReturnValue %197
OpFunctionEnd
%11 = OpFunction %7 None %8
%12 = OpLabel
%200 = OpVariable %13 Function
%202 = OpVariable %26 Function
%203 = OpVariable %26 Function
%211 = OpVariable %26 Function
OpStore %200 %201
OpStore %202 %65
OpStore %203 %21
OpBranch %204
%204 = OpLabel
OpLoopMerge %206 %207 None
OpBranch %208
%208 = OpLabel
%209 = OpLoad %6 %203
%210 = OpSLessThan %38 %209 %37
OpBranchConditional %210 %205 %206
%205 = OpLabel
OpStore %211 %65
OpBranch %212
%212 = OpLabel
OpLoopMerge %214 %215 None
OpBranch %216
%216 = OpLabel
%217 = OpLoad %6 %211
%219 = OpSLessThan %38 %217 %218
OpBranchConditional %219 %213 %214
%213 = OpLabel
%220 = OpLoad %6 %202
%221 = OpLoad %6 %211
%222 = OpIAdd %6 %220 %221
%223 = OpIMul %6 %222 %37
OpStore %202 %223
OpBranch %215
%215 = OpLabel
%224 = OpLoad %6 %211
%225 = OpIAdd %6 %224 %65
OpStore %211 %225
OpBranch %212
%214 = OpLabel
OpBranch %207
%207 = OpLabel
%226 = OpLoad %6 %203
%227 = OpIAdd %6 %226 %65
OpStore %203 %227
OpBranch %204
%206 = OpLabel
%228 = OpLoad %6 %202
%229 = OpCompositeConstruct %7 %228 %228 %228 %228
OpReturnValue %229
OpFunctionEnd
END
# uniforms for variant
# injectionSwitch
BUFFER variant_injectionSwitch DATA_TYPE vec2<float> STD140 DATA
0.0 1.0
END
# _GLF_uniform_int_values
BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
1 0 2 4
END
# _GLF_uniform_float_values
BUFFER variant__GLF_uniform_float_values DATA_TYPE float[] STD140 DATA
1.0 0.0 2.0
END
BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
PIPELINE graphics variant_pipeline
ATTACH variant_vertex_shader
ATTACH variant_fragment_shader
FRAMEBUFFER_SIZE 32 32
BIND BUFFER variant_framebuffer AS color LOCATION 0
BIND BUFFER variant_injectionSwitch AS uniform DESCRIPTOR_SET 0 BINDING 2
BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 1
BIND BUFFER variant__GLF_uniform_float_values AS uniform DESCRIPTOR_SET 0 BINDING 0
END
CLEAR_COLOR variant_pipeline 0 0 0 255
CLEAR variant_pipeline
RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 32 32
EXPECT variant_framebuffer IDX 0 0 SIZE 32 32 EQ_RGBA 255 0 0 255