From c81f9dce07e5ea41e8aa1f65bc619b6ed669403b Mon Sep 17 00:00:00 2001 From: Ben Clayton Date: Wed, 2 Nov 2022 17:29:48 +0000 Subject: [PATCH] tint: Implement const-eval of quantizeToF16 Bug: tint:1581 Change-Id: I5cf9806bde7875282d3b67731dbb88666523f598 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/108142 Reviewed-by: Antonio Maiorano Commit-Queue: Ben Clayton Kokoro: Ben Clayton Kokoro: Kokoro --- src/tint/intrinsics.def | 4 +- src/tint/resolver/const_eval.cc | 21 ++++++ src/tint/resolver/const_eval.h | 9 +++ src/tint/resolver/const_eval_builtin_test.cc | 57 ++++++++++++++++ src/tint/resolver/intrinsic_table.inl | 4 +- .../12e50e.wgsl.expected.dxc.hlsl | 2 +- .../12e50e.wgsl.expected.fxc.hlsl | 2 +- .../quantizeToF16/12e50e.wgsl.expected.glsl | 21 +----- .../quantizeToF16/12e50e.wgsl.expected.msl | 2 +- .../quantizeToF16/12e50e.wgsl.expected.spvasm | 27 ++++---- .../2cddf3.wgsl.expected.dxc.hlsl | 2 +- .../2cddf3.wgsl.expected.fxc.hlsl | 2 +- .../quantizeToF16/2cddf3.wgsl.expected.glsl | 21 +----- .../quantizeToF16/2cddf3.wgsl.expected.msl | 2 +- .../quantizeToF16/2cddf3.wgsl.expected.spvasm | 63 +++++++----------- .../cba294.wgsl.expected.dxc.hlsl | 2 +- .../cba294.wgsl.expected.fxc.hlsl | 2 +- .../quantizeToF16/cba294.wgsl.expected.glsl | 27 +------- .../quantizeToF16/cba294.wgsl.expected.msl | 2 +- .../quantizeToF16/cba294.wgsl.expected.spvasm | 61 ++++++----------- .../e8fd14.wgsl.expected.dxc.hlsl | 2 +- .../e8fd14.wgsl.expected.fxc.hlsl | 2 +- .../quantizeToF16/e8fd14.wgsl.expected.glsl | 27 +------- .../quantizeToF16/e8fd14.wgsl.expected.msl | 2 +- .../quantizeToF16/e8fd14.wgsl.expected.spvasm | 66 +++++++------------ webgpu-cts/expectations.txt | 1 - 26 files changed, 193 insertions(+), 240 deletions(-) diff --git a/src/tint/intrinsics.def b/src/tint/intrinsics.def index cc228311d2..3146aa84f4 100644 --- a/src/tint/intrinsics.def +++ b/src/tint/intrinsics.def @@ -514,8 +514,8 @@ fn pack4x8snorm(vec4) -> u32 fn pack4x8unorm(vec4) -> u32 fn pow(T, T) -> T fn pow(vec, vec) -> vec -fn quantizeToF16(f32) -> f32 -fn quantizeToF16(vec) -> vec +@const fn quantizeToF16(f32) -> f32 +@const fn quantizeToF16(vec) -> vec fn radians(T) -> T fn radians(vec) -> vec fn reflect(vec, vec) -> vec diff --git a/src/tint/resolver/const_eval.cc b/src/tint/resolver/const_eval.cc index b61151d62b..0331f46cf2 100644 --- a/src/tint/resolver/const_eval.cc +++ b/src/tint/resolver/const_eval.cc @@ -1869,6 +1869,27 @@ ConstEval::Result ConstEval::step(const sem::Type* ty, return TransformElements(builder, ty, transform, args[0], args[1]); } +ConstEval::Result ConstEval::quantizeToF16(const sem::Type* ty, + utils::VectorRef args, + const Source&) { + auto transform = [&](const sem::Constant* c) { + auto conv = CheckedConvert(f16(c->As())); + if (!conv) { + // https://www.w3.org/TR/WGSL/#quantizeToF16-builtin + // If e is outside the finite range of binary16, then the result is any value of type + // f32 + switch (conv.Failure()) { + case ConversionFailure::kExceedsNegativeLimit: + return CreateElement(builder, c->Type(), f16(f16::kLowestValue)); + case ConversionFailure::kExceedsPositiveLimit: + return CreateElement(builder, c->Type(), f16(f16::kHighestValue)); + } + } + return CreateElement(builder, c->Type(), conv.Get()); + }; + return TransformElements(builder, ty, transform, args[0]); +} + ConstEval::Result ConstEval::Convert(const sem::Type* target_ty, const sem::Constant* value, const Source& source) { diff --git a/src/tint/resolver/const_eval.h b/src/tint/resolver/const_eval.h index 91189fab25..07ce7e7d0b 100644 --- a/src/tint/resolver/const_eval.h +++ b/src/tint/resolver/const_eval.h @@ -530,6 +530,15 @@ class ConstEval { utils::VectorRef args, const Source& source); + /// quantizeToF16 builtin + /// @param ty the expression type + /// @param args the input arguments + /// @param source the source location of the conversion + /// @return the result value, or null if the value cannot be calculated + Result quantizeToF16(const sem::Type* ty, + utils::VectorRef args, + const Source& source); + private: /// Adds the given error message to the diagnostics void AddError(const std::string& msg, const Source& source) const; diff --git a/src/tint/resolver/const_eval_builtin_test.cc b/src/tint/resolver/const_eval_builtin_test.cc index 3c275cb5fe..daa5a7265d 100644 --- a/src/tint/resolver/const_eval_builtin_test.cc +++ b/src/tint/resolver/const_eval_builtin_test.cc @@ -842,5 +842,62 @@ INSTANTIATE_TEST_SUITE_P( // StepCases(), StepCases())))); +std::vector QuantizeToF16Cases() { + return { + C({0_f}, 0_f), // + C({-0_f}, -0_f), // + C({1_f}, 1_f), // + C({-1_f}, -1_f), // + + // 0.00006106496 quantized to 0.000061035156 = 0x1p-14 + C({0.00006106496_f}, 0.000061035156_f), // + C({-0.00006106496_f}, -0.000061035156_f), // + + // 1.0004883 quantized to 1.0 = 0x1p0 + C({1.0004883_f}, 1.0_f), // + C({-1.0004883_f}, -1.0_f), // + + // 8196.0 quantized to 8192.0 = 0x1p13 + C({8196_f}, 8192_f), // + C({-8196_f}, -8192_f), // + + // Value in subnormal f16 range + C({0x0.034p-14_f}, 0x0.034p-14_f), // + C({-0x0.034p-14_f}, -0x0.034p-14_f), // + C({0x0.068p-14_f}, 0x0.068p-14_f), // + C({-0x0.068p-14_f}, -0x0.068p-14_f), // + + // 0x0.06b7p-14 quantized to 0x0.068p-14 + C({0x0.06b7p-14_f}, 0x0.068p-14_f), // + C({-0x0.06b7p-14_f}, -0x0.068p-14_f), // + + // Value out of f16 range + C({65504.003_f}, 65504_f), // + C({-65504.003_f}, -65504_f), // + C({0x1.234p56_f}, 65504_f), // + C({-0x4.321p65_f}, -65504_f), // + + // Vector tests + C({Vec(0_f, -0_f)}, Vec(0_f, -0_f)), // + C({Vec(1_f, -1_f)}, Vec(1_f, -1_f)), // + + C({Vec(0.00006106496_f, -0.00006106496_f, 1.0004883_f, -1.0004883_f)}, + Vec(0.000061035156_f, -0.000061035156_f, 1.0_f, -1.0_f)), + + C({Vec(8196_f, 8192_f, 0x0.034p-14_f)}, Vec(8192_f, 8192_f, 0x0.034p-14_f)), + + C({Vec(0x0.034p-14_f, -0x0.034p-14_f, 0x0.068p-14_f, -0x0.068p-14_f)}, + Vec(0x0.034p-14_f, -0x0.034p-14_f, 0x0.068p-14_f, -0x0.068p-14_f)), + + C({Vec(65504.003_f, 0x1.234p56_f)}, Vec(65504_f, 65504_f)), + C({Vec(-0x1.234p56_f, -65504.003_f)}, Vec(-65504_f, -65504_f)), + }; +} +INSTANTIATE_TEST_SUITE_P( // + QuantizeToF16, + ResolverConstEvalBuiltinTest, + testing::Combine(testing::Values(sem::BuiltinType::kQuantizeToF16), + testing::ValuesIn(QuantizeToF16Cases()))); + } // namespace } // namespace tint::resolver diff --git a/src/tint/resolver/intrinsic_table.inl b/src/tint/resolver/intrinsic_table.inl index 5335ed7e15..ea7ad989a8 100644 --- a/src/tint/resolver/intrinsic_table.inl +++ b/src/tint/resolver/intrinsic_table.inl @@ -12302,7 +12302,7 @@ constexpr OverloadInfo kOverloads[] = { /* parameters */ &kParameters[880], /* return matcher indices */ &kMatcherIndices[62], /* flags */ OverloadFlags(OverloadFlag::kIsBuiltin, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline), - /* const eval */ nullptr, + /* const eval */ &ConstEval::quantizeToF16, }, { /* [331] */ @@ -12314,7 +12314,7 @@ constexpr OverloadInfo kOverloads[] = { /* parameters */ &kParameters[879], /* return matcher indices */ &kMatcherIndices[60], /* flags */ OverloadFlags(OverloadFlag::kIsBuiltin, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline), - /* const eval */ nullptr, + /* const eval */ &ConstEval::quantizeToF16, }, { /* [332] */ diff --git a/test/tint/builtins/gen/literal/quantizeToF16/12e50e.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/quantizeToF16/12e50e.wgsl.expected.dxc.hlsl index 0068d1c74a..4ed0cbcb3b 100644 --- a/test/tint/builtins/gen/literal/quantizeToF16/12e50e.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/literal/quantizeToF16/12e50e.wgsl.expected.dxc.hlsl @@ -1,5 +1,5 @@ void quantizeToF16_12e50e() { - float res = float(min16float(1.0f)); + float res = 1.0f; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/quantizeToF16/12e50e.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/quantizeToF16/12e50e.wgsl.expected.fxc.hlsl index 0068d1c74a..4ed0cbcb3b 100644 --- a/test/tint/builtins/gen/literal/quantizeToF16/12e50e.wgsl.expected.fxc.hlsl +++ b/test/tint/builtins/gen/literal/quantizeToF16/12e50e.wgsl.expected.fxc.hlsl @@ -1,5 +1,5 @@ void quantizeToF16_12e50e() { - float res = float(min16float(1.0f)); + float res = 1.0f; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/quantizeToF16/12e50e.wgsl.expected.glsl b/test/tint/builtins/gen/literal/quantizeToF16/12e50e.wgsl.expected.glsl index b0c188fc4d..531c0b279f 100644 --- a/test/tint/builtins/gen/literal/quantizeToF16/12e50e.wgsl.expected.glsl +++ b/test/tint/builtins/gen/literal/quantizeToF16/12e50e.wgsl.expected.glsl @@ -1,12 +1,7 @@ #version 310 es -float tint_quantizeToF16(float param_0) { - return unpackHalf2x16(packHalf2x16(vec2(param_0))).x; -} - - void quantizeToF16_12e50e() { - float res = tint_quantizeToF16(1.0f); + float res = 1.0f; } vec4 vertex_main() { @@ -25,13 +20,8 @@ void main() { #version 310 es precision mediump float; -float tint_quantizeToF16(float param_0) { - return unpackHalf2x16(packHalf2x16(vec2(param_0))).x; -} - - void quantizeToF16_12e50e() { - float res = tint_quantizeToF16(1.0f); + float res = 1.0f; } void fragment_main() { @@ -44,13 +34,8 @@ void main() { } #version 310 es -float tint_quantizeToF16(float param_0) { - return unpackHalf2x16(packHalf2x16(vec2(param_0))).x; -} - - void quantizeToF16_12e50e() { - float res = tint_quantizeToF16(1.0f); + float res = 1.0f; } void compute_main() { diff --git a/test/tint/builtins/gen/literal/quantizeToF16/12e50e.wgsl.expected.msl b/test/tint/builtins/gen/literal/quantizeToF16/12e50e.wgsl.expected.msl index ef41ccf7a0..1299d620e1 100644 --- a/test/tint/builtins/gen/literal/quantizeToF16/12e50e.wgsl.expected.msl +++ b/test/tint/builtins/gen/literal/quantizeToF16/12e50e.wgsl.expected.msl @@ -2,7 +2,7 @@ using namespace metal; void quantizeToF16_12e50e() { - float res = float(half(1.0f)); + float res = 1.0f; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/quantizeToF16/12e50e.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/quantizeToF16/12e50e.wgsl.expected.spvasm index c9d9f279ad..623716f464 100644 --- a/test/tint/builtins/gen/literal/quantizeToF16/12e50e.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/literal/quantizeToF16/12e50e.wgsl.expected.spvasm @@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 30 +; Bound: 29 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -32,33 +32,32 @@ %9 = OpTypeFunction %void %float_1 = OpConstant %float 1 %_ptr_Function_float = OpTypePointer Function %float - %17 = OpTypeFunction %v4float + %16 = OpTypeFunction %v4float %quantizeToF16_12e50e = OpFunction %void None %9 %12 = OpLabel %res = OpVariable %_ptr_Function_float Function %8 - %13 = OpQuantizeToF16 %float %float_1 - OpStore %res %13 + OpStore %res %float_1 OpReturn OpFunctionEnd -%vertex_main_inner = OpFunction %v4float None %17 - %19 = OpLabel - %20 = OpFunctionCall %void %quantizeToF16_12e50e +%vertex_main_inner = OpFunction %v4float None %16 + %18 = OpLabel + %19 = OpFunctionCall %void %quantizeToF16_12e50e OpReturnValue %5 OpFunctionEnd %vertex_main = OpFunction %void None %9 - %22 = OpLabel - %23 = OpFunctionCall %v4float %vertex_main_inner - OpStore %value %23 + %21 = OpLabel + %22 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %22 OpStore %vertex_point_size %float_1 OpReturn OpFunctionEnd %fragment_main = OpFunction %void None %9 - %25 = OpLabel - %26 = OpFunctionCall %void %quantizeToF16_12e50e + %24 = OpLabel + %25 = OpFunctionCall %void %quantizeToF16_12e50e OpReturn OpFunctionEnd %compute_main = OpFunction %void None %9 - %28 = OpLabel - %29 = OpFunctionCall %void %quantizeToF16_12e50e + %27 = OpLabel + %28 = OpFunctionCall %void %quantizeToF16_12e50e OpReturn OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/quantizeToF16/2cddf3.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/quantizeToF16/2cddf3.wgsl.expected.dxc.hlsl index d50ffc8c53..ef0fc5607d 100644 --- a/test/tint/builtins/gen/literal/quantizeToF16/2cddf3.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/literal/quantizeToF16/2cddf3.wgsl.expected.dxc.hlsl @@ -1,5 +1,5 @@ void quantizeToF16_2cddf3() { - float2 res = float2(min16float2((1.0f).xx)); + float2 res = (1.0f).xx; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/quantizeToF16/2cddf3.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/quantizeToF16/2cddf3.wgsl.expected.fxc.hlsl index d50ffc8c53..ef0fc5607d 100644 --- a/test/tint/builtins/gen/literal/quantizeToF16/2cddf3.wgsl.expected.fxc.hlsl +++ b/test/tint/builtins/gen/literal/quantizeToF16/2cddf3.wgsl.expected.fxc.hlsl @@ -1,5 +1,5 @@ void quantizeToF16_2cddf3() { - float2 res = float2(min16float2((1.0f).xx)); + float2 res = (1.0f).xx; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/quantizeToF16/2cddf3.wgsl.expected.glsl b/test/tint/builtins/gen/literal/quantizeToF16/2cddf3.wgsl.expected.glsl index 70672e9aeb..1a895b15b5 100644 --- a/test/tint/builtins/gen/literal/quantizeToF16/2cddf3.wgsl.expected.glsl +++ b/test/tint/builtins/gen/literal/quantizeToF16/2cddf3.wgsl.expected.glsl @@ -1,12 +1,7 @@ #version 310 es -vec2 tint_quantizeToF16(vec2 param_0) { - return unpackHalf2x16(packHalf2x16(param_0)); -} - - void quantizeToF16_2cddf3() { - vec2 res = tint_quantizeToF16(vec2(1.0f)); + vec2 res = vec2(1.0f); } vec4 vertex_main() { @@ -25,13 +20,8 @@ void main() { #version 310 es precision mediump float; -vec2 tint_quantizeToF16(vec2 param_0) { - return unpackHalf2x16(packHalf2x16(param_0)); -} - - void quantizeToF16_2cddf3() { - vec2 res = tint_quantizeToF16(vec2(1.0f)); + vec2 res = vec2(1.0f); } void fragment_main() { @@ -44,13 +34,8 @@ void main() { } #version 310 es -vec2 tint_quantizeToF16(vec2 param_0) { - return unpackHalf2x16(packHalf2x16(param_0)); -} - - void quantizeToF16_2cddf3() { - vec2 res = tint_quantizeToF16(vec2(1.0f)); + vec2 res = vec2(1.0f); } void compute_main() { diff --git a/test/tint/builtins/gen/literal/quantizeToF16/2cddf3.wgsl.expected.msl b/test/tint/builtins/gen/literal/quantizeToF16/2cddf3.wgsl.expected.msl index 0ac4a09b09..eccd5ae36b 100644 --- a/test/tint/builtins/gen/literal/quantizeToF16/2cddf3.wgsl.expected.msl +++ b/test/tint/builtins/gen/literal/quantizeToF16/2cddf3.wgsl.expected.msl @@ -2,7 +2,7 @@ using namespace metal; void quantizeToF16_2cddf3() { - float2 res = float2(half2(float2(1.0f))); + float2 res = float2(1.0f); } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/quantizeToF16/2cddf3.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/quantizeToF16/2cddf3.wgsl.expected.spvasm index 189b7c0abc..b71e9dac56 100644 --- a/test/tint/builtins/gen/literal/quantizeToF16/2cddf3.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/literal/quantizeToF16/2cddf3.wgsl.expected.spvasm @@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 45 +; Bound: 32 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -12,8 +12,6 @@ OpExecutionMode %compute_main LocalSize 1 1 1 OpName %value "value" OpName %vertex_point_size "vertex_point_size" - OpName %tint_quantizeToF16 "tint_quantizeToF16" - OpName %v "v" OpName %quantizeToF16_2cddf3 "quantizeToF16_2cddf3" OpName %res "res" OpName %vertex_main_inner "vertex_main_inner" @@ -30,54 +28,39 @@ %_ptr_Output_float = OpTypePointer Output %float %8 = OpConstantNull %float %vertex_point_size = OpVariable %_ptr_Output_float Output %8 - %v2float = OpTypeVector %float 2 - %9 = OpTypeFunction %v2float %v2float - %uint = OpTypeInt 32 0 - %16 = OpConstantNull %uint - %uint_1 = OpConstant %uint 1 %void = OpTypeVoid - %22 = OpTypeFunction %void + %9 = OpTypeFunction %void + %v2float = OpTypeVector %float 2 %float_1 = OpConstant %float 1 - %28 = OpConstantComposite %v2float %float_1 %float_1 + %15 = OpConstantComposite %v2float %float_1 %float_1 %_ptr_Function_v2float = OpTypePointer Function %v2float - %31 = OpConstantNull %v2float - %32 = OpTypeFunction %v4float -%tint_quantizeToF16 = OpFunction %v2float None %9 - %v = OpFunctionParameter %v2float - %13 = OpLabel - %17 = OpCompositeExtract %float %v 0 - %14 = OpQuantizeToF16 %float %17 - %20 = OpCompositeExtract %float %v 1 - %18 = OpQuantizeToF16 %float %20 - %21 = OpCompositeConstruct %v2float %14 %18 - OpReturnValue %21 - OpFunctionEnd -%quantizeToF16_2cddf3 = OpFunction %void None %22 - %25 = OpLabel - %res = OpVariable %_ptr_Function_v2float Function %31 - %26 = OpFunctionCall %v2float %tint_quantizeToF16 %28 - OpStore %res %26 + %18 = OpConstantNull %v2float + %19 = OpTypeFunction %v4float +%quantizeToF16_2cddf3 = OpFunction %void None %9 + %12 = OpLabel + %res = OpVariable %_ptr_Function_v2float Function %18 + OpStore %res %15 OpReturn OpFunctionEnd -%vertex_main_inner = OpFunction %v4float None %32 - %34 = OpLabel - %35 = OpFunctionCall %void %quantizeToF16_2cddf3 +%vertex_main_inner = OpFunction %v4float None %19 + %21 = OpLabel + %22 = OpFunctionCall %void %quantizeToF16_2cddf3 OpReturnValue %5 OpFunctionEnd -%vertex_main = OpFunction %void None %22 - %37 = OpLabel - %38 = OpFunctionCall %v4float %vertex_main_inner - OpStore %value %38 +%vertex_main = OpFunction %void None %9 + %24 = OpLabel + %25 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %25 OpStore %vertex_point_size %float_1 OpReturn OpFunctionEnd -%fragment_main = OpFunction %void None %22 - %40 = OpLabel - %41 = OpFunctionCall %void %quantizeToF16_2cddf3 +%fragment_main = OpFunction %void None %9 + %27 = OpLabel + %28 = OpFunctionCall %void %quantizeToF16_2cddf3 OpReturn OpFunctionEnd -%compute_main = OpFunction %void None %22 - %43 = OpLabel - %44 = OpFunctionCall %void %quantizeToF16_2cddf3 +%compute_main = OpFunction %void None %9 + %30 = OpLabel + %31 = OpFunctionCall %void %quantizeToF16_2cddf3 OpReturn OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/quantizeToF16/cba294.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/quantizeToF16/cba294.wgsl.expected.dxc.hlsl index 85c7a6dabc..e597919145 100644 --- a/test/tint/builtins/gen/literal/quantizeToF16/cba294.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/literal/quantizeToF16/cba294.wgsl.expected.dxc.hlsl @@ -1,5 +1,5 @@ void quantizeToF16_cba294() { - float4 res = float4(min16float4((1.0f).xxxx)); + float4 res = (1.0f).xxxx; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/quantizeToF16/cba294.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/quantizeToF16/cba294.wgsl.expected.fxc.hlsl index 85c7a6dabc..e597919145 100644 --- a/test/tint/builtins/gen/literal/quantizeToF16/cba294.wgsl.expected.fxc.hlsl +++ b/test/tint/builtins/gen/literal/quantizeToF16/cba294.wgsl.expected.fxc.hlsl @@ -1,5 +1,5 @@ void quantizeToF16_cba294() { - float4 res = float4(min16float4((1.0f).xxxx)); + float4 res = (1.0f).xxxx; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/quantizeToF16/cba294.wgsl.expected.glsl b/test/tint/builtins/gen/literal/quantizeToF16/cba294.wgsl.expected.glsl index a16f0f9360..dc1eb66f82 100644 --- a/test/tint/builtins/gen/literal/quantizeToF16/cba294.wgsl.expected.glsl +++ b/test/tint/builtins/gen/literal/quantizeToF16/cba294.wgsl.expected.glsl @@ -1,14 +1,7 @@ #version 310 es -vec4 tint_quantizeToF16(vec4 param_0) { - return vec4( - unpackHalf2x16(packHalf2x16(param_0.xy)), - unpackHalf2x16(packHalf2x16(param_0.zw))); -} - - void quantizeToF16_cba294() { - vec4 res = tint_quantizeToF16(vec4(1.0f)); + vec4 res = vec4(1.0f); } vec4 vertex_main() { @@ -27,15 +20,8 @@ void main() { #version 310 es precision mediump float; -vec4 tint_quantizeToF16(vec4 param_0) { - return vec4( - unpackHalf2x16(packHalf2x16(param_0.xy)), - unpackHalf2x16(packHalf2x16(param_0.zw))); -} - - void quantizeToF16_cba294() { - vec4 res = tint_quantizeToF16(vec4(1.0f)); + vec4 res = vec4(1.0f); } void fragment_main() { @@ -48,15 +34,8 @@ void main() { } #version 310 es -vec4 tint_quantizeToF16(vec4 param_0) { - return vec4( - unpackHalf2x16(packHalf2x16(param_0.xy)), - unpackHalf2x16(packHalf2x16(param_0.zw))); -} - - void quantizeToF16_cba294() { - vec4 res = tint_quantizeToF16(vec4(1.0f)); + vec4 res = vec4(1.0f); } void compute_main() { diff --git a/test/tint/builtins/gen/literal/quantizeToF16/cba294.wgsl.expected.msl b/test/tint/builtins/gen/literal/quantizeToF16/cba294.wgsl.expected.msl index d615dd52af..6dbfc50766 100644 --- a/test/tint/builtins/gen/literal/quantizeToF16/cba294.wgsl.expected.msl +++ b/test/tint/builtins/gen/literal/quantizeToF16/cba294.wgsl.expected.msl @@ -2,7 +2,7 @@ using namespace metal; void quantizeToF16_cba294() { - float4 res = float4(half4(float4(1.0f))); + float4 res = float4(1.0f); } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/quantizeToF16/cba294.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/quantizeToF16/cba294.wgsl.expected.spvasm index 69dbb990ce..bea69618f4 100644 --- a/test/tint/builtins/gen/literal/quantizeToF16/cba294.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/literal/quantizeToF16/cba294.wgsl.expected.spvasm @@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 49 +; Bound: 30 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -12,8 +12,6 @@ OpExecutionMode %compute_main LocalSize 1 1 1 OpName %value "value" OpName %vertex_point_size "vertex_point_size" - OpName %tint_quantizeToF16 "tint_quantizeToF16" - OpName %v "v" OpName %quantizeToF16_cba294 "quantizeToF16_cba294" OpName %res "res" OpName %vertex_main_inner "vertex_main_inner" @@ -30,58 +28,37 @@ %_ptr_Output_float = OpTypePointer Output %float %8 = OpConstantNull %float %vertex_point_size = OpVariable %_ptr_Output_float Output %8 - %9 = OpTypeFunction %v4float %v4float - %uint = OpTypeInt 32 0 - %15 = OpConstantNull %uint - %uint_1 = OpConstant %uint 1 - %uint_2 = OpConstant %uint 2 - %uint_3 = OpConstant %uint 3 %void = OpTypeVoid - %27 = OpTypeFunction %void + %9 = OpTypeFunction %void %float_1 = OpConstant %float 1 - %33 = OpConstantComposite %v4float %float_1 %float_1 %float_1 %float_1 + %14 = OpConstantComposite %v4float %float_1 %float_1 %float_1 %float_1 %_ptr_Function_v4float = OpTypePointer Function %v4float - %36 = OpTypeFunction %v4float -%tint_quantizeToF16 = OpFunction %v4float None %9 - %v = OpFunctionParameter %v4float + %17 = OpTypeFunction %v4float +%quantizeToF16_cba294 = OpFunction %void None %9 %12 = OpLabel - %16 = OpCompositeExtract %float %v 0 - %13 = OpQuantizeToF16 %float %16 - %19 = OpCompositeExtract %float %v 1 - %17 = OpQuantizeToF16 %float %19 - %22 = OpCompositeExtract %float %v 2 - %20 = OpQuantizeToF16 %float %22 - %25 = OpCompositeExtract %float %v 3 - %23 = OpQuantizeToF16 %float %25 - %26 = OpCompositeConstruct %v4float %13 %17 %20 %23 - OpReturnValue %26 - OpFunctionEnd -%quantizeToF16_cba294 = OpFunction %void None %27 - %30 = OpLabel %res = OpVariable %_ptr_Function_v4float Function %5 - %31 = OpFunctionCall %v4float %tint_quantizeToF16 %33 - OpStore %res %31 + OpStore %res %14 OpReturn OpFunctionEnd -%vertex_main_inner = OpFunction %v4float None %36 - %38 = OpLabel - %39 = OpFunctionCall %void %quantizeToF16_cba294 +%vertex_main_inner = OpFunction %v4float None %17 + %19 = OpLabel + %20 = OpFunctionCall %void %quantizeToF16_cba294 OpReturnValue %5 OpFunctionEnd -%vertex_main = OpFunction %void None %27 - %41 = OpLabel - %42 = OpFunctionCall %v4float %vertex_main_inner - OpStore %value %42 +%vertex_main = OpFunction %void None %9 + %22 = OpLabel + %23 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %23 OpStore %vertex_point_size %float_1 OpReturn OpFunctionEnd -%fragment_main = OpFunction %void None %27 - %44 = OpLabel - %45 = OpFunctionCall %void %quantizeToF16_cba294 +%fragment_main = OpFunction %void None %9 + %25 = OpLabel + %26 = OpFunctionCall %void %quantizeToF16_cba294 OpReturn OpFunctionEnd -%compute_main = OpFunction %void None %27 - %47 = OpLabel - %48 = OpFunctionCall %void %quantizeToF16_cba294 +%compute_main = OpFunction %void None %9 + %28 = OpLabel + %29 = OpFunctionCall %void %quantizeToF16_cba294 OpReturn OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/quantizeToF16/e8fd14.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/quantizeToF16/e8fd14.wgsl.expected.dxc.hlsl index e5a09b3326..c403817c9a 100644 --- a/test/tint/builtins/gen/literal/quantizeToF16/e8fd14.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/literal/quantizeToF16/e8fd14.wgsl.expected.dxc.hlsl @@ -1,5 +1,5 @@ void quantizeToF16_e8fd14() { - float3 res = float3(min16float3((1.0f).xxx)); + float3 res = (1.0f).xxx; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/quantizeToF16/e8fd14.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/quantizeToF16/e8fd14.wgsl.expected.fxc.hlsl index e5a09b3326..c403817c9a 100644 --- a/test/tint/builtins/gen/literal/quantizeToF16/e8fd14.wgsl.expected.fxc.hlsl +++ b/test/tint/builtins/gen/literal/quantizeToF16/e8fd14.wgsl.expected.fxc.hlsl @@ -1,5 +1,5 @@ void quantizeToF16_e8fd14() { - float3 res = float3(min16float3((1.0f).xxx)); + float3 res = (1.0f).xxx; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/quantizeToF16/e8fd14.wgsl.expected.glsl b/test/tint/builtins/gen/literal/quantizeToF16/e8fd14.wgsl.expected.glsl index d277459e1e..b5cf6bf950 100644 --- a/test/tint/builtins/gen/literal/quantizeToF16/e8fd14.wgsl.expected.glsl +++ b/test/tint/builtins/gen/literal/quantizeToF16/e8fd14.wgsl.expected.glsl @@ -1,14 +1,7 @@ #version 310 es -vec3 tint_quantizeToF16(vec3 param_0) { - return vec3( - unpackHalf2x16(packHalf2x16(param_0.xy)), - unpackHalf2x16(packHalf2x16(param_0.zz)).x); -} - - void quantizeToF16_e8fd14() { - vec3 res = tint_quantizeToF16(vec3(1.0f)); + vec3 res = vec3(1.0f); } vec4 vertex_main() { @@ -27,15 +20,8 @@ void main() { #version 310 es precision mediump float; -vec3 tint_quantizeToF16(vec3 param_0) { - return vec3( - unpackHalf2x16(packHalf2x16(param_0.xy)), - unpackHalf2x16(packHalf2x16(param_0.zz)).x); -} - - void quantizeToF16_e8fd14() { - vec3 res = tint_quantizeToF16(vec3(1.0f)); + vec3 res = vec3(1.0f); } void fragment_main() { @@ -48,15 +34,8 @@ void main() { } #version 310 es -vec3 tint_quantizeToF16(vec3 param_0) { - return vec3( - unpackHalf2x16(packHalf2x16(param_0.xy)), - unpackHalf2x16(packHalf2x16(param_0.zz)).x); -} - - void quantizeToF16_e8fd14() { - vec3 res = tint_quantizeToF16(vec3(1.0f)); + vec3 res = vec3(1.0f); } void compute_main() { diff --git a/test/tint/builtins/gen/literal/quantizeToF16/e8fd14.wgsl.expected.msl b/test/tint/builtins/gen/literal/quantizeToF16/e8fd14.wgsl.expected.msl index 3c4a55b10a..cef9dc20e5 100644 --- a/test/tint/builtins/gen/literal/quantizeToF16/e8fd14.wgsl.expected.msl +++ b/test/tint/builtins/gen/literal/quantizeToF16/e8fd14.wgsl.expected.msl @@ -2,7 +2,7 @@ using namespace metal; void quantizeToF16_e8fd14() { - float3 res = float3(half3(float3(1.0f))); + float3 res = float3(1.0f); } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/quantizeToF16/e8fd14.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/quantizeToF16/e8fd14.wgsl.expected.spvasm index af5c62d3ce..83f18452b2 100644 --- a/test/tint/builtins/gen/literal/quantizeToF16/e8fd14.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/literal/quantizeToF16/e8fd14.wgsl.expected.spvasm @@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 48 +; Bound: 32 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -12,8 +12,6 @@ OpExecutionMode %compute_main LocalSize 1 1 1 OpName %value "value" OpName %vertex_point_size "vertex_point_size" - OpName %tint_quantizeToF16 "tint_quantizeToF16" - OpName %v "v" OpName %quantizeToF16_e8fd14 "quantizeToF16_e8fd14" OpName %res "res" OpName %vertex_main_inner "vertex_main_inner" @@ -30,57 +28,39 @@ %_ptr_Output_float = OpTypePointer Output %float %8 = OpConstantNull %float %vertex_point_size = OpVariable %_ptr_Output_float Output %8 - %v3float = OpTypeVector %float 3 - %9 = OpTypeFunction %v3float %v3float - %uint = OpTypeInt 32 0 - %16 = OpConstantNull %uint - %uint_1 = OpConstant %uint 1 - %uint_2 = OpConstant %uint 2 %void = OpTypeVoid - %25 = OpTypeFunction %void + %9 = OpTypeFunction %void + %v3float = OpTypeVector %float 3 %float_1 = OpConstant %float 1 - %31 = OpConstantComposite %v3float %float_1 %float_1 %float_1 + %15 = OpConstantComposite %v3float %float_1 %float_1 %float_1 %_ptr_Function_v3float = OpTypePointer Function %v3float - %34 = OpConstantNull %v3float - %35 = OpTypeFunction %v4float -%tint_quantizeToF16 = OpFunction %v3float None %9 - %v = OpFunctionParameter %v3float - %13 = OpLabel - %17 = OpCompositeExtract %float %v 0 - %14 = OpQuantizeToF16 %float %17 - %20 = OpCompositeExtract %float %v 1 - %18 = OpQuantizeToF16 %float %20 - %23 = OpCompositeExtract %float %v 2 - %21 = OpQuantizeToF16 %float %23 - %24 = OpCompositeConstruct %v3float %14 %18 %21 - OpReturnValue %24 - OpFunctionEnd -%quantizeToF16_e8fd14 = OpFunction %void None %25 - %28 = OpLabel - %res = OpVariable %_ptr_Function_v3float Function %34 - %29 = OpFunctionCall %v3float %tint_quantizeToF16 %31 - OpStore %res %29 + %18 = OpConstantNull %v3float + %19 = OpTypeFunction %v4float +%quantizeToF16_e8fd14 = OpFunction %void None %9 + %12 = OpLabel + %res = OpVariable %_ptr_Function_v3float Function %18 + OpStore %res %15 OpReturn OpFunctionEnd -%vertex_main_inner = OpFunction %v4float None %35 - %37 = OpLabel - %38 = OpFunctionCall %void %quantizeToF16_e8fd14 +%vertex_main_inner = OpFunction %v4float None %19 + %21 = OpLabel + %22 = OpFunctionCall %void %quantizeToF16_e8fd14 OpReturnValue %5 OpFunctionEnd -%vertex_main = OpFunction %void None %25 - %40 = OpLabel - %41 = OpFunctionCall %v4float %vertex_main_inner - OpStore %value %41 +%vertex_main = OpFunction %void None %9 + %24 = OpLabel + %25 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %25 OpStore %vertex_point_size %float_1 OpReturn OpFunctionEnd -%fragment_main = OpFunction %void None %25 - %43 = OpLabel - %44 = OpFunctionCall %void %quantizeToF16_e8fd14 +%fragment_main = OpFunction %void None %9 + %27 = OpLabel + %28 = OpFunctionCall %void %quantizeToF16_e8fd14 OpReturn OpFunctionEnd -%compute_main = OpFunction %void None %25 - %46 = OpLabel - %47 = OpFunctionCall %void %quantizeToF16_e8fd14 +%compute_main = OpFunction %void None %9 + %30 = OpLabel + %31 = OpFunctionCall %void %quantizeToF16_e8fd14 OpReturn OpFunctionEnd diff --git a/webgpu-cts/expectations.txt b/webgpu-cts/expectations.txt index cdb6e7f5ec..38de05ec59 100644 --- a/webgpu-cts/expectations.txt +++ b/webgpu-cts/expectations.txt @@ -351,7 +351,6 @@ crbug.com/dawn/0000 [ win10 ] webgpu:shader,execution,expression,call,builtin,in crbug.com/dawn/0000 [ win10 ] webgpu:shader,execution,expression,call,builtin,insertBits:integer:inputSource="uniform";signed=true;width=2 [ Failure ] crbug.com/dawn/0000 [ win10 ] webgpu:shader,execution,expression,call,builtin,insertBits:integer:inputSource="uniform";signed=true;width=3 [ Failure ] crbug.com/dawn/0000 [ win10 ] webgpu:shader,execution,expression,call,builtin,insertBits:integer:inputSource="uniform";signed=true;width=4 [ Failure ] -crbug.com/dawn/0000 webgpu:shader,execution,expression,call,builtin,quantizeToF16:* [ Failure ] crbug.com/dawn/0000 [ win10 ] webgpu:shader,execution,expression,call,builtin,sign:f32:inputSource="storage_r";vectorize="_undef_" [ Failure ] crbug.com/dawn/0000 [ win10 ] webgpu:shader,execution,expression,call,builtin,sign:f32:inputSource="storage_r";vectorize=2 [ Failure ] crbug.com/dawn/0000 [ win10 ] webgpu:shader,execution,expression,call,builtin,sign:f32:inputSource="storage_r";vectorize=3 [ Failure ]