blob: a2263ed5ab8d94bc3789c52a39a26e34bc242fdc [file] [log] [blame]
#!amber
# Copyright 2021 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.
# Optimized using spirv-opt with the following arguments:
# '-O'
# spirv-opt commit hash: a0370efd589be33d5d9a85cfde2f85841b3755af
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_5 _GLF_uniform_int_values[2]
# #define _int_3 _GLF_uniform_int_values[3]
#
# precision highp float;
# precision highp int;
#
# // Contents of _GLF_uniform_int_values: [1, 0, 5, 3]
# layout(set = 0, binding = 0) uniform buf0
# {
# int _GLF_uniform_int_values[4];
# };
#
# const int _GLF_global_loop_bound = 10;
# int _GLF_global_loop_count = 0;
#
# // Contents of injectionSwitch: [0.0, 1.0]
# layout(set = 0, binding = 1) uniform buf1
# {
# highp vec2 injectionSwitch;
# };
#
# layout(location = 0) out vec4 _GLF_color;
#
# void main()
# {
# int a = _int_0;
#
# // Iterated three times.
# while(_GLF_global_loop_count < _GLF_global_loop_bound)
# {
# a++;
#
# // Iterated four times.
# for(int i = clamp(ivec2(1, int(injectionSwitch.y)), ivec2(0), ivec2(_int_1)).x; i < _int_5; i++)
# {
# _GLF_global_loop_count++;
# }
# }
#
# // Always true.
# if(a == _int_3)
# {
# _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: 102
; Schema: 0
OpCapability Shader
%1 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint Fragment %4 "main" %76
OpExecutionMode %4 OriginUpperLeft
OpSource ESSL 320
OpName %4 "main"
OpName %15 "buf0"
OpMemberName %15 0 "_GLF_uniform_int_values"
OpName %17 ""
OpName %76 "_GLF_color"
OpDecorate %14 ArrayStride 16
OpMemberDecorate %15 0 Offset 0
OpDecorate %15 Block
OpDecorate %17 DescriptorSet 0
OpDecorate %17 Binding 0
OpDecorate %76 Location 0
%2 = OpTypeVoid
%3 = OpTypeFunction %2
%6 = OpTypeInt 32 1
%9 = OpConstant %6 0
%12 = OpTypeInt 32 0
%13 = OpConstant %12 4
%14 = OpTypeArray %6 %13
%15 = OpTypeStruct %14
%16 = OpTypePointer Uniform %15
%17 = OpVariable %16 Uniform
%18 = OpConstant %6 1
%19 = OpTypePointer Uniform %6
%28 = OpConstant %6 10
%29 = OpTypeBool
%34 = OpTypeFloat 32
%44 = OpTypeVector %6 2
%46 = OpConstantComposite %44 %9 %9
%59 = OpConstant %6 2
%68 = OpConstant %6 3
%74 = OpTypeVector %34 4
%75 = OpTypePointer Output %74
%76 = OpVariable %75 Output
%101 = OpUndef %6
%4 = OpFunction %2 None %3
%5 = OpLabel
%20 = OpAccessChain %19 %17 %9 %18
%21 = OpLoad %6 %20
OpBranch %22
%22 = OpLabel
%96 = OpPhi %6 %21 %5 %32 %25
%95 = OpPhi %6 %9 %5 %98 %25
%30 = OpSLessThan %29 %95 %28
OpLoopMerge %24 %25 None
OpBranchConditional %30 %23 %24
%23 = OpLabel
%32 = OpIAdd %6 %96 %18
%45 = OpCompositeConstruct %44 %18 %101
%47 = OpAccessChain %19 %17 %9 %9
%48 = OpLoad %6 %47
%49 = OpCompositeConstruct %44 %48 %48
%50 = OpExtInst %44 %1 SClamp %45 %46 %49
%52 = OpCompositeExtract %6 %50 0
OpBranch %53
%53 = OpLabel
%98 = OpPhi %6 %95 %23 %64 %54
%97 = OpPhi %6 %52 %23 %66 %54
%60 = OpAccessChain %19 %17 %9 %59
%61 = OpLoad %6 %60
%62 = OpSLessThan %29 %97 %61
OpLoopMerge %55 %54 None
OpBranchConditional %62 %54 %55
%54 = OpLabel
%64 = OpIAdd %6 %98 %18
%66 = OpIAdd %6 %97 %18
OpBranch %53
%55 = OpLabel
OpBranch %25
%25 = OpLabel
OpBranch %22
%24 = OpLabel
%69 = OpAccessChain %19 %17 %9 %68
%70 = OpLoad %6 %69
%71 = OpIEqual %29 %96 %70
OpSelectionMerge %73 None
OpBranchConditional %71 %72 %90
%72 = OpLabel
%77 = OpAccessChain %19 %17 %9 %9
%78 = OpLoad %6 %77
%79 = OpConvertSToF %34 %78
%82 = OpConvertSToF %34 %21
%89 = OpCompositeConstruct %74 %79 %82 %82 %79
OpStore %76 %89
OpBranch %73
%90 = OpLabel
%93 = OpConvertSToF %34 %21
%94 = OpCompositeConstruct %74 %93 %93 %93 %93
OpStore %76 %94
OpBranch %73
%73 = OpLabel
OpReturn
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 5 3
END
BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
PIPELINE graphics variant_pipeline
ATTACH variant_vertex_shader
ATTACH variant_fragment_shader
FRAMEBUFFER_SIZE 256 256
BIND BUFFER variant_framebuffer AS color LOCATION 0
BIND BUFFER variant_injectionSwitch 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 256 256
EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255