Files
Vulkan-CTS-bin/vulkan/amber/graphicsfuzz/cov-function-unused-argument-single-loop-iteration-icrement-global-counter.amber
2026-05-06 23:44:13 +02:00

215 lines
6.6 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 _float_1_0 _GLF_uniform_float_values[0]
#
# precision highp float;
# precision highp int;
#
# // Contents of _GLF_uniform_int_values: 1
# layout(set = 0, binding = 0) uniform buf0
# {
# int _GLF_uniform_int_values[1];
# };
#
# // Contents of _GLF_uniform_float_values: 1.0
# layout(set = 0, binding = 1) uniform buf1
# {
# float _GLF_uniform_float_values[1];
# };
#
# const int _GLF_global_loop_bound = 10;
# int _GLF_global_loop_count = 0;
#
# layout(location = 0) out vec4 _GLF_color;
#
# void func(float ref)
# {
# // Iterates once.
# for(int i = 1; i > 0 && _GLF_global_loop_count < _GLF_global_loop_bound; i--)
# {
# _GLF_global_loop_count++;
# }
# }
# void main()
# {
# // The argument is not used by the function.
# func(_float_1_0);
#
# // Always true.
# if(_GLF_global_loop_count == _int_1)
# {
# _GLF_color = vec4(1, 0, 0, 1);
# }
# }
SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
; SPIR-V
; Version: 1.0
; Generator: Khronos Glslang Reference Front End; 10
; Bound: 63
; Schema: 0
OpCapability Shader
%1 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint Fragment %4 "main" %59
OpExecutionMode %4 OriginUpperLeft
OpSource ESSL 320
OpName %4 "main"
OpName %10 "func(f1;"
OpName %9 "ref"
OpName %14 "_GLF_global_loop_count"
OpName %17 "i"
OpName %38 "buf1"
OpMemberName %38 0 "_GLF_uniform_float_values"
OpName %40 ""
OpName %41 "param"
OpName %48 "buf0"
OpMemberName %48 0 "_GLF_uniform_int_values"
OpName %50 ""
OpName %59 "_GLF_color"
OpDecorate %37 ArrayStride 16
OpMemberDecorate %38 0 Offset 0
OpDecorate %38 Block
OpDecorate %40 DescriptorSet 0
OpDecorate %40 Binding 1
OpDecorate %47 ArrayStride 16
OpMemberDecorate %48 0 Offset 0
OpDecorate %48 Block
OpDecorate %50 DescriptorSet 0
OpDecorate %50 Binding 0
OpDecorate %59 Location 0
%2 = OpTypeVoid
%3 = OpTypeFunction %2
%6 = OpTypeFloat 32
%7 = OpTypePointer Function %6
%8 = OpTypeFunction %2 %7
%12 = OpTypeInt 32 1
%13 = OpTypePointer Private %12
%14 = OpVariable %13 Private
%15 = OpConstant %12 0
%16 = OpTypePointer Function %12
%18 = OpConstant %12 1
%25 = OpTypeBool
%28 = OpConstant %12 10
%35 = OpTypeInt 32 0
%36 = OpConstant %35 1
%37 = OpTypeArray %6 %36
%38 = OpTypeStruct %37
%39 = OpTypePointer Uniform %38
%40 = OpVariable %39 Uniform
%42 = OpTypePointer Uniform %6
%47 = OpTypeArray %12 %36
%48 = OpTypeStruct %47
%49 = OpTypePointer Uniform %48
%50 = OpVariable %49 Uniform
%51 = OpTypePointer Uniform %12
%57 = OpTypeVector %6 4
%58 = OpTypePointer Output %57
%59 = OpVariable %58 Output
%60 = OpConstant %6 1
%61 = OpConstant %6 0
%62 = OpConstantComposite %57 %60 %61 %61 %60
%4 = OpFunction %2 None %3
%5 = OpLabel
%41 = OpVariable %7 Function
OpStore %14 %15
%43 = OpAccessChain %42 %40 %15 %15
%44 = OpLoad %6 %43
OpStore %41 %44
%45 = OpFunctionCall %2 %10 %41
%46 = OpLoad %12 %14
%52 = OpAccessChain %51 %50 %15 %15
%53 = OpLoad %12 %52
%54 = OpIEqual %25 %46 %53
OpSelectionMerge %56 None
OpBranchConditional %54 %55 %56
%55 = OpLabel
OpStore %59 %62
OpBranch %56
%56 = OpLabel
OpReturn
OpFunctionEnd
%10 = OpFunction %2 None %8
%9 = OpFunctionParameter %7
%11 = OpLabel
%17 = OpVariable %16 Function
OpStore %17 %18
OpBranch %19
%19 = OpLabel
OpLoopMerge %21 %22 None
OpBranch %23
%23 = OpLabel
%24 = OpLoad %12 %17
%26 = OpSGreaterThan %25 %24 %15
%27 = OpLoad %12 %14
%29 = OpSLessThan %25 %27 %28
%30 = OpLogicalAnd %25 %26 %29
OpBranchConditional %30 %20 %21
%20 = OpLabel
%31 = OpLoad %12 %14
%32 = OpIAdd %12 %31 %18
OpStore %14 %32
OpBranch %22
%22 = OpLabel
%33 = OpLoad %12 %17
%34 = OpISub %12 %33 %18
OpStore %17 %34
OpBranch %19
%21 = OpLabel
OpReturn
OpFunctionEnd
END
# uniforms for variant
# _GLF_uniform_float_values
BUFFER variant__GLF_uniform_float_values DATA_TYPE float[] STD140 DATA
1.0
END
# _GLF_uniform_int_values
BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
1
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_float_values AS uniform DESCRIPTOR_SET 0 BINDING 1
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