From 486d2d099c560c9f2dc3a2ffb06481e603bac4d0 Mon Sep 17 00:00:00 2001 From: Stephan Unverwerth Date: Sat, 1 Jan 2022 17:33:09 +0100 Subject: [PATCH] LibSoftGPU: Add SIMD.h with SoftGPU specific SIMD functions Adds functions to expand Vector{2,3,4} to their SIMD equivalent. --- Userland/Libraries/LibSoftGPU/SIMD.h | 70 ++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 Userland/Libraries/LibSoftGPU/SIMD.h diff --git a/Userland/Libraries/LibSoftGPU/SIMD.h b/Userland/Libraries/LibSoftGPU/SIMD.h new file mode 100644 index 0000000000..66ade79d50 --- /dev/null +++ b/Userland/Libraries/LibSoftGPU/SIMD.h @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2021, Stephan Unverwerth + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +#pragma once + +#include +#include +#include +#include + +namespace SoftGPU { + +ALWAYS_INLINE static constexpr Vector2 expand4(Vector2 const& v) +{ + return Vector2 { + AK::SIMD::expand4(v.x()), + AK::SIMD::expand4(v.y()), + }; +} + +ALWAYS_INLINE static constexpr Vector3 expand4(Vector3 const& v) +{ + return Vector3 { + AK::SIMD::expand4(v.x()), + AK::SIMD::expand4(v.y()), + AK::SIMD::expand4(v.z()), + }; +} + +ALWAYS_INLINE static constexpr Vector4 expand4(Vector4 const& v) +{ + return Vector4 { + AK::SIMD::expand4(v.x()), + AK::SIMD::expand4(v.y()), + AK::SIMD::expand4(v.z()), + AK::SIMD::expand4(v.w()), + }; +} + +ALWAYS_INLINE static constexpr Vector2 expand4(Vector2 const& v) +{ + return Vector2 { + AK::SIMD::expand4(v.x()), + AK::SIMD::expand4(v.y()), + }; +} + +ALWAYS_INLINE static constexpr Vector3 expand4(Vector3 const& v) +{ + return Vector3 { + AK::SIMD::expand4(v.x()), + AK::SIMD::expand4(v.y()), + AK::SIMD::expand4(v.z()), + }; +} + +ALWAYS_INLINE static constexpr Vector4 expand4(Vector4 const& v) +{ + return Vector4 { + AK::SIMD::expand4(v.x()), + AK::SIMD::expand4(v.y()), + AK::SIMD::expand4(v.z()), + AK::SIMD::expand4(v.w()), + }; +} + +}