blob: 0c4d4c8ce921d5256f276c6812d4686bccee440b [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.
SHADER vertex variant_vertex_shader PASSTHROUGH
# variant_fragment_shader is derived from the following GLSL:
# #version 320 es
#
# #define _int_5 _GLF_uniform_int_values[0]
# #define _int_1 _GLF_uniform_int_values[1]
# #define _int_0 _GLF_uniform_int_values[2]
# #define _int_2 _GLF_uniform_int_values[3]
# #define _float_0_0 _GLF_uniform_float_values[0]
#
# precision highp float;
# precision highp int;
#
# // Contents of _GLF_uniform_float_values: 0.0
# layout(set = 0, binding = 0) uniform buf0
# {
# float _GLF_uniform_float_values[1];
# };
# // Contents of _GLF_uniform_int_values: [5, 1, 0, 2]
# layout(set = 0, binding = 1) uniform buf1
# {
# int _GLF_uniform_int_values[4];
# };
# layout(location = 0) out vec4 _GLF_color;
#
# void main()
# {
# int arr[5] = int[5](_int_1, _int_1, _int_1, _int_1, _int_1);
# int a = _int_1;
#
# // This loop sets arr[1] = 2.
# do
# {
# int b = _int_0;
#
# // True after the first iteration.
# if(a > _int_1 && arr[a] == _int_1)
# {
# b++;
# }
#
# // Always false.
# if(gl_FragCoord.x < _float_0_0)
# {
# continue;
# }
#
# // True after the first iteration.
# if(b == _int_1)
# {
# break;
# }
# else
# {
# // Executed during the first iteration.
# arr[a] = _int_2;
# a++;
# }
# }
# while(true);
#
# _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1);
#
# // Check for expected results.
# int ref[5] = int[5](_int_1, _int_2, _int_1, _int_1, _int_1);
# for(int i = _int_0; i < _int_5; i++)
# {
# if(arr[i] != ref[i] || a != _int_2)
# {
# // Failure.
# _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: 159
; Schema: 0
OpCapability Shader
%1 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint Fragment %4 "main" %64 %98
OpExecutionMode %4 OriginUpperLeft
OpSource ESSL 320
OpName %4 "main"
OpName %11 "arr"
OpName %14 "buf1"
OpMemberName %14 0 "_GLF_uniform_int_values"
OpName %16 ""
OpName %32 "a"
OpName %39 "b"
OpName %64 "gl_FragCoord"
OpName %71 "buf0"
OpMemberName %71 0 "_GLF_uniform_float_values"
OpName %73 ""
OpName %98 "_GLF_color"
OpName %112 "ref"
OpName %124 "i"
OpDecorate %13 ArrayStride 16
OpMemberDecorate %14 0 Offset 0
OpDecorate %14 Block
OpDecorate %16 DescriptorSet 0
OpDecorate %16 Binding 1
OpDecorate %64 BuiltIn FragCoord
OpDecorate %70 ArrayStride 16
OpMemberDecorate %71 0 Offset 0
OpDecorate %71 Block
OpDecorate %73 DescriptorSet 0
OpDecorate %73 Binding 0
OpDecorate %98 Location 0
%2 = OpTypeVoid
%3 = OpTypeFunction %2
%6 = OpTypeInt 32 1
%7 = OpTypeInt 32 0
%8 = OpConstant %7 5
%9 = OpTypeArray %6 %8
%10 = OpTypePointer Function %9
%12 = OpConstant %7 4
%13 = OpTypeArray %6 %12
%14 = OpTypeStruct %13
%15 = OpTypePointer Uniform %14
%16 = OpVariable %15 Uniform
%17 = OpConstant %6 0
%18 = OpConstant %6 1
%19 = OpTypePointer Uniform %6
%31 = OpTypePointer Function %6
%40 = OpConstant %6 2
%43 = OpTypeBool
%61 = OpTypeFloat 32
%62 = OpTypeVector %61 4
%63 = OpTypePointer Input %62
%64 = OpVariable %63 Input
%65 = OpConstant %7 0
%66 = OpTypePointer Input %61
%69 = OpConstant %7 1
%70 = OpTypeArray %61 %69
%71 = OpTypeStruct %70
%72 = OpTypePointer Uniform %71
%73 = OpVariable %72 Uniform
%74 = OpTypePointer Uniform %61
%90 = OpConstant %6 3
%96 = OpConstantTrue %43
%97 = OpTypePointer Output %62
%98 = OpVariable %97 Output
%4 = OpFunction %2 None %3
%5 = OpLabel
%11 = OpVariable %10 Function
%32 = OpVariable %31 Function
%39 = OpVariable %31 Function
%112 = OpVariable %10 Function
%124 = OpVariable %31 Function
%20 = OpAccessChain %19 %16 %17 %18
%21 = OpLoad %6 %20
%22 = OpAccessChain %19 %16 %17 %18
%23 = OpLoad %6 %22
%24 = OpAccessChain %19 %16 %17 %18
%25 = OpLoad %6 %24
%26 = OpAccessChain %19 %16 %17 %18
%27 = OpLoad %6 %26
%28 = OpAccessChain %19 %16 %17 %18
%29 = OpLoad %6 %28
%30 = OpCompositeConstruct %9 %21 %23 %25 %27 %29
OpStore %11 %30
%33 = OpAccessChain %19 %16 %17 %18
%34 = OpLoad %6 %33
OpStore %32 %34
OpBranch %35
%35 = OpLabel
OpLoopMerge %37 %38 None
OpBranch %36
%36 = OpLabel
%41 = OpAccessChain %19 %16 %17 %40
%42 = OpLoad %6 %41
OpStore %39 %42
%44 = OpLoad %6 %32
%45 = OpAccessChain %19 %16 %17 %18
%46 = OpLoad %6 %45
%47 = OpSGreaterThan %43 %44 %46
OpSelectionMerge %49 None
OpBranchConditional %47 %48 %49
%48 = OpLabel
%50 = OpLoad %6 %32
%51 = OpAccessChain %31 %11 %50
%52 = OpLoad %6 %51
%53 = OpAccessChain %19 %16 %17 %18
%54 = OpLoad %6 %53
%55 = OpIEqual %43 %52 %54
OpBranch %49
%49 = OpLabel
%56 = OpPhi %43 %47 %36 %55 %48
OpSelectionMerge %58 None
OpBranchConditional %56 %57 %58
%57 = OpLabel
%59 = OpLoad %6 %39
%60 = OpIAdd %6 %59 %18
OpStore %39 %60
OpBranch %58
%58 = OpLabel
%67 = OpAccessChain %66 %64 %65
%68 = OpLoad %61 %67
%75 = OpAccessChain %74 %73 %17 %17
%76 = OpLoad %61 %75
%77 = OpFOrdLessThan %43 %68 %76
OpSelectionMerge %79 None
OpBranchConditional %77 %78 %79
%78 = OpLabel
OpBranch %38
%79 = OpLabel
%81 = OpLoad %6 %39
%82 = OpAccessChain %19 %16 %17 %18
%83 = OpLoad %6 %82
%84 = OpIEqual %43 %81 %83
OpSelectionMerge %86 None
OpBranchConditional %84 %85 %88
%85 = OpLabel
OpBranch %37
%88 = OpLabel
%89 = OpLoad %6 %32
%91 = OpAccessChain %19 %16 %17 %90
%92 = OpLoad %6 %91
%93 = OpAccessChain %31 %11 %89
OpStore %93 %92
%94 = OpLoad %6 %32
%95 = OpIAdd %6 %94 %18
OpStore %32 %95
OpBranch %86
%86 = OpLabel
OpBranch %38
%38 = OpLabel
OpBranchConditional %96 %35 %37
%37 = OpLabel
%99 = OpAccessChain %19 %16 %17 %18
%100 = OpLoad %6 %99
%101 = OpConvertSToF %61 %100
%102 = OpAccessChain %19 %16 %17 %40
%103 = OpLoad %6 %102
%104 = OpConvertSToF %61 %103
%105 = OpAccessChain %19 %16 %17 %40
%106 = OpLoad %6 %105
%107 = OpConvertSToF %61 %106
%108 = OpAccessChain %19 %16 %17 %18
%109 = OpLoad %6 %108
%110 = OpConvertSToF %61 %109
%111 = OpCompositeConstruct %62 %101 %104 %107 %110
OpStore %98 %111
%113 = OpAccessChain %19 %16 %17 %18
%114 = OpLoad %6 %113
%115 = OpAccessChain %19 %16 %17 %90
%116 = OpLoad %6 %115
%117 = OpAccessChain %19 %16 %17 %18
%118 = OpLoad %6 %117
%119 = OpAccessChain %19 %16 %17 %18
%120 = OpLoad %6 %119
%121 = OpAccessChain %19 %16 %17 %18
%122 = OpLoad %6 %121
%123 = OpCompositeConstruct %9 %114 %116 %118 %120 %122
OpStore %112 %123
%125 = OpAccessChain %19 %16 %17 %40
%126 = OpLoad %6 %125
OpStore %124 %126
OpBranch %127
%127 = OpLabel
OpLoopMerge %129 %130 None
OpBranch %131
%131 = OpLabel
%132 = OpLoad %6 %124
%133 = OpAccessChain %19 %16 %17 %17
%134 = OpLoad %6 %133
%135 = OpSLessThan %43 %132 %134
OpBranchConditional %135 %128 %129
%128 = OpLabel
%136 = OpLoad %6 %124
%137 = OpAccessChain %31 %11 %136
%138 = OpLoad %6 %137
%139 = OpLoad %6 %124
%140 = OpAccessChain %31 %112 %139
%141 = OpLoad %6 %140
%142 = OpINotEqual %43 %138 %141
%143 = OpLogicalNot %43 %142
OpSelectionMerge %145 None
OpBranchConditional %143 %144 %145
%144 = OpLabel
%146 = OpLoad %6 %32
%147 = OpAccessChain %19 %16 %17 %90
%148 = OpLoad %6 %147
%149 = OpINotEqual %43 %146 %148
OpBranch %145
%145 = OpLabel
%150 = OpPhi %43 %142 %128 %149 %144
OpSelectionMerge %152 None
OpBranchConditional %150 %151 %152
%151 = OpLabel
%153 = OpAccessChain %19 %16 %17 %40
%154 = OpLoad %6 %153
%155 = OpConvertSToF %61 %154
%156 = OpCompositeConstruct %62 %155 %155 %155 %155
OpStore %98 %156
OpBranch %152
%152 = OpLabel
OpBranch %130
%130 = OpLabel
%157 = OpLoad %6 %124
%158 = OpIAdd %6 %157 %18
OpStore %124 %158
OpBranch %127
%129 = OpLabel
OpReturn
OpFunctionEnd
END
# uniforms for variant
# _GLF_uniform_int_values
BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
5 1 0 2
END
# _GLF_uniform_float_values
BUFFER variant__GLF_uniform_float_values DATA_TYPE float[] STD140 DATA
0.0
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__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 256 256
EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255