mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 00:47:45 +00:00
LibSoftGPU: Add SIMD.h with SoftGPU specific SIMD functions
Adds functions to expand Vector{2,3,4} to their SIMD equivalent.
This commit is contained in:
parent
7adcdecc7b
commit
486d2d099c
1 changed files with 70 additions and 0 deletions
70
Userland/Libraries/LibSoftGPU/SIMD.h
Normal file
70
Userland/Libraries/LibSoftGPU/SIMD.h
Normal file
|
@ -0,0 +1,70 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2021, Stephan Unverwerth <s.unverwerth@serenityos.org>
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <AK/SIMDExtras.h>
|
||||||
|
#include <LibGfx/Vector2.h>
|
||||||
|
#include <LibGfx/Vector3.h>
|
||||||
|
#include <LibGfx/Vector4.h>
|
||||||
|
|
||||||
|
namespace SoftGPU {
|
||||||
|
|
||||||
|
ALWAYS_INLINE static constexpr Vector2<AK::SIMD::f32x4> expand4(Vector2<float> const& v)
|
||||||
|
{
|
||||||
|
return Vector2<AK::SIMD::f32x4> {
|
||||||
|
AK::SIMD::expand4(v.x()),
|
||||||
|
AK::SIMD::expand4(v.y()),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
ALWAYS_INLINE static constexpr Vector3<AK::SIMD::f32x4> expand4(Vector3<float> const& v)
|
||||||
|
{
|
||||||
|
return Vector3<AK::SIMD::f32x4> {
|
||||||
|
AK::SIMD::expand4(v.x()),
|
||||||
|
AK::SIMD::expand4(v.y()),
|
||||||
|
AK::SIMD::expand4(v.z()),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
ALWAYS_INLINE static constexpr Vector4<AK::SIMD::f32x4> expand4(Vector4<float> const& v)
|
||||||
|
{
|
||||||
|
return Vector4<AK::SIMD::f32x4> {
|
||||||
|
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<AK::SIMD::i32x4> expand4(Vector2<int> const& v)
|
||||||
|
{
|
||||||
|
return Vector2<AK::SIMD::i32x4> {
|
||||||
|
AK::SIMD::expand4(v.x()),
|
||||||
|
AK::SIMD::expand4(v.y()),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
ALWAYS_INLINE static constexpr Vector3<AK::SIMD::i32x4> expand4(Vector3<int> const& v)
|
||||||
|
{
|
||||||
|
return Vector3<AK::SIMD::i32x4> {
|
||||||
|
AK::SIMD::expand4(v.x()),
|
||||||
|
AK::SIMD::expand4(v.y()),
|
||||||
|
AK::SIMD::expand4(v.z()),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
ALWAYS_INLINE static constexpr Vector4<AK::SIMD::i32x4> expand4(Vector4<int> const& v)
|
||||||
|
{
|
||||||
|
return Vector4<AK::SIMD::i32x4> {
|
||||||
|
AK::SIMD::expand4(v.x()),
|
||||||
|
AK::SIMD::expand4(v.y()),
|
||||||
|
AK::SIMD::expand4(v.z()),
|
||||||
|
AK::SIMD::expand4(v.w()),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue