blob: 7944dd02075ee327d17c016e3a30b9ac2447c7bd [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 inst combine shifts code 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_1 _GLF_uniform_int_values[1]
# #define _int_3 _GLF_uniform_int_values[2]
# #define _int_2 _GLF_uniform_int_values[3]
# #define _float_255_0 _GLF_uniform_float_values[0]
# #define _float_60_0 _GLF_uniform_float_values[1]
# #define _float_0_01 _GLF_uniform_float_values[2]
# #define _float_0_0 _GLF_uniform_float_values[3]
#
# precision highp int;
#
# precision highp float;
#
# // Contents of _GLF_uniform_float_values: [255.0, 60.0, 0.01, 0.0]
# layout(set = 0, binding = 0) uniform buf0
# {
# float _GLF_uniform_float_values[4];
# };
#
# // Contents of _GLF_uniform_int_values: [0, 1, 3, 2]
# layout(set = 0, binding = 1) uniform buf1
# {
# int _GLF_uniform_int_values[4];
# };
#
# layout(location = 0) out vec4 _GLF_color;
#
# void main()
# {
# // a becomes 1006648320.
# uint a = packHalf2x16(vec2(1.0));
# vec4 values = unpackUnorm4x8(a);
#
# vec4 ref = vec4(_float_0_0, _float_60_0 / _float_255_0,
# _float_0_0 / _float_255_0, _float_60_0 / _float_255_0);
#
# if (abs(values[_int_0] - ref[_int_0]) < _float_0_01
# && abs(values[_int_1] - ref[_int_1]) < _float_0_01
# && abs(values[_int_2] - ref[_int_2]) < _float_0_01
# && abs(values[_int_3] - ref[_int_3]) < _float_0_01)
# {
# _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: 139
; Schema: 0
OpCapability Shader
%1 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint Fragment %4 "main" %120
OpExecutionMode %4 OriginUpperLeft
OpSource ESSL 310
OpName %4 "main"
OpName %8 "a"
OpName %16 "values"
OpName %19 "ref"
OpName %22 "buf0"
OpMemberName %22 0 "_GLF_uniform_float_values"
OpName %24 ""
OpName %50 "buf1"
OpMemberName %50 0 "_GLF_uniform_int_values"
OpName %52 ""
OpName %120 "_GLF_color"
OpDecorate %21 ArrayStride 16
OpMemberDecorate %22 0 Offset 0
OpDecorate %22 Block
OpDecorate %24 DescriptorSet 0
OpDecorate %24 Binding 0
OpDecorate %49 ArrayStride 16
OpMemberDecorate %50 0 Offset 0
OpDecorate %50 Block
OpDecorate %52 DescriptorSet 0
OpDecorate %52 Binding 1
OpDecorate %120 Location 0
%2 = OpTypeVoid
%3 = OpTypeFunction %2
%6 = OpTypeInt 32 0
%7 = OpTypePointer Function %6
%9 = OpTypeFloat 32
%10 = OpTypeVector %9 2
%11 = OpConstant %9 1
%12 = OpConstantComposite %10 %11 %11
%14 = OpTypeVector %9 4
%15 = OpTypePointer Function %14
%20 = OpConstant %6 4
%21 = OpTypeArray %9 %20
%22 = OpTypeStruct %21
%23 = OpTypePointer Uniform %22
%24 = OpVariable %23 Uniform
%25 = OpTypeInt 32 1
%26 = OpConstant %25 0
%27 = OpConstant %25 3
%28 = OpTypePointer Uniform %9
%31 = OpConstant %25 1
%48 = OpTypeBool
%49 = OpTypeArray %25 %20
%50 = OpTypeStruct %49
%51 = OpTypePointer Uniform %50
%52 = OpVariable %51 Uniform
%53 = OpTypePointer Uniform %25
%56 = OpTypePointer Function %9
%65 = OpConstant %25 2
%119 = OpTypePointer Output %14
%120 = OpVariable %119 Output
%4 = OpFunction %2 None %3
%5 = OpLabel
%8 = OpVariable %7 Function
%16 = OpVariable %15 Function
%19 = OpVariable %15 Function
%13 = OpExtInst %6 %1 PackHalf2x16 %12
OpStore %8 %13
%17 = OpLoad %6 %8
%18 = OpExtInst %14 %1 UnpackUnorm4x8 %17
OpStore %16 %18
%29 = OpAccessChain %28 %24 %26 %27
%30 = OpLoad %9 %29
%32 = OpAccessChain %28 %24 %26 %31
%33 = OpLoad %9 %32
%34 = OpAccessChain %28 %24 %26 %26
%35 = OpLoad %9 %34
%36 = OpFDiv %9 %33 %35
%37 = OpAccessChain %28 %24 %26 %27
%38 = OpLoad %9 %37
%39 = OpAccessChain %28 %24 %26 %26
%40 = OpLoad %9 %39
%41 = OpFDiv %9 %38 %40
%42 = OpAccessChain %28 %24 %26 %31
%43 = OpLoad %9 %42
%44 = OpAccessChain %28 %24 %26 %26
%45 = OpLoad %9 %44
%46 = OpFDiv %9 %43 %45
%47 = OpCompositeConstruct %14 %30 %36 %41 %46
OpStore %19 %47
%54 = OpAccessChain %53 %52 %26 %26
%55 = OpLoad %25 %54
%57 = OpAccessChain %56 %16 %55
%58 = OpLoad %9 %57
%59 = OpAccessChain %53 %52 %26 %26
%60 = OpLoad %25 %59
%61 = OpAccessChain %56 %19 %60
%62 = OpLoad %9 %61
%63 = OpFSub %9 %58 %62
%64 = OpExtInst %9 %1 FAbs %63
%66 = OpAccessChain %28 %24 %26 %65
%67 = OpLoad %9 %66
%68 = OpFOrdLessThan %48 %64 %67
OpSelectionMerge %70 None
OpBranchConditional %68 %69 %70
%69 = OpLabel
%71 = OpAccessChain %53 %52 %26 %31
%72 = OpLoad %25 %71
%73 = OpAccessChain %56 %16 %72
%74 = OpLoad %9 %73
%75 = OpAccessChain %53 %52 %26 %31
%76 = OpLoad %25 %75
%77 = OpAccessChain %56 %19 %76
%78 = OpLoad %9 %77
%79 = OpFSub %9 %74 %78
%80 = OpExtInst %9 %1 FAbs %79
%81 = OpAccessChain %28 %24 %26 %65
%82 = OpLoad %9 %81
%83 = OpFOrdLessThan %48 %80 %82
OpBranch %70
%70 = OpLabel
%84 = OpPhi %48 %68 %5 %83 %69
OpSelectionMerge %86 None
OpBranchConditional %84 %85 %86
%85 = OpLabel
%87 = OpAccessChain %53 %52 %26 %27
%88 = OpLoad %25 %87
%89 = OpAccessChain %56 %16 %88
%90 = OpLoad %9 %89
%91 = OpAccessChain %53 %52 %26 %27
%92 = OpLoad %25 %91
%93 = OpAccessChain %56 %19 %92
%94 = OpLoad %9 %93
%95 = OpFSub %9 %90 %94
%96 = OpExtInst %9 %1 FAbs %95
%97 = OpAccessChain %28 %24 %26 %65
%98 = OpLoad %9 %97
%99 = OpFOrdLessThan %48 %96 %98
OpBranch %86
%86 = OpLabel
%100 = OpPhi %48 %84 %70 %99 %85
OpSelectionMerge %102 None
OpBranchConditional %100 %101 %102
%101 = OpLabel
%103 = OpAccessChain %53 %52 %26 %65
%104 = OpLoad %25 %103
%105 = OpAccessChain %56 %16 %104
%106 = OpLoad %9 %105
%107 = OpAccessChain %53 %52 %26 %65
%108 = OpLoad %25 %107
%109 = OpAccessChain %56 %19 %108
%110 = OpLoad %9 %109
%111 = OpFSub %9 %106 %110
%112 = OpExtInst %9 %1 FAbs %111
%113 = OpAccessChain %28 %24 %26 %65
%114 = OpLoad %9 %113
%115 = OpFOrdLessThan %48 %112 %114
OpBranch %102
%102 = OpLabel
%116 = OpPhi %48 %100 %86 %115 %101
OpSelectionMerge %118 None
OpBranchConditional %116 %117 %134
%117 = OpLabel
%121 = OpAccessChain %53 %52 %26 %31
%122 = OpLoad %25 %121
%123 = OpConvertSToF %9 %122
%124 = OpAccessChain %53 %52 %26 %26
%125 = OpLoad %25 %124
%126 = OpConvertSToF %9 %125
%127 = OpAccessChain %53 %52 %26 %26
%128 = OpLoad %25 %127
%129 = OpConvertSToF %9 %128
%130 = OpAccessChain %53 %52 %26 %31
%131 = OpLoad %25 %130
%132 = OpConvertSToF %9 %131
%133 = OpCompositeConstruct %14 %123 %126 %129 %132
OpStore %120 %133
OpBranch %118
%134 = OpLabel
%135 = OpAccessChain %53 %52 %26 %26
%136 = OpLoad %25 %135
%137 = OpConvertSToF %9 %136
%138 = OpCompositeConstruct %14 %137 %137 %137 %137
OpStore %120 %138
OpBranch %118
%118 = OpLabel
OpReturn
OpFunctionEnd
END
# uniforms for variant
# _GLF_uniform_int_values
BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
0 1 3 2
END
# _GLF_uniform_float_values
BUFFER variant__GLF_uniform_float_values DATA_TYPE float[] STD140 DATA
255.0 60.0 0.01 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