Files
Vulkan-CTS-bin/vulkan/amber/graphicsfuzz/cov-loop-decrease-integer-never-break.amber
T
2026-05-06 23:44:13 +02:00

170 lines
4.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
#
# precision highp float;
# precision highp int;
#
# // Contents of one: 1
# layout(push_constant) uniform buf_push
# {
# int one;
# };
#
# layout(location = 0) out vec4 _GLF_color;
#
# void main()
# {
# int a = 100;
#
# do
# {
# // Always false.
# if(one < 1)
# {
# break;
# }
#
# a--;
# }
# while(a > 1);
#
# // Always true.
# if(a == 1)
# {
# _GLF_color = vec4(1, 0, 0, 1);
# }
# else
# {
# _GLF_color = vec4(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: 44
; Schema: 0
OpCapability Shader
%1 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint Fragment %4 "main" %38
OpExecutionMode %4 OriginUpperLeft
OpSource ESSL 320
OpName %4 "main"
OpName %8 "a"
OpName %14 "buf_push"
OpMemberName %14 0 "one"
OpName %16 ""
OpName %38 "_GLF_color"
OpMemberDecorate %14 0 Offset 0
OpDecorate %14 Block
OpDecorate %38 Location 0
%2 = OpTypeVoid
%3 = OpTypeFunction %2
%6 = OpTypeInt 32 1
%7 = OpTypePointer Function %6
%9 = OpConstant %6 100
%14 = OpTypeStruct %6
%15 = OpTypePointer PushConstant %14
%16 = OpVariable %15 PushConstant
%17 = OpConstant %6 0
%18 = OpTypePointer PushConstant %6
%21 = OpConstant %6 1
%22 = OpTypeBool
%35 = OpTypeFloat 32
%36 = OpTypeVector %35 4
%37 = OpTypePointer Output %36
%38 = OpVariable %37 Output
%39 = OpConstant %35 1
%40 = OpConstant %35 0
%41 = OpConstantComposite %36 %39 %40 %40 %39
%43 = OpConstantComposite %36 %40 %40 %40 %40
%4 = OpFunction %2 None %3
%5 = OpLabel
%8 = OpVariable %7 Function
OpStore %8 %9
OpBranch %10
%10 = OpLabel
OpLoopMerge %12 %13 None
OpBranch %11
%11 = OpLabel
%19 = OpAccessChain %18 %16 %17
%20 = OpLoad %6 %19
%23 = OpSLessThan %22 %20 %21
OpSelectionMerge %25 None
OpBranchConditional %23 %24 %25
%24 = OpLabel
OpBranch %12
%25 = OpLabel
%27 = OpLoad %6 %8
%28 = OpISub %6 %27 %21
OpStore %8 %28
OpBranch %13
%13 = OpLabel
%29 = OpLoad %6 %8
%30 = OpSGreaterThan %22 %29 %21
OpBranchConditional %30 %10 %12
%12 = OpLabel
%31 = OpLoad %6 %8
%32 = OpIEqual %22 %31 %21
OpSelectionMerge %34 None
OpBranchConditional %32 %33 %42
%33 = OpLabel
OpStore %38 %41
OpBranch %34
%42 = OpLabel
OpStore %38 %43
OpBranch %34
%34 = OpLabel
OpReturn
OpFunctionEnd
END
# uniforms for variant
# one
BUFFER variant_one 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_one AS push_constant
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