Files
Vulkan-CTS-bin/vulkan/amber/graphicsfuzz/cov-loop-function-call-negative-argument.amber
2026-05-06 23:44:13 +02:00

431 lines
13 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_0 _GLF_uniform_int_values[0]
# #define _int_1 _GLF_uniform_int_values[1]
# #define _int_7 _GLF_uniform_int_values[2]
# #define _int_10 _GLF_uniform_int_values[3]
#
# precision highp float;
# precision highp int;
#
# // Contents of _GLF_uniform_int_values: [0, 1, 7, 10]
# layout(set = 0, binding = 0) uniform buf0
# {
# int _GLF_uniform_int_values[4];
# };
#
# layout(location = 0) out vec4 _GLF_color;
#
# int arr0[10] = int[10](0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
# int arr1[10] = int[10](1, 1, 1, 1, 1, 1, 1, 1, 1, 1);
#
# void func(int x)
# {
# int a = 1;
# int b = x;
#
# // Iterates seven times.
# while(b <= x)
# {
# if(a > 7)
# {
# break;
# }
#
# // Always false.
# if(arr0[clamp(b, 0, 1)] < arr0[0])
# {
# arr1[a] = arr0[b++];
# }
# else
# {
# arr1[a] = arr0[a];
# }
#
# a++;
# }
#
# arr1[a++] = b;
#
# for(int i = _int_0; i < _int_7; i++)
# {
# arr0[i] = arr1[_int_1];
# }
# }
#
# void main()
# {
# for(int a = _int_0; a < _int_7; a++)
# {
# for(int i = -10; i < 0; i++)
# {
# func(i);
# }
# }
#
# // Verify against expected results and set output to black if failed.
# _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1);
# int ref[10] = int[10](_int_1, _int_0, _int_0, _int_0, _int_0, _int_0, _int_0, _int_0, -_int_1, _int_1);
#
# for(int i = _int_0; i < _int_10; i++)
# {
# if(arr0[i] != _int_0 || arr1[i] != ref[i])
# {
# _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: 202
; Schema: 0
OpCapability Shader
%1 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint Fragment %4 "main" %126
OpExecutionMode %4 OriginUpperLeft
OpSource ESSL 320
OpName %4 "main"
OpName %10 "func(i1;"
OpName %9 "x"
OpName %16 "arr0"
OpName %19 "arr1"
OpName %22 "a"
OpName %23 "b"
OpName %68 "i"
OpName %71 "buf0"
OpMemberName %71 0 "_GLF_uniform_int_values"
OpName %73 ""
OpName %95 "a"
OpName %107 "i"
OpName %116 "param"
OpName %126 "_GLF_color"
OpName %141 "ref"
OpName %164 "i"
OpDecorate %70 ArrayStride 16
OpMemberDecorate %71 0 Offset 0
OpDecorate %71 Block
OpDecorate %73 DescriptorSet 0
OpDecorate %73 Binding 0
OpDecorate %126 Location 0
%2 = OpTypeVoid
%3 = OpTypeFunction %2
%6 = OpTypeInt 32 1
%7 = OpTypePointer Function %6
%8 = OpTypeFunction %2 %7
%12 = OpTypeInt 32 0
%13 = OpConstant %12 10
%14 = OpTypeArray %6 %13
%15 = OpTypePointer Private %14
%16 = OpVariable %15 Private
%17 = OpConstant %6 0
%18 = OpConstantComposite %14 %17 %17 %17 %17 %17 %17 %17 %17 %17 %17
%19 = OpVariable %15 Private
%20 = OpConstant %6 1
%21 = OpConstantComposite %14 %20 %20 %20 %20 %20 %20 %20 %20 %20 %20
%32 = OpTypeBool
%35 = OpConstant %6 7
%42 = OpTypePointer Private %6
%69 = OpConstant %12 4
%70 = OpTypeArray %6 %69
%71 = OpTypeStruct %70
%72 = OpTypePointer Uniform %71
%73 = OpVariable %72 Uniform
%74 = OpTypePointer Uniform %6
%83 = OpConstant %6 2
%108 = OpConstant %6 -10
%123 = OpTypeFloat 32
%124 = OpTypeVector %123 4
%125 = OpTypePointer Output %124
%126 = OpVariable %125 Output
%140 = OpTypePointer Function %14
%173 = OpConstant %6 3
%4 = OpFunction %2 None %3
%5 = OpLabel
%95 = OpVariable %7 Function
%107 = OpVariable %7 Function
%116 = OpVariable %7 Function
%141 = OpVariable %140 Function
%164 = OpVariable %7 Function
OpStore %16 %18
OpStore %19 %21
%96 = OpAccessChain %74 %73 %17 %17
%97 = OpLoad %6 %96
OpStore %95 %97
OpBranch %98
%98 = OpLabel
OpLoopMerge %100 %101 None
OpBranch %102
%102 = OpLabel
%103 = OpLoad %6 %95
%104 = OpAccessChain %74 %73 %17 %83
%105 = OpLoad %6 %104
%106 = OpSLessThan %32 %103 %105
OpBranchConditional %106 %99 %100
%99 = OpLabel
OpStore %107 %108
OpBranch %109
%109 = OpLabel
OpLoopMerge %111 %112 None
OpBranch %113
%113 = OpLabel
%114 = OpLoad %6 %107
%115 = OpSLessThan %32 %114 %17
OpBranchConditional %115 %110 %111
%110 = OpLabel
%117 = OpLoad %6 %107
OpStore %116 %117
%118 = OpFunctionCall %2 %10 %116
OpBranch %112
%112 = OpLabel
%119 = OpLoad %6 %107
%120 = OpIAdd %6 %119 %20
OpStore %107 %120
OpBranch %109
%111 = OpLabel
OpBranch %101
%101 = OpLabel
%121 = OpLoad %6 %95
%122 = OpIAdd %6 %121 %20
OpStore %95 %122
OpBranch %98
%100 = OpLabel
%127 = OpAccessChain %74 %73 %17 %20
%128 = OpLoad %6 %127
%129 = OpConvertSToF %123 %128
%130 = OpAccessChain %74 %73 %17 %17
%131 = OpLoad %6 %130
%132 = OpConvertSToF %123 %131
%133 = OpAccessChain %74 %73 %17 %17
%134 = OpLoad %6 %133
%135 = OpConvertSToF %123 %134
%136 = OpAccessChain %74 %73 %17 %20
%137 = OpLoad %6 %136
%138 = OpConvertSToF %123 %137
%139 = OpCompositeConstruct %124 %129 %132 %135 %138
OpStore %126 %139
%142 = OpAccessChain %74 %73 %17 %20
%143 = OpLoad %6 %142
%144 = OpAccessChain %74 %73 %17 %17
%145 = OpLoad %6 %144
%146 = OpAccessChain %74 %73 %17 %17
%147 = OpLoad %6 %146
%148 = OpAccessChain %74 %73 %17 %17
%149 = OpLoad %6 %148
%150 = OpAccessChain %74 %73 %17 %17
%151 = OpLoad %6 %150
%152 = OpAccessChain %74 %73 %17 %17
%153 = OpLoad %6 %152
%154 = OpAccessChain %74 %73 %17 %17
%155 = OpLoad %6 %154
%156 = OpAccessChain %74 %73 %17 %17
%157 = OpLoad %6 %156
%158 = OpAccessChain %74 %73 %17 %20
%159 = OpLoad %6 %158
%160 = OpSNegate %6 %159
%161 = OpAccessChain %74 %73 %17 %20
%162 = OpLoad %6 %161
%163 = OpCompositeConstruct %14 %143 %145 %147 %149 %151 %153 %155 %157 %160 %162
OpStore %141 %163
%165 = OpAccessChain %74 %73 %17 %17
%166 = OpLoad %6 %165
OpStore %164 %166
OpBranch %167
%167 = OpLabel
OpLoopMerge %169 %170 None
OpBranch %171
%171 = OpLabel
%172 = OpLoad %6 %164
%174 = OpAccessChain %74 %73 %17 %173
%175 = OpLoad %6 %174
%176 = OpSLessThan %32 %172 %175
OpBranchConditional %176 %168 %169
%168 = OpLabel
%177 = OpLoad %6 %164
%178 = OpAccessChain %42 %16 %177
%179 = OpLoad %6 %178
%180 = OpAccessChain %74 %73 %17 %17
%181 = OpLoad %6 %180
%182 = OpINotEqual %32 %179 %181
%183 = OpLogicalNot %32 %182
OpSelectionMerge %185 None
OpBranchConditional %183 %184 %185
%184 = OpLabel
%186 = OpLoad %6 %164
%187 = OpAccessChain %42 %19 %186
%188 = OpLoad %6 %187
%189 = OpLoad %6 %164
%190 = OpAccessChain %7 %141 %189
%191 = OpLoad %6 %190
%192 = OpINotEqual %32 %188 %191
OpBranch %185
%185 = OpLabel
%193 = OpPhi %32 %182 %168 %192 %184
OpSelectionMerge %195 None
OpBranchConditional %193 %194 %195
%194 = OpLabel
%196 = OpAccessChain %74 %73 %17 %17
%197 = OpLoad %6 %196
%198 = OpConvertSToF %123 %197
%199 = OpCompositeConstruct %124 %198 %198 %198 %198
OpStore %126 %199
OpBranch %195
%195 = OpLabel
OpBranch %170
%170 = OpLabel
%200 = OpLoad %6 %164
%201 = OpIAdd %6 %200 %20
OpStore %164 %201
OpBranch %167
%169 = OpLabel
OpReturn
OpFunctionEnd
%10 = OpFunction %2 None %8
%9 = OpFunctionParameter %7
%11 = OpLabel
%22 = OpVariable %7 Function
%23 = OpVariable %7 Function
%68 = OpVariable %7 Function
OpStore %22 %20
%24 = OpLoad %6 %9
OpStore %23 %24
OpBranch %25
%25 = OpLabel
OpLoopMerge %27 %28 None
OpBranch %29
%29 = OpLabel
%30 = OpLoad %6 %23
%31 = OpLoad %6 %9
%33 = OpSLessThanEqual %32 %30 %31
OpBranchConditional %33 %26 %27
%26 = OpLabel
%34 = OpLoad %6 %22
%36 = OpSGreaterThan %32 %34 %35
OpSelectionMerge %38 None
OpBranchConditional %36 %37 %38
%37 = OpLabel
OpBranch %27
%38 = OpLabel
%40 = OpLoad %6 %23
%41 = OpExtInst %6 %1 SClamp %40 %17 %20
%43 = OpAccessChain %42 %16 %41
%44 = OpLoad %6 %43
%45 = OpAccessChain %42 %16 %17
%46 = OpLoad %6 %45
%47 = OpSLessThan %32 %44 %46
OpSelectionMerge %49 None
OpBranchConditional %47 %48 %56
%48 = OpLabel
%50 = OpLoad %6 %22
%51 = OpLoad %6 %23
%52 = OpIAdd %6 %51 %20
OpStore %23 %52
%53 = OpAccessChain %42 %16 %51
%54 = OpLoad %6 %53
%55 = OpAccessChain %42 %19 %50
OpStore %55 %54
OpBranch %49
%56 = OpLabel
%57 = OpLoad %6 %22
%58 = OpLoad %6 %22
%59 = OpAccessChain %42 %16 %58
%60 = OpLoad %6 %59
%61 = OpAccessChain %42 %19 %57
OpStore %61 %60
OpBranch %49
%49 = OpLabel
%62 = OpLoad %6 %22
%63 = OpIAdd %6 %62 %20
OpStore %22 %63
OpBranch %28
%28 = OpLabel
OpBranch %25
%27 = OpLabel
%64 = OpLoad %6 %22
%65 = OpIAdd %6 %64 %20
OpStore %22 %65
%66 = OpLoad %6 %23
%67 = OpAccessChain %42 %19 %64
OpStore %67 %66
%75 = OpAccessChain %74 %73 %17 %17
%76 = OpLoad %6 %75
OpStore %68 %76
OpBranch %77
%77 = OpLabel
OpLoopMerge %79 %80 None
OpBranch %81
%81 = OpLabel
%82 = OpLoad %6 %68
%84 = OpAccessChain %74 %73 %17 %83
%85 = OpLoad %6 %84
%86 = OpSLessThan %32 %82 %85
OpBranchConditional %86 %78 %79
%78 = OpLabel
%87 = OpLoad %6 %68
%88 = OpAccessChain %74 %73 %17 %20
%89 = OpLoad %6 %88
%90 = OpAccessChain %42 %19 %89
%91 = OpLoad %6 %90
%92 = OpAccessChain %42 %16 %87
OpStore %92 %91
OpBranch %80
%80 = OpLabel
%93 = OpLoad %6 %68
%94 = OpIAdd %6 %93 %20
OpStore %68 %94
OpBranch %77
%79 = OpLabel
OpReturn
OpFunctionEnd
END
# uniforms for variant
# _GLF_uniform_int_values
BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
0 1 7 10
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__GLF_uniform_int_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