blob: 774133618f59e2c53cf91f1dce426393b97e5466 [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 NIR 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_100 _GLF_uniform_int_values[0]
# #define _int_0 _GLF_uniform_int_values[1]
# #define _int_1 _GLF_uniform_int_values[2]
# #define _int_4 _GLF_uniform_int_values[3]
# #define _float_1_0 _GLF_uniform_float_values[0]
#
# precision highp int;
# precision highp float;
#
# // Contents of _GLF_uniform_float_values: 1.0
# layout(set = 0, binding = 0) uniform buf0
# {
# float _GLF_uniform_float_values[1];
# };
#
# // Contents of _GLF_uniform_int_values: [100, 0, 1, 4]
# layout(set = 0, binding = 1) uniform buf1
# {
# int _GLF_uniform_int_values[4];
# };
#
# layout(location = 0) out vec4 _GLF_color;
#
# void main()
# {
# mat4 m0 = mat4(_int_0);
#
# for(int c = _int_1; c < _int_100; c++)
# {
# // m1 has no dependency outside this block.
# mat4 m1 = m0;
#
# m1[c % _int_4][_int_1] = _float_1_0;
# m0[c % _int_4][_int_1] = _float_1_0;
# }
#
# // Always true.
# if(m0 == mat4(_int_0, _int_1, _int_0, _int_0, _int_0, _int_1, _int_0, _int_0, _int_0, _int_1, _int_0, _int_0, _int_0, _int_1, _int_0, _int_0))
# {
# _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: 172
; Schema: 0
OpCapability Shader
%1 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint Fragment %4 "main" %153
OpExecutionMode %4 OriginUpperLeft
OpSource ESSL 320
OpName %4 "main"
OpName %10 "m0"
OpName %15 "buf1"
OpMemberName %15 0 "_GLF_uniform_int_values"
OpName %17 ""
OpName %32 "c"
OpName %46 "m1"
OpName %57 "buf0"
OpMemberName %57 0 "_GLF_uniform_float_values"
OpName %59 ""
OpName %153 "_GLF_color"
OpDecorate %14 ArrayStride 16
OpMemberDecorate %15 0 Offset 0
OpDecorate %15 Block
OpDecorate %17 DescriptorSet 0
OpDecorate %17 Binding 1
OpDecorate %56 ArrayStride 16
OpMemberDecorate %57 0 Offset 0
OpDecorate %57 Block
OpDecorate %59 DescriptorSet 0
OpDecorate %59 Binding 0
OpDecorate %153 Location 0
%2 = OpTypeVoid
%3 = OpTypeFunction %2
%6 = OpTypeFloat 32
%7 = OpTypeVector %6 4
%8 = OpTypeMatrix %7 4
%9 = OpTypePointer Function %8
%11 = OpTypeInt 32 1
%12 = OpTypeInt 32 0
%13 = OpConstant %12 4
%14 = OpTypeArray %11 %13
%15 = OpTypeStruct %14
%16 = OpTypePointer Uniform %15
%17 = OpVariable %16 Uniform
%18 = OpConstant %11 0
%19 = OpConstant %11 1
%20 = OpTypePointer Uniform %11
%24 = OpConstant %6 1
%25 = OpConstant %6 0
%31 = OpTypePointer Function %11
%33 = OpConstant %11 2
%44 = OpTypeBool
%49 = OpConstant %11 3
%55 = OpConstant %12 1
%56 = OpTypeArray %6 %55
%57 = OpTypeStruct %56
%58 = OpTypePointer Uniform %57
%59 = OpVariable %58 Uniform
%60 = OpTypePointer Uniform %6
%63 = OpTypePointer Function %6
%132 = OpTypeVector %44 4
%152 = OpTypePointer Output %7
%153 = OpVariable %152 Output
%4 = OpFunction %2 None %3
%5 = OpLabel
%10 = OpVariable %9 Function
%32 = OpVariable %31 Function
%46 = OpVariable %9 Function
%21 = OpAccessChain %20 %17 %18 %19
%22 = OpLoad %11 %21
%23 = OpConvertSToF %6 %22
%26 = OpCompositeConstruct %7 %23 %25 %25 %25
%27 = OpCompositeConstruct %7 %25 %23 %25 %25
%28 = OpCompositeConstruct %7 %25 %25 %23 %25
%29 = OpCompositeConstruct %7 %25 %25 %25 %23
%30 = OpCompositeConstruct %8 %26 %27 %28 %29
OpStore %10 %30
%34 = OpAccessChain %20 %17 %18 %33
%35 = OpLoad %11 %34
OpStore %32 %35
OpBranch %36
%36 = OpLabel
OpLoopMerge %38 %39 None
OpBranch %40
%40 = OpLabel
%41 = OpLoad %11 %32
%42 = OpAccessChain %20 %17 %18 %18
%43 = OpLoad %11 %42
%45 = OpSLessThan %44 %41 %43
OpBranchConditional %45 %37 %38
%37 = OpLabel
%47 = OpLoad %8 %10
OpStore %46 %47
%48 = OpLoad %11 %32
%50 = OpAccessChain %20 %17 %18 %49
%51 = OpLoad %11 %50
%52 = OpSMod %11 %48 %51
%53 = OpAccessChain %20 %17 %18 %33
%54 = OpLoad %11 %53
%61 = OpAccessChain %60 %59 %18 %18
%62 = OpLoad %6 %61
%64 = OpAccessChain %63 %46 %52 %54
OpStore %64 %62
%65 = OpLoad %11 %32
%66 = OpAccessChain %20 %17 %18 %49
%67 = OpLoad %11 %66
%68 = OpSMod %11 %65 %67
%69 = OpAccessChain %20 %17 %18 %33
%70 = OpLoad %11 %69
%71 = OpAccessChain %60 %59 %18 %18
%72 = OpLoad %6 %71
%73 = OpAccessChain %63 %10 %68 %70
OpStore %73 %72
OpBranch %39
%39 = OpLabel
%74 = OpLoad %11 %32
%75 = OpIAdd %11 %74 %19
OpStore %32 %75
OpBranch %36
%38 = OpLabel
%76 = OpLoad %8 %10
%77 = OpAccessChain %20 %17 %18 %19
%78 = OpLoad %11 %77
%79 = OpConvertSToF %6 %78
%80 = OpAccessChain %20 %17 %18 %33
%81 = OpLoad %11 %80
%82 = OpConvertSToF %6 %81
%83 = OpAccessChain %20 %17 %18 %19
%84 = OpLoad %11 %83
%85 = OpConvertSToF %6 %84
%86 = OpAccessChain %20 %17 %18 %19
%87 = OpLoad %11 %86
%88 = OpConvertSToF %6 %87
%89 = OpAccessChain %20 %17 %18 %19
%90 = OpLoad %11 %89
%91 = OpConvertSToF %6 %90
%92 = OpAccessChain %20 %17 %18 %33
%93 = OpLoad %11 %92
%94 = OpConvertSToF %6 %93
%95 = OpAccessChain %20 %17 %18 %19
%96 = OpLoad %11 %95
%97 = OpConvertSToF %6 %96
%98 = OpAccessChain %20 %17 %18 %19
%99 = OpLoad %11 %98
%100 = OpConvertSToF %6 %99
%101 = OpAccessChain %20 %17 %18 %19
%102 = OpLoad %11 %101
%103 = OpConvertSToF %6 %102
%104 = OpAccessChain %20 %17 %18 %33
%105 = OpLoad %11 %104
%106 = OpConvertSToF %6 %105
%107 = OpAccessChain %20 %17 %18 %19
%108 = OpLoad %11 %107
%109 = OpConvertSToF %6 %108
%110 = OpAccessChain %20 %17 %18 %19
%111 = OpLoad %11 %110
%112 = OpConvertSToF %6 %111
%113 = OpAccessChain %20 %17 %18 %19
%114 = OpLoad %11 %113
%115 = OpConvertSToF %6 %114
%116 = OpAccessChain %20 %17 %18 %33
%117 = OpLoad %11 %116
%118 = OpConvertSToF %6 %117
%119 = OpAccessChain %20 %17 %18 %19
%120 = OpLoad %11 %119
%121 = OpConvertSToF %6 %120
%122 = OpAccessChain %20 %17 %18 %19
%123 = OpLoad %11 %122
%124 = OpConvertSToF %6 %123
%125 = OpCompositeConstruct %7 %79 %82 %85 %88
%126 = OpCompositeConstruct %7 %91 %94 %97 %100
%127 = OpCompositeConstruct %7 %103 %106 %109 %112
%128 = OpCompositeConstruct %7 %115 %118 %121 %124
%129 = OpCompositeConstruct %8 %125 %126 %127 %128
%130 = OpCompositeExtract %7 %76 0
%131 = OpCompositeExtract %7 %129 0
%133 = OpFOrdEqual %132 %130 %131
%134 = OpAll %44 %133
%135 = OpCompositeExtract %7 %76 1
%136 = OpCompositeExtract %7 %129 1
%137 = OpFOrdEqual %132 %135 %136
%138 = OpAll %44 %137
%139 = OpLogicalAnd %44 %134 %138
%140 = OpCompositeExtract %7 %76 2
%141 = OpCompositeExtract %7 %129 2
%142 = OpFOrdEqual %132 %140 %141
%143 = OpAll %44 %142
%144 = OpLogicalAnd %44 %139 %143
%145 = OpCompositeExtract %7 %76 3
%146 = OpCompositeExtract %7 %129 3
%147 = OpFOrdEqual %132 %145 %146
%148 = OpAll %44 %147
%149 = OpLogicalAnd %44 %144 %148
OpSelectionMerge %151 None
OpBranchConditional %149 %150 %167
%150 = OpLabel
%154 = OpAccessChain %20 %17 %18 %33
%155 = OpLoad %11 %154
%156 = OpConvertSToF %6 %155
%157 = OpAccessChain %20 %17 %18 %19
%158 = OpLoad %11 %157
%159 = OpConvertSToF %6 %158
%160 = OpAccessChain %20 %17 %18 %19
%161 = OpLoad %11 %160
%162 = OpConvertSToF %6 %161
%163 = OpAccessChain %20 %17 %18 %33
%164 = OpLoad %11 %163
%165 = OpConvertSToF %6 %164
%166 = OpCompositeConstruct %7 %156 %159 %162 %165
OpStore %153 %166
OpBranch %151
%167 = OpLabel
%168 = OpAccessChain %20 %17 %18 %19
%169 = OpLoad %11 %168
%170 = OpConvertSToF %6 %169
%171 = OpCompositeConstruct %7 %170 %170 %170 %170
OpStore %153 %171
OpBranch %151
%151 = OpLabel
OpReturn
OpFunctionEnd
END
# uniforms for variant
# _GLF_uniform_int_values
BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
100 0 1 4
END
# _GLF_uniform_float_values
BUFFER variant__GLF_uniform_float_values DATA_TYPE float[] STD140 DATA
1.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