blob: c39a890b42ead960f65c574cff0c800a9454fd7a [file] [log] [blame]
#!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
#
# #define _int_1 _GLF_uniform_int_values[0]
# #define _int_0 _GLF_uniform_int_values[1]
# #define _int_10 _GLF_uniform_int_values[2]
# #define _int_5 _GLF_uniform_int_values[3]
#
# precision highp float;
# precision highp int;
#
# // Contents of _GLF_uniform_int_values: [1, 0, 10, 5]
# layout(set = 0, binding = 0) uniform buf0
# {
# int _GLF_uniform_int_values[4];
# };
#
# // Contents of injectionSwitch: [0.0, 1.0]
# layout(push_constant) uniform buf_push {
# highp vec2 injectionSwitch;
# };
#
# layout(location = 0) out vec4 _GLF_color;
#
# struct S
# {
# int data;
# };
#
# S arr[10] = S[10](S(1), S(1), S(1), S(1), S(1), S(1), S(1), S(1), S(1), S(1));
#
# void func(inout S s)
# {
# // Always false.
# if(injectionSwitch.x > injectionSwitch.y)
# {
# return;
# }
#
# // Always false.
# if(gl_FragCoord.y < 0.0)
# {
# return;
# }
#
# s.data = 0;
# }
#
# void main()
# {
# func(arr[_int_1]);
# bool b = false;
#
# // Always false.
# if(injectionSwitch.x > injectionSwitch.y)
# {
# b = true;
# }
#
# // Always true.
# if(!b)
# {
# int idx = 0;
#
# for(int i = 0; i < _int_5; i++)
# {
# arr[idx].data = _int_1;
# func(arr[i]);
# }
# }
#
# // The first five elements had data set to zero, but also the first element was set back to one in iterations i = 1..4.
# int ref[10] = int[10](_int_1, _int_0, _int_0, _int_0, _int_0, _int_1, _int_1, _int_1, _int_1, _int_1);
#
# // Check the results and set an output color to black if the check fails.
# _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1);
# for(int i = _int_0; i < _int_10; i++)
# {
# if(arr[i].data != ref[i])
# {
# _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: 175
; Schema: 0
OpCapability Shader
%1 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint Fragment %4 "main" %41 %133
OpExecutionMode %4 OriginUpperLeft
OpSource ESSL 320
OpName %4 "main"
OpName %7 "S"
OpMemberName %7 0 "data"
OpName %11 "func(struct-S-i11;"
OpName %10 "s"
OpName %17 "arr"
OpName %23 "buf_push"
OpMemberName %23 0 "injectionSwitch"
OpName %25 ""
OpName %41 "gl_FragCoord"
OpName %54 "buf0"
OpMemberName %54 0 "_GLF_uniform_int_values"
OpName %56 ""
OpName %60 "param"
OpName %68 "b"
OpName %82 "idx"
OpName %83 "i"
OpName %100 "param"
OpName %110 "ref"
OpName %133 "_GLF_color"
OpName %147 "i"
OpMemberDecorate %23 0 Offset 0
OpDecorate %23 Block
OpDecorate %41 BuiltIn FragCoord
OpDecorate %53 ArrayStride 16
OpMemberDecorate %54 0 Offset 0
OpDecorate %54 Block
OpDecorate %56 DescriptorSet 0
OpDecorate %56 Binding 0
OpDecorate %133 Location 0
%2 = OpTypeVoid
%3 = OpTypeFunction %2
%6 = OpTypeInt 32 1
%7 = OpTypeStruct %6
%8 = OpTypePointer Function %7
%9 = OpTypeFunction %2 %8
%13 = OpTypeInt 32 0
%14 = OpConstant %13 10
%15 = OpTypeArray %7 %14
%16 = OpTypePointer Private %15
%17 = OpVariable %16 Private
%18 = OpConstant %6 1
%19 = OpConstantComposite %7 %18
%20 = OpConstantComposite %15 %19 %19 %19 %19 %19 %19 %19 %19 %19 %19
%21 = OpTypeFloat 32
%22 = OpTypeVector %21 2
%23 = OpTypeStruct %22
%24 = OpTypePointer PushConstant %23
%25 = OpVariable %24 PushConstant
%26 = OpConstant %6 0
%27 = OpConstant %13 0
%28 = OpTypePointer PushConstant %21
%31 = OpConstant %13 1
%34 = OpTypeBool
%39 = OpTypeVector %21 4
%40 = OpTypePointer Input %39
%41 = OpVariable %40 Input
%42 = OpTypePointer Input %21
%45 = OpConstant %21 0
%50 = OpTypePointer Function %6
%52 = OpConstant %13 4
%53 = OpTypeArray %6 %52
%54 = OpTypeStruct %53
%55 = OpTypePointer Uniform %54
%56 = OpVariable %55 Uniform
%57 = OpTypePointer Uniform %6
%61 = OpTypePointer Private %7
%67 = OpTypePointer Function %34
%69 = OpConstantFalse %34
%77 = OpConstantTrue %34
%90 = OpConstant %6 3
%97 = OpTypePointer Private %6
%108 = OpTypeArray %6 %14
%109 = OpTypePointer Function %108
%132 = OpTypePointer Output %39
%133 = OpVariable %132 Output
%156 = OpConstant %6 2
%4 = OpFunction %2 None %3
%5 = OpLabel
%60 = OpVariable %8 Function
%68 = OpVariable %67 Function
%82 = OpVariable %50 Function
%83 = OpVariable %50 Function
%100 = OpVariable %8 Function
%110 = OpVariable %109 Function
%147 = OpVariable %50 Function
OpStore %17 %20
%58 = OpAccessChain %57 %56 %26 %26
%59 = OpLoad %6 %58
%62 = OpAccessChain %61 %17 %59
%63 = OpLoad %7 %62
OpStore %60 %63
%64 = OpFunctionCall %2 %11 %60
%65 = OpLoad %7 %60
%66 = OpAccessChain %61 %17 %59
OpStore %66 %65
OpStore %68 %69
%70 = OpAccessChain %28 %25 %26 %27
%71 = OpLoad %21 %70
%72 = OpAccessChain %28 %25 %26 %31
%73 = OpLoad %21 %72
%74 = OpFOrdGreaterThan %34 %71 %73
OpSelectionMerge %76 None
OpBranchConditional %74 %75 %76
%75 = OpLabel
OpStore %68 %77
OpBranch %76
%76 = OpLabel
%78 = OpLoad %34 %68
%79 = OpLogicalNot %34 %78
OpSelectionMerge %81 None
OpBranchConditional %79 %80 %81
%80 = OpLabel
OpStore %82 %26
OpStore %83 %26
OpBranch %84
%84 = OpLabel
OpLoopMerge %86 %87 None
OpBranch %88
%88 = OpLabel
%89 = OpLoad %6 %83
%91 = OpAccessChain %57 %56 %26 %90
%92 = OpLoad %6 %91
%93 = OpSLessThan %34 %89 %92
OpBranchConditional %93 %85 %86
%85 = OpLabel
%94 = OpLoad %6 %82
%95 = OpAccessChain %57 %56 %26 %26
%96 = OpLoad %6 %95
%98 = OpAccessChain %97 %17 %94 %26
OpStore %98 %96
%99 = OpLoad %6 %83
%101 = OpAccessChain %61 %17 %99
%102 = OpLoad %7 %101
OpStore %100 %102
%103 = OpFunctionCall %2 %11 %100
%104 = OpLoad %7 %100
%105 = OpAccessChain %61 %17 %99
OpStore %105 %104
OpBranch %87
%87 = OpLabel
%106 = OpLoad %6 %83
%107 = OpIAdd %6 %106 %18
OpStore %83 %107
OpBranch %84
%86 = OpLabel
OpBranch %81
%81 = OpLabel
%111 = OpAccessChain %57 %56 %26 %26
%112 = OpLoad %6 %111
%113 = OpAccessChain %57 %56 %26 %18
%114 = OpLoad %6 %113
%115 = OpAccessChain %57 %56 %26 %18
%116 = OpLoad %6 %115
%117 = OpAccessChain %57 %56 %26 %18
%118 = OpLoad %6 %117
%119 = OpAccessChain %57 %56 %26 %18
%120 = OpLoad %6 %119
%121 = OpAccessChain %57 %56 %26 %26
%122 = OpLoad %6 %121
%123 = OpAccessChain %57 %56 %26 %26
%124 = OpLoad %6 %123
%125 = OpAccessChain %57 %56 %26 %26
%126 = OpLoad %6 %125
%127 = OpAccessChain %57 %56 %26 %26
%128 = OpLoad %6 %127
%129 = OpAccessChain %57 %56 %26 %26
%130 = OpLoad %6 %129
%131 = OpCompositeConstruct %108 %112 %114 %116 %118 %120 %122 %124 %126 %128 %130
OpStore %110 %131
%134 = OpAccessChain %57 %56 %26 %26
%135 = OpLoad %6 %134
%136 = OpConvertSToF %21 %135
%137 = OpAccessChain %57 %56 %26 %18
%138 = OpLoad %6 %137
%139 = OpConvertSToF %21 %138
%140 = OpAccessChain %57 %56 %26 %18
%141 = OpLoad %6 %140
%142 = OpConvertSToF %21 %141
%143 = OpAccessChain %57 %56 %26 %26
%144 = OpLoad %6 %143
%145 = OpConvertSToF %21 %144
%146 = OpCompositeConstruct %39 %136 %139 %142 %145
OpStore %133 %146
%148 = OpAccessChain %57 %56 %26 %18
%149 = OpLoad %6 %148
OpStore %147 %149
OpBranch %150
%150 = OpLabel
OpLoopMerge %152 %153 None
OpBranch %154
%154 = OpLabel
%155 = OpLoad %6 %147
%157 = OpAccessChain %57 %56 %26 %156
%158 = OpLoad %6 %157
%159 = OpSLessThan %34 %155 %158
OpBranchConditional %159 %151 %152
%151 = OpLabel
%160 = OpLoad %6 %147
%161 = OpAccessChain %97 %17 %160 %26
%162 = OpLoad %6 %161
%163 = OpLoad %6 %147
%164 = OpAccessChain %50 %110 %163
%165 = OpLoad %6 %164
%166 = OpINotEqual %34 %162 %165
OpSelectionMerge %168 None
OpBranchConditional %166 %167 %168
%167 = OpLabel
%169 = OpAccessChain %57 %56 %26 %18
%170 = OpLoad %6 %169
%171 = OpConvertSToF %21 %170
%172 = OpCompositeConstruct %39 %171 %171 %171 %171
OpStore %133 %172
OpBranch %168
%168 = OpLabel
OpBranch %153
%153 = OpLabel
%173 = OpLoad %6 %147
%174 = OpIAdd %6 %173 %18
OpStore %147 %174
OpBranch %150
%152 = OpLabel
OpReturn
OpFunctionEnd
%11 = OpFunction %2 None %9
%10 = OpFunctionParameter %8
%12 = OpLabel
%29 = OpAccessChain %28 %25 %26 %27
%30 = OpLoad %21 %29
%32 = OpAccessChain %28 %25 %26 %31
%33 = OpLoad %21 %32
%35 = OpFOrdGreaterThan %34 %30 %33
OpSelectionMerge %37 None
OpBranchConditional %35 %36 %37
%36 = OpLabel
OpReturn
%37 = OpLabel
%43 = OpAccessChain %42 %41 %31
%44 = OpLoad %21 %43
%46 = OpFOrdLessThan %34 %44 %45
OpSelectionMerge %48 None
OpBranchConditional %46 %47 %48
%47 = OpLabel
OpReturn
%48 = OpLabel
%51 = OpAccessChain %50 %10 %26
OpStore %51 %26
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 10 5
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_injectionSwitch AS push_constant
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 32 32
EXPECT variant_framebuffer IDX 0 0 SIZE 32 32 EQ_RGBA 255 0 0 255