blob: c9439ee530dc4b28cf72b344988599bc8d9ca107 [file] [log] [blame]
#!amber
# Copyright 2020 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 a specific instruction simplification path
# 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 310 es
# #define _int_0 _GLF_uniform_int_values[0]
# #define _int_2 _GLF_uniform_int_values[1]
# #define _int_3 _GLF_uniform_int_values[2]
# #define _int_4 _GLF_uniform_int_values[3]
# #define _int_5 _GLF_uniform_int_values[4]
# #define _int_6 _GLF_uniform_int_values[5]
# #define _int_10 _GLF_uniform_int_values[6]
# #define _int_11 _GLF_uniform_int_values[7]
# #define _int_7 _GLF_uniform_int_values[8]
# #define _int_8 _GLF_uniform_int_values[9]
# #define _int_9 _GLF_uniform_int_values[10]
# #define _int_1 _GLF_uniform_int_values[11]
#
# precision highp float;
#
# // Contents of _GLF_uniform_int_values: [0, 2, 3, 4, 5, 6, 10, 11, 7, 8, 9, 1]
# layout(set = 0, binding = 0) uniform buf0
# {
# int _GLF_uniform_int_values[12];
# };
#
# layout(location = 0) out vec4 _GLF_color;
#
# // Always returns a.
# int f(int a)
# {
# for (int i = _int_0; i < _int_10; i++)
# {
# if (i > _int_3)
# {
# return a;
# }
# }
# return _int_0;
# }
# void main()
# {
# int a[10];
# int ref[10];
# ref[_int_0] = _int_2;
# ref[_int_1] = _int_3;
# ref[_int_2] = _int_4;
# ref[_int_3] = _int_5;
# ref[_int_4] = _int_6;
#
# ref[_int_5] = _int_10;
# ref[_int_6] = _int_11;
#
# ref[_int_7] = _int_7;
# ref[_int_8] = _int_8;
# ref[_int_9] = _int_9;
#
# for (int i = _int_0; i < _int_10; i++)
# {
# a[i] = i;
#
# // True for i = 0..4.
# if (i < _int_10 / _int_2)
# {
# a[i] = i + _int_2;
#
# // Always true.
# if (i < _int_10)
# {
# continue;
# }
#
# // Unreachable code below.
# a[i] = i + _int_7;
#
# if (f(a[i]) < _int_7)
# {
# a[i]--;
# }
# }
# else
# {
# // True for i = 5..6.
# if (f(a[i]) < _int_7)
# {
# a[i] += _int_5;
# }
# }
# }
# for (int i = _int_0; i < _int_10; i++)
# {
# if (a[i] != ref[i])
# {
# _GLF_color = vec4(_int_0);
# return;
# }
# }
# _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1);
# }
SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
; SPIR-V
; Version: 1.0
; Generator: Khronos Glslang Reference Front End; 8
; Bound: 235
; Schema: 0
OpCapability Shader
%1 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint Fragment %4 "main" %214
OpExecutionMode %4 OriginUpperLeft
OpSource ESSL 310
OpName %4 "main"
OpName %10 "f(i1;"
OpName %9 "a"
OpName %12 "i"
OpName %16 "buf0"
OpMemberName %16 0 "_GLF_uniform_int_values"
OpName %18 ""
OpName %53 "ref"
OpName %112 "i"
OpName %124 "a"
OpName %157 "param"
OpName %172 "param"
OpName %190 "i"
OpName %214 "_GLF_color"
OpDecorate %10 RelaxedPrecision
OpDecorate %9 RelaxedPrecision
OpDecorate %12 RelaxedPrecision
OpDecorate %15 ArrayStride 16
OpMemberDecorate %16 0 RelaxedPrecision
OpMemberDecorate %16 0 Offset 0
OpDecorate %16 Block
OpDecorate %18 DescriptorSet 0
OpDecorate %18 Binding 0
OpDecorate %22 RelaxedPrecision
OpDecorate %28 RelaxedPrecision
OpDecorate %31 RelaxedPrecision
OpDecorate %34 RelaxedPrecision
OpDecorate %37 RelaxedPrecision
OpDecorate %41 RelaxedPrecision
OpDecorate %43 RelaxedPrecision
OpDecorate %45 RelaxedPrecision
OpDecorate %47 RelaxedPrecision
OpDecorate %53 RelaxedPrecision
OpDecorate %55 RelaxedPrecision
OpDecorate %57 RelaxedPrecision
OpDecorate %61 RelaxedPrecision
OpDecorate %63 RelaxedPrecision
OpDecorate %66 RelaxedPrecision
OpDecorate %69 RelaxedPrecision
OpDecorate %72 RelaxedPrecision
OpDecorate %75 RelaxedPrecision
OpDecorate %78 RelaxedPrecision
OpDecorate %81 RelaxedPrecision
OpDecorate %84 RelaxedPrecision
OpDecorate %86 RelaxedPrecision
OpDecorate %89 RelaxedPrecision
OpDecorate %92 RelaxedPrecision
OpDecorate %96 RelaxedPrecision
OpDecorate %98 RelaxedPrecision
OpDecorate %102 RelaxedPrecision
OpDecorate %104 RelaxedPrecision
OpDecorate %108 RelaxedPrecision
OpDecorate %110 RelaxedPrecision
OpDecorate %112 RelaxedPrecision
OpDecorate %114 RelaxedPrecision
OpDecorate %120 RelaxedPrecision
OpDecorate %122 RelaxedPrecision
OpDecorate %124 RelaxedPrecision
OpDecorate %125 RelaxedPrecision
OpDecorate %126 RelaxedPrecision
OpDecorate %128 RelaxedPrecision
OpDecorate %130 RelaxedPrecision
OpDecorate %132 RelaxedPrecision
OpDecorate %133 RelaxedPrecision
OpDecorate %137 RelaxedPrecision
OpDecorate %138 RelaxedPrecision
OpDecorate %140 RelaxedPrecision
OpDecorate %141 RelaxedPrecision
OpDecorate %143 RelaxedPrecision
OpDecorate %145 RelaxedPrecision
OpDecorate %150 RelaxedPrecision
OpDecorate %151 RelaxedPrecision
OpDecorate %153 RelaxedPrecision
OpDecorate %154 RelaxedPrecision
OpDecorate %156 RelaxedPrecision
OpDecorate %159 RelaxedPrecision
OpDecorate %160 RelaxedPrecision
OpDecorate %162 RelaxedPrecision
OpDecorate %166 RelaxedPrecision
OpDecorate %168 RelaxedPrecision
OpDecorate %169 RelaxedPrecision
OpDecorate %171 RelaxedPrecision
OpDecorate %174 RelaxedPrecision
OpDecorate %175 RelaxedPrecision
OpDecorate %177 RelaxedPrecision
OpDecorate %181 RelaxedPrecision
OpDecorate %183 RelaxedPrecision
OpDecorate %185 RelaxedPrecision
OpDecorate %186 RelaxedPrecision
OpDecorate %188 RelaxedPrecision
OpDecorate %189 RelaxedPrecision
OpDecorate %190 RelaxedPrecision
OpDecorate %192 RelaxedPrecision
OpDecorate %198 RelaxedPrecision
OpDecorate %200 RelaxedPrecision
OpDecorate %202 RelaxedPrecision
OpDecorate %204 RelaxedPrecision
OpDecorate %205 RelaxedPrecision
OpDecorate %207 RelaxedPrecision
OpDecorate %214 Location 0
OpDecorate %216 RelaxedPrecision
OpDecorate %220 RelaxedPrecision
OpDecorate %221 RelaxedPrecision
OpDecorate %223 RelaxedPrecision
OpDecorate %226 RelaxedPrecision
OpDecorate %229 RelaxedPrecision
OpDecorate %232 RelaxedPrecision
%2 = OpTypeVoid
%3 = OpTypeFunction %2
%6 = OpTypeInt 32 1
%7 = OpTypePointer Function %6
%8 = OpTypeFunction %6 %7
%13 = OpTypeInt 32 0
%14 = OpConstant %13 12
%15 = OpTypeArray %6 %14
%16 = OpTypeStruct %15
%17 = OpTypePointer Uniform %16
%18 = OpVariable %17 Uniform
%19 = OpConstant %6 0
%20 = OpTypePointer Uniform %6
%29 = OpConstant %6 6
%32 = OpTypeBool
%35 = OpConstant %6 2
%44 = OpConstant %6 1
%50 = OpConstant %13 10
%51 = OpTypeArray %6 %50
%52 = OpTypePointer Function %51
%59 = OpConstant %6 11
%67 = OpConstant %6 3
%73 = OpConstant %6 4
%79 = OpConstant %6 5
%90 = OpConstant %6 7
%94 = OpConstant %6 8
%100 = OpConstant %6 9
%106 = OpConstant %6 10
%211 = OpTypeFloat 32
%212 = OpTypeVector %211 4
%213 = OpTypePointer Output %212
%214 = OpVariable %213 Output
%4 = OpFunction %2 None %3
%5 = OpLabel
%53 = OpVariable %52 Function
%112 = OpVariable %7 Function
%124 = OpVariable %52 Function
%157 = OpVariable %7 Function
%172 = OpVariable %7 Function
%190 = OpVariable %7 Function
%54 = OpAccessChain %20 %18 %19 %19
%55 = OpLoad %6 %54
%56 = OpAccessChain %20 %18 %19 %44
%57 = OpLoad %6 %56
%58 = OpAccessChain %7 %53 %55
OpStore %58 %57
%60 = OpAccessChain %20 %18 %19 %59
%61 = OpLoad %6 %60
%62 = OpAccessChain %20 %18 %19 %35
%63 = OpLoad %6 %62
%64 = OpAccessChain %7 %53 %61
OpStore %64 %63
%65 = OpAccessChain %20 %18 %19 %44
%66 = OpLoad %6 %65
%68 = OpAccessChain %20 %18 %19 %67
%69 = OpLoad %6 %68
%70 = OpAccessChain %7 %53 %66
OpStore %70 %69
%71 = OpAccessChain %20 %18 %19 %35
%72 = OpLoad %6 %71
%74 = OpAccessChain %20 %18 %19 %73
%75 = OpLoad %6 %74
%76 = OpAccessChain %7 %53 %72
OpStore %76 %75
%77 = OpAccessChain %20 %18 %19 %67
%78 = OpLoad %6 %77
%80 = OpAccessChain %20 %18 %19 %79
%81 = OpLoad %6 %80
%82 = OpAccessChain %7 %53 %78
OpStore %82 %81
%83 = OpAccessChain %20 %18 %19 %73
%84 = OpLoad %6 %83
%85 = OpAccessChain %20 %18 %19 %29
%86 = OpLoad %6 %85
%87 = OpAccessChain %7 %53 %84
OpStore %87 %86
%88 = OpAccessChain %20 %18 %19 %79
%89 = OpLoad %6 %88
%91 = OpAccessChain %20 %18 %19 %90
%92 = OpLoad %6 %91
%93 = OpAccessChain %7 %53 %89
OpStore %93 %92
%95 = OpAccessChain %20 %18 %19 %94
%96 = OpLoad %6 %95
%97 = OpAccessChain %20 %18 %19 %94
%98 = OpLoad %6 %97
%99 = OpAccessChain %7 %53 %96
OpStore %99 %98
%101 = OpAccessChain %20 %18 %19 %100
%102 = OpLoad %6 %101
%103 = OpAccessChain %20 %18 %19 %100
%104 = OpLoad %6 %103
%105 = OpAccessChain %7 %53 %102
OpStore %105 %104
%107 = OpAccessChain %20 %18 %19 %106
%108 = OpLoad %6 %107
%109 = OpAccessChain %20 %18 %19 %106
%110 = OpLoad %6 %109
%111 = OpAccessChain %7 %53 %108
OpStore %111 %110
%113 = OpAccessChain %20 %18 %19 %19
%114 = OpLoad %6 %113
OpStore %112 %114
OpBranch %115
%115 = OpLabel
OpLoopMerge %117 %118 None
OpBranch %119
%119 = OpLabel
%120 = OpLoad %6 %112
%121 = OpAccessChain %20 %18 %19 %29
%122 = OpLoad %6 %121
%123 = OpSLessThan %32 %120 %122
OpBranchConditional %123 %116 %117
%116 = OpLabel
%125 = OpLoad %6 %112
%126 = OpLoad %6 %112
%127 = OpAccessChain %7 %124 %125
OpStore %127 %126
%128 = OpLoad %6 %112
%129 = OpAccessChain %20 %18 %19 %29
%130 = OpLoad %6 %129
%131 = OpAccessChain %20 %18 %19 %44
%132 = OpLoad %6 %131
%133 = OpSDiv %6 %130 %132
%134 = OpSLessThan %32 %128 %133
OpSelectionMerge %136 None
OpBranchConditional %134 %135 %170
%135 = OpLabel
%137 = OpLoad %6 %112
%138 = OpLoad %6 %112
%139 = OpAccessChain %20 %18 %19 %44
%140 = OpLoad %6 %139
%141 = OpIAdd %6 %138 %140
%142 = OpAccessChain %7 %124 %137
OpStore %142 %141
%143 = OpLoad %6 %112
%144 = OpAccessChain %20 %18 %19 %29
%145 = OpLoad %6 %144
%146 = OpSLessThan %32 %143 %145
OpSelectionMerge %148 None
OpBranchConditional %146 %147 %148
%147 = OpLabel
OpBranch %118
%148 = OpLabel
%150 = OpLoad %6 %112
%151 = OpLoad %6 %112
%152 = OpAccessChain %20 %18 %19 %94
%153 = OpLoad %6 %152
%154 = OpIAdd %6 %151 %153
%155 = OpAccessChain %7 %124 %150
OpStore %155 %154
%156 = OpLoad %6 %112
%158 = OpAccessChain %7 %124 %156
%159 = OpLoad %6 %158
OpStore %157 %159
%160 = OpFunctionCall %6 %10 %157
%161 = OpAccessChain %20 %18 %19 %94
%162 = OpLoad %6 %161
%163 = OpSLessThan %32 %160 %162
OpSelectionMerge %165 None
OpBranchConditional %163 %164 %165
%164 = OpLabel
%166 = OpLoad %6 %112
%167 = OpAccessChain %7 %124 %166
%168 = OpLoad %6 %167
%169 = OpISub %6 %168 %44
OpStore %167 %169
OpBranch %165
%165 = OpLabel
OpBranch %136
%170 = OpLabel
%171 = OpLoad %6 %112
%173 = OpAccessChain %7 %124 %171
%174 = OpLoad %6 %173
OpStore %172 %174
%175 = OpFunctionCall %6 %10 %172
%176 = OpAccessChain %20 %18 %19 %94
%177 = OpLoad %6 %176
%178 = OpSLessThan %32 %175 %177
OpSelectionMerge %180 None
OpBranchConditional %178 %179 %180
%179 = OpLabel
%181 = OpLoad %6 %112
%182 = OpAccessChain %20 %18 %19 %73
%183 = OpLoad %6 %182
%184 = OpAccessChain %7 %124 %181
%185 = OpLoad %6 %184
%186 = OpIAdd %6 %185 %183
%187 = OpAccessChain %7 %124 %181
OpStore %187 %186
OpBranch %180
%180 = OpLabel
OpBranch %136
%136 = OpLabel
OpBranch %118
%118 = OpLabel
%188 = OpLoad %6 %112
%189 = OpIAdd %6 %188 %44
OpStore %112 %189
OpBranch %115
%117 = OpLabel
%191 = OpAccessChain %20 %18 %19 %19
%192 = OpLoad %6 %191
OpStore %190 %192
OpBranch %193
%193 = OpLabel
OpLoopMerge %195 %196 None
OpBranch %197
%197 = OpLabel
%198 = OpLoad %6 %190
%199 = OpAccessChain %20 %18 %19 %29
%200 = OpLoad %6 %199
%201 = OpSLessThan %32 %198 %200
OpBranchConditional %201 %194 %195
%194 = OpLabel
%202 = OpLoad %6 %190
%203 = OpAccessChain %7 %124 %202
%204 = OpLoad %6 %203
%205 = OpLoad %6 %190
%206 = OpAccessChain %7 %53 %205
%207 = OpLoad %6 %206
%208 = OpINotEqual %32 %204 %207
OpSelectionMerge %210 None
OpBranchConditional %208 %209 %210
%209 = OpLabel
%215 = OpAccessChain %20 %18 %19 %19
%216 = OpLoad %6 %215
%217 = OpConvertSToF %211 %216
%218 = OpCompositeConstruct %212 %217 %217 %217 %217
OpStore %214 %218
OpReturn
%210 = OpLabel
OpBranch %196
%196 = OpLabel
%220 = OpLoad %6 %190
%221 = OpIAdd %6 %220 %44
OpStore %190 %221
OpBranch %193
%195 = OpLabel
%222 = OpAccessChain %20 %18 %19 %59
%223 = OpLoad %6 %222
%224 = OpConvertSToF %211 %223
%225 = OpAccessChain %20 %18 %19 %19
%226 = OpLoad %6 %225
%227 = OpConvertSToF %211 %226
%228 = OpAccessChain %20 %18 %19 %19
%229 = OpLoad %6 %228
%230 = OpConvertSToF %211 %229
%231 = OpAccessChain %20 %18 %19 %59
%232 = OpLoad %6 %231
%233 = OpConvertSToF %211 %232
%234 = OpCompositeConstruct %212 %224 %227 %230 %233
OpStore %214 %234
OpReturn
OpFunctionEnd
%10 = OpFunction %6 None %8
%9 = OpFunctionParameter %7
%11 = OpLabel
%12 = OpVariable %7 Function
%21 = OpAccessChain %20 %18 %19 %19
%22 = OpLoad %6 %21
OpStore %12 %22
OpBranch %23
%23 = OpLabel
OpLoopMerge %25 %26 None
OpBranch %27
%27 = OpLabel
%28 = OpLoad %6 %12
%30 = OpAccessChain %20 %18 %19 %29
%31 = OpLoad %6 %30
%33 = OpSLessThan %32 %28 %31
OpBranchConditional %33 %24 %25
%24 = OpLabel
%34 = OpLoad %6 %12
%36 = OpAccessChain %20 %18 %19 %35
%37 = OpLoad %6 %36
%38 = OpSGreaterThan %32 %34 %37
OpSelectionMerge %40 None
OpBranchConditional %38 %39 %40
%39 = OpLabel
%41 = OpLoad %6 %9
OpReturnValue %41
%40 = OpLabel
OpBranch %26
%26 = OpLabel
%43 = OpLoad %6 %12
%45 = OpIAdd %6 %43 %44
OpStore %12 %45
OpBranch %23
%25 = OpLabel
%46 = OpAccessChain %20 %18 %19 %19
%47 = OpLoad %6 %46
OpReturnValue %47
OpFunctionEnd
END
# uniforms for variant
# _GLF_uniform_int_values
BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
0 2 3 4 5 6 10 11 7 8 9 1
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 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