blob: 6122994612c13893e3119afa0e512e2420912e36 [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_1 _GLF_uniform_int_values[0]
# #define _int_0 _GLF_uniform_int_values[1]
# #define _int_2 _GLF_uniform_int_values[2]
# #define _float_1_0 _GLF_uniform_float_values[0]
# #define _float_0_0 _GLF_uniform_float_values[1]
#
# precision highp float;
# precision highp int;
#
# // Contents of _GLF_uniform_int_values: [1, 0, 2]
# layout(set = 0, binding = 0) uniform buf0
# {
# int _GLF_uniform_int_values[3];
# };
# // Contents of _GLF_uniform_float_values: [1.0, 0.0]
# layout(set = 0, binding = 1) uniform buf1
# {
# float _GLF_uniform_float_values[2];
# };
#
# // Contents of zero: 0
# layout(push_constant) uniform buf_push
# {
# int zero;
# };
#
# struct S
# {
# float arr[10];
# };
#
# const int _GLF_global_loop_bound = 10;
# int _GLF_global_loop_count = 0;
#
# layout(location = 0) out vec4 _GLF_color;
#
# int func()
# {
# int m = _int_0;
#
# for( m = _int_1; _GLF_global_loop_count < _GLF_global_loop_bound; m = _int_2)
# {
# _GLF_global_loop_count++;
#
# switch(zero)
# {
# case 0:
# S s0 = S(float[10](_float_1_0, _float_1_0, _float_1_0, _float_1_0, _float_1_0, _float_1_0, _float_1_0, _float_1_0, _float_1_0, _float_1_0));
#
# // Always true.
# if(s0.arr[m] > _float_0_0)
# {
# m = _int_1;
# }
#
# int a = _int_0;
# // Fallthrough
# case 1:
# // a would be undefined if zero == 1, but case 0 gets always executed.
# while (a > _int_0 && _GLF_global_loop_count < _GLF_global_loop_bound)
# {
# // Never executed.
# _GLF_global_loop_count ++;
# }
#
# S s1 = S(float[10](_float_1_0, _float_1_0, _float_1_0, _float_1_0, _float_1_0, _float_1_0, _float_1_0, _float_1_0, _float_1_0, _float_1_0));
#
# // Always true.
# if(s1.arr[m] > _float_0_0)
# {
# a = _int_1;
# }
# }
# }
#
# // The loop sets m = 2 after each iteration so this function
# // always returns 2 regardless of how many times the loop was run.
# return m;
# }
#
# void main()
# {
# // Always true.
# if(func() == _int_2)
# {
# _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: 176
; Schema: 0
OpCapability Shader
%1 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint Fragment %4 "main" %157
OpExecutionMode %4 OriginUpperLeft
OpSource ESSL 320
OpName %4 "main"
OpName %8 "func("
OpName %11 "_GLF_global_loop_count"
OpName %14 "m"
OpName %18 "buf0"
OpMemberName %18 0 "_GLF_uniform_int_values"
OpName %20 ""
OpName %38 "buf_push"
OpMemberName %38 0 "zero"
OpName %40 ""
OpName %50 "S"
OpMemberName %50 0 "arr"
OpName %52 "s0"
OpName %55 "buf1"
OpMemberName %55 0 "_GLF_uniform_float_values"
OpName %57 ""
OpName %92 "a"
OpName %109 "s1"
OpName %157 "_GLF_color"
OpDecorate %17 ArrayStride 16
OpMemberDecorate %18 0 Offset 0
OpDecorate %18 Block
OpDecorate %20 DescriptorSet 0
OpDecorate %20 Binding 0
OpMemberDecorate %38 0 Offset 0
OpDecorate %38 Block
OpDecorate %54 ArrayStride 16
OpMemberDecorate %55 0 Offset 0
OpDecorate %55 Block
OpDecorate %57 DescriptorSet 0
OpDecorate %57 Binding 1
OpDecorate %157 Location 0
%2 = OpTypeVoid
%3 = OpTypeFunction %2
%6 = OpTypeInt 32 1
%7 = OpTypeFunction %6
%10 = OpTypePointer Private %6
%11 = OpVariable %10 Private
%12 = OpConstant %6 0
%13 = OpTypePointer Function %6
%15 = OpTypeInt 32 0
%16 = OpConstant %15 3
%17 = OpTypeArray %6 %16
%18 = OpTypeStruct %17
%19 = OpTypePointer Uniform %18
%20 = OpVariable %19 Uniform
%21 = OpConstant %6 1
%22 = OpTypePointer Uniform %6
%33 = OpConstant %6 10
%34 = OpTypeBool
%38 = OpTypeStruct %6
%39 = OpTypePointer PushConstant %38
%40 = OpVariable %39 PushConstant
%41 = OpTypePointer PushConstant %6
%47 = OpTypeFloat 32
%48 = OpConstant %15 10
%49 = OpTypeArray %47 %48
%50 = OpTypeStruct %49
%51 = OpTypePointer Function %50
%53 = OpConstant %15 2
%54 = OpTypeArray %47 %53
%55 = OpTypeStruct %54
%56 = OpTypePointer Uniform %55
%57 = OpVariable %56 Uniform
%58 = OpTypePointer Uniform %47
%82 = OpTypePointer Function %47
%143 = OpConstant %6 2
%155 = OpTypeVector %47 4
%156 = OpTypePointer Output %155
%157 = OpVariable %156 Output
%4 = OpFunction %2 None %3
%5 = OpLabel
OpStore %11 %12
%149 = OpFunctionCall %6 %8
%150 = OpAccessChain %22 %20 %12 %143
%151 = OpLoad %6 %150
%152 = OpIEqual %34 %149 %151
OpSelectionMerge %154 None
OpBranchConditional %152 %153 %171
%153 = OpLabel
%158 = OpAccessChain %22 %20 %12 %12
%159 = OpLoad %6 %158
%160 = OpConvertSToF %47 %159
%161 = OpAccessChain %22 %20 %12 %21
%162 = OpLoad %6 %161
%163 = OpConvertSToF %47 %162
%164 = OpAccessChain %22 %20 %12 %21
%165 = OpLoad %6 %164
%166 = OpConvertSToF %47 %165
%167 = OpAccessChain %22 %20 %12 %12
%168 = OpLoad %6 %167
%169 = OpConvertSToF %47 %168
%170 = OpCompositeConstruct %155 %160 %163 %166 %169
OpStore %157 %170
OpBranch %154
%171 = OpLabel
%172 = OpAccessChain %22 %20 %12 %21
%173 = OpLoad %6 %172
%174 = OpConvertSToF %47 %173
%175 = OpCompositeConstruct %155 %174 %174 %174 %174
OpStore %157 %175
OpBranch %154
%154 = OpLabel
OpReturn
OpFunctionEnd
%8 = OpFunction %6 None %7
%9 = OpLabel
%14 = OpVariable %13 Function
%52 = OpVariable %51 Function
%92 = OpVariable %13 Function
%109 = OpVariable %51 Function
%23 = OpAccessChain %22 %20 %12 %21
%24 = OpLoad %6 %23
OpStore %14 %24
%25 = OpAccessChain %22 %20 %12 %12
%26 = OpLoad %6 %25
OpStore %14 %26
OpBranch %27
%27 = OpLabel
OpLoopMerge %29 %30 None
OpBranch %31
%31 = OpLabel
%32 = OpLoad %6 %11
%35 = OpSLessThan %34 %32 %33
OpBranchConditional %35 %28 %29
%28 = OpLabel
%36 = OpLoad %6 %11
%37 = OpIAdd %6 %36 %21
OpStore %11 %37
%42 = OpAccessChain %41 %40 %12
%43 = OpLoad %6 %42
OpSelectionMerge %46 None
OpSwitch %43 %46 0 %44 1 %45
%44 = OpLabel
%59 = OpAccessChain %58 %57 %12 %12
%60 = OpLoad %47 %59
%61 = OpAccessChain %58 %57 %12 %12
%62 = OpLoad %47 %61
%63 = OpAccessChain %58 %57 %12 %12
%64 = OpLoad %47 %63
%65 = OpAccessChain %58 %57 %12 %12
%66 = OpLoad %47 %65
%67 = OpAccessChain %58 %57 %12 %12
%68 = OpLoad %47 %67
%69 = OpAccessChain %58 %57 %12 %12
%70 = OpLoad %47 %69
%71 = OpAccessChain %58 %57 %12 %12
%72 = OpLoad %47 %71
%73 = OpAccessChain %58 %57 %12 %12
%74 = OpLoad %47 %73
%75 = OpAccessChain %58 %57 %12 %12
%76 = OpLoad %47 %75
%77 = OpAccessChain %58 %57 %12 %12
%78 = OpLoad %47 %77
%79 = OpCompositeConstruct %49 %60 %62 %64 %66 %68 %70 %72 %74 %76 %78
%80 = OpCompositeConstruct %50 %79
OpStore %52 %80
%81 = OpLoad %6 %14
%83 = OpAccessChain %82 %52 %12 %81
%84 = OpLoad %47 %83
%85 = OpAccessChain %58 %57 %12 %21
%86 = OpLoad %47 %85
%87 = OpFOrdGreaterThan %34 %84 %86
OpSelectionMerge %89 None
OpBranchConditional %87 %88 %89
%88 = OpLabel
%90 = OpAccessChain %22 %20 %12 %12
%91 = OpLoad %6 %90
OpStore %14 %91
OpBranch %89
%89 = OpLabel
%93 = OpAccessChain %22 %20 %12 %21
%94 = OpLoad %6 %93
OpStore %92 %94
OpBranch %45
%45 = OpLabel
OpBranch %95
%95 = OpLabel
OpLoopMerge %97 %98 None
OpBranch %99
%99 = OpLabel
%100 = OpLoad %6 %92
%101 = OpAccessChain %22 %20 %12 %21
%102 = OpLoad %6 %101
%103 = OpSGreaterThan %34 %100 %102
%104 = OpLoad %6 %11
%105 = OpSLessThan %34 %104 %33
%106 = OpLogicalAnd %34 %103 %105
OpBranchConditional %106 %96 %97
%96 = OpLabel
%107 = OpLoad %6 %11
%108 = OpIAdd %6 %107 %21
OpStore %11 %108
OpBranch %98
%98 = OpLabel
OpBranch %95
%97 = OpLabel
%110 = OpAccessChain %58 %57 %12 %12
%111 = OpLoad %47 %110
%112 = OpAccessChain %58 %57 %12 %12
%113 = OpLoad %47 %112
%114 = OpAccessChain %58 %57 %12 %12
%115 = OpLoad %47 %114
%116 = OpAccessChain %58 %57 %12 %12
%117 = OpLoad %47 %116
%118 = OpAccessChain %58 %57 %12 %12
%119 = OpLoad %47 %118
%120 = OpAccessChain %58 %57 %12 %12
%121 = OpLoad %47 %120
%122 = OpAccessChain %58 %57 %12 %12
%123 = OpLoad %47 %122
%124 = OpAccessChain %58 %57 %12 %12
%125 = OpLoad %47 %124
%126 = OpAccessChain %58 %57 %12 %12
%127 = OpLoad %47 %126
%128 = OpAccessChain %58 %57 %12 %12
%129 = OpLoad %47 %128
%130 = OpCompositeConstruct %49 %111 %113 %115 %117 %119 %121 %123 %125 %127 %129
%131 = OpCompositeConstruct %50 %130
OpStore %109 %131
%132 = OpLoad %6 %14
%133 = OpAccessChain %82 %109 %12 %132
%134 = OpLoad %47 %133
%135 = OpAccessChain %58 %57 %12 %21
%136 = OpLoad %47 %135
%137 = OpFOrdGreaterThan %34 %134 %136
OpSelectionMerge %139 None
OpBranchConditional %137 %138 %139
%138 = OpLabel
%140 = OpAccessChain %22 %20 %12 %12
%141 = OpLoad %6 %140
OpStore %92 %141
OpBranch %139
%139 = OpLabel
OpBranch %46
%46 = OpLabel
OpBranch %30
%30 = OpLabel
%144 = OpAccessChain %22 %20 %12 %143
%145 = OpLoad %6 %144
OpStore %14 %145
OpBranch %27
%29 = OpLabel
%146 = OpLoad %6 %14
OpReturnValue %146
OpFunctionEnd
END
# uniforms for variant
# zero
BUFFER variant_zero DATA_TYPE int32 STD140 DATA
0
END
# _GLF_uniform_float_values
BUFFER variant__GLF_uniform_float_values DATA_TYPE float[] STD140 DATA
1.0 0.0
END
# _GLF_uniform_int_values
BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
1 0 2
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_zero AS push_constant
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 256 256
EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255