blob: 9d889fc789f90a130f6d183e61620f23d7c7ce62 [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: Covers a specific instruction combine simplify demanded 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_1 _GLF_uniform_int_values[0]
# #define _int_0 _GLF_uniform_int_values[1]
# #define _int_2 _GLF_uniform_int_values[2]
# #define _int_3 _GLF_uniform_int_values[3]
# #define _float_0_0 _GLF_uniform_float_values[0]
# #define _float_127_0 _GLF_uniform_float_values[1]
# #define _float_60_0 _GLF_uniform_float_values[2]
#
# precision highp float;
#
# precision highp int;
#
# // Contents of _GLF_uniform_float_values: [0.0, 127.0, 60.0]
# layout(set = 0, binding = 0) uniform buf0
# {
# float _GLF_uniform_float_values[3];
# };
#
# // Contents of _GLF_uniform_int_values: [1, 0, 2, 3]
# layout(set = 0, binding = 1) uniform buf1
# {
# int _GLF_uniform_int_values[4];
# };
#
# layout(location = 0) out vec4 _GLF_color;
#
# void main()
# {
# // Converts the two 32-bit floating-point quantities to 16-bit quantities
# // and packs them into a 32-bit unsigned integer of 1006648320.
# uint a = packHalf2x16(vec2(1.0));
#
# // Unpacks the integer into 8-bit signed integers of values 0.0, 60.0, 0.0 and 60.0.
# // Then converts them into normalized floating-point numbers by dividing 127.0.
# vec4 v1 = unpackSnorm4x8(a);
#
# float E = 0.01;
# if (abs(v1[_int_0] - (_float_0_0 / _float_127_0)) < E
# && abs(v1[_int_1] - (_float_60_0 / _float_127_0)) < E
# && abs(v1[_int_2] - (_float_0_0 / _float_127_0)) < E
# && abs(v1[_int_3] - (_float_60_0 / _float_127_0)) < E)
# {
# _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1);
# }
# else
# {
# _GLF_color = vec4(v1[_int_0]);
# }
# }
SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
; SPIR-V
; Version: 1.0
; Generator: Khronos Glslang Reference Front End; 8
; Bound: 124
; Schema: 0
OpCapability Shader
%1 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint Fragment %4 "main" %104
OpExecutionMode %4 OriginUpperLeft
OpSource ESSL 310
OpName %4 "main"
OpName %8 "a"
OpName %16 "v1"
OpName %20 "E"
OpName %26 "buf1"
OpMemberName %26 0 "_GLF_uniform_int_values"
OpName %28 ""
OpName %38 "buf0"
OpMemberName %38 0 "_GLF_uniform_float_values"
OpName %40 ""
OpName %104 "_GLF_color"
OpDecorate %25 ArrayStride 16
OpMemberDecorate %26 0 Offset 0
OpDecorate %26 Block
OpDecorate %28 DescriptorSet 0
OpDecorate %28 Binding 1
OpDecorate %37 ArrayStride 16
OpMemberDecorate %38 0 Offset 0
OpDecorate %38 Block
OpDecorate %40 DescriptorSet 0
OpDecorate %40 Binding 0
OpDecorate %104 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
%19 = OpTypePointer Function %9
%21 = OpConstant %9 0.00999999978
%22 = OpTypeBool
%23 = OpTypeInt 32 1
%24 = OpConstant %6 4
%25 = OpTypeArray %23 %24
%26 = OpTypeStruct %25
%27 = OpTypePointer Uniform %26
%28 = OpVariable %27 Uniform
%29 = OpConstant %23 0
%30 = OpConstant %23 1
%31 = OpTypePointer Uniform %23
%36 = OpConstant %6 3
%37 = OpTypeArray %9 %36
%38 = OpTypeStruct %37
%39 = OpTypePointer Uniform %38
%40 = OpVariable %39 Uniform
%41 = OpTypePointer Uniform %9
%57 = OpConstant %23 2
%86 = OpConstant %23 3
%103 = OpTypePointer Output %14
%104 = OpVariable %103 Output
%4 = OpFunction %2 None %3
%5 = OpLabel
%8 = OpVariable %7 Function
%16 = OpVariable %15 Function
%20 = OpVariable %19 Function
%13 = OpExtInst %6 %1 PackHalf2x16 %12
OpStore %8 %13
%17 = OpLoad %6 %8
%18 = OpExtInst %14 %1 UnpackSnorm4x8 %17
OpStore %16 %18
OpStore %20 %21
%32 = OpAccessChain %31 %28 %29 %30
%33 = OpLoad %23 %32
%34 = OpAccessChain %19 %16 %33
%35 = OpLoad %9 %34
%42 = OpAccessChain %41 %40 %29 %29
%43 = OpLoad %9 %42
%44 = OpAccessChain %41 %40 %29 %30
%45 = OpLoad %9 %44
%46 = OpFDiv %9 %43 %45
%47 = OpFSub %9 %35 %46
%48 = OpExtInst %9 %1 FAbs %47
%49 = OpLoad %9 %20
%50 = OpFOrdLessThan %22 %48 %49
OpSelectionMerge %52 None
OpBranchConditional %50 %51 %52
%51 = OpLabel
%53 = OpAccessChain %31 %28 %29 %29
%54 = OpLoad %23 %53
%55 = OpAccessChain %19 %16 %54
%56 = OpLoad %9 %55
%58 = OpAccessChain %41 %40 %29 %57
%59 = OpLoad %9 %58
%60 = OpAccessChain %41 %40 %29 %30
%61 = OpLoad %9 %60
%62 = OpFDiv %9 %59 %61
%63 = OpFSub %9 %56 %62
%64 = OpExtInst %9 %1 FAbs %63
%65 = OpLoad %9 %20
%66 = OpFOrdLessThan %22 %64 %65
OpBranch %52
%52 = OpLabel
%67 = OpPhi %22 %50 %5 %66 %51
OpSelectionMerge %69 None
OpBranchConditional %67 %68 %69
%68 = OpLabel
%70 = OpAccessChain %31 %28 %29 %57
%71 = OpLoad %23 %70
%72 = OpAccessChain %19 %16 %71
%73 = OpLoad %9 %72
%74 = OpAccessChain %41 %40 %29 %29
%75 = OpLoad %9 %74
%76 = OpAccessChain %41 %40 %29 %30
%77 = OpLoad %9 %76
%78 = OpFDiv %9 %75 %77
%79 = OpFSub %9 %73 %78
%80 = OpExtInst %9 %1 FAbs %79
%81 = OpLoad %9 %20
%82 = OpFOrdLessThan %22 %80 %81
OpBranch %69
%69 = OpLabel
%83 = OpPhi %22 %67 %52 %82 %68
OpSelectionMerge %85 None
OpBranchConditional %83 %84 %85
%84 = OpLabel
%87 = OpAccessChain %31 %28 %29 %86
%88 = OpLoad %23 %87
%89 = OpAccessChain %19 %16 %88
%90 = OpLoad %9 %89
%91 = OpAccessChain %41 %40 %29 %57
%92 = OpLoad %9 %91
%93 = OpAccessChain %41 %40 %29 %30
%94 = OpLoad %9 %93
%95 = OpFDiv %9 %92 %94
%96 = OpFSub %9 %90 %95
%97 = OpExtInst %9 %1 FAbs %96
%98 = OpLoad %9 %20
%99 = OpFOrdLessThan %22 %97 %98
OpBranch %85
%85 = OpLabel
%100 = OpPhi %22 %83 %69 %99 %84
OpSelectionMerge %102 None
OpBranchConditional %100 %101 %118
%101 = OpLabel
%105 = OpAccessChain %31 %28 %29 %29
%106 = OpLoad %23 %105
%107 = OpConvertSToF %9 %106
%108 = OpAccessChain %31 %28 %29 %30
%109 = OpLoad %23 %108
%110 = OpConvertSToF %9 %109
%111 = OpAccessChain %31 %28 %29 %30
%112 = OpLoad %23 %111
%113 = OpConvertSToF %9 %112
%114 = OpAccessChain %31 %28 %29 %29
%115 = OpLoad %23 %114
%116 = OpConvertSToF %9 %115
%117 = OpCompositeConstruct %14 %107 %110 %113 %116
OpStore %104 %117
OpBranch %102
%118 = OpLabel
%119 = OpAccessChain %31 %28 %29 %30
%120 = OpLoad %23 %119
%121 = OpAccessChain %19 %16 %120
%122 = OpLoad %9 %121
%123 = OpCompositeConstruct %14 %122 %122 %122 %122
OpStore %104 %123
OpBranch %102
%102 = OpLabel
OpReturn
OpFunctionEnd
END
# uniforms for variant
# _GLF_uniform_int_values
BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
1 0 2 3
END
# _GLF_uniform_float_values
BUFFER variant__GLF_uniform_float_values DATA_TYPE float[] STD140 DATA
0.0 127.0 60.0
END
BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
PIPELINE graphics variant_pipeline
ATTACH variant_vertex_shader
ATTACH variant_fragment_shader
FRAMEBUFFER_SIZE 16 16
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 16 16
EXPECT variant_framebuffer IDX 0 0 SIZE 16 16 EQ_RGBA 255 0 0 255