Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: matrix abstraction #13

Merged
merged 13 commits into from
Aug 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,17 @@ BreakAfterJavaFieldAnnotations: false
#BreakArrays: true
BreakBeforeBinaryOperators: None
BreakBeforeConceptDeclarations: true
BreakBeforeBraces: Allman
BreakBeforeBraces: Attach
BraceWrapping:
AfterClass: true
AfterControlStatement: true
AfterEnum: true
AfterFunction: true
AfterNamespace: true
BeforeLambdaBody: true
AfterStruct: true
BeforeElse: true
SplitEmptyFunction: true
#BreakBeforeInlineASMColon: OnlyMultiline
BreakBeforeTernaryOperators: true
BreakConstructorInitializers: AfterColon
Expand Down Expand Up @@ -169,4 +179,3 @@ SpacesInSquareBrackets: false
Standard: Latest
TabWidth: 4
UseTab: Never
...
2 changes: 2 additions & 0 deletions .clangd
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
CompileFlags:
Add: [-D__CLANGD__]
1 change: 1 addition & 0 deletions Forge/BUCK
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ cxx_library(
"Math/**/*.hpp",
"Math/*.h",
"Math/**/*.h",
"Math/**/*.inl",

"Graphics/*.h",
"Graphics/**/*.h",
Expand Down
25 changes: 25 additions & 0 deletions Forge/Math/Internal/ScalarTypes.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#pragma once
#ifndef TF_MATH_INTERNAL_SCALAR_TYPES_H
#define TF_MATH_INTERNAL_SCALAR_TYPES_H


struct float4
Expand All @@ -12,6 +15,10 @@ struct float4
};
};

struct float4x1 {
float4 mCol0;
};

struct float4x2
{
float4 mCol0;
Expand All @@ -35,3 +42,21 @@ struct float4x4
};


struct half
{
};

struct half2
{
};

struct half3
{
};

struct half4
{
};

#endif

195 changes: 163 additions & 32 deletions Forge/Math/Internal/SimdTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include "Forge/TF_Config.h"
#include "Forge/TF_Types.h"
#include <cmath>

#if defined(TF_FEATURE_CPU_SSE)
#include <xmmintrin.h>
Expand All @@ -17,14 +18,14 @@
#define TF_SIMDI_MAX 0xFFFFFFFF
#define TF_SIMDF_MAX 0xFFFFFFFF

typedef __m128 TSimdf32x4;
typedef __m128i TSimdi32x4;
typedef __m128 Tsimd_f32x4_t;
typedef __m128i Tsimd_i32x4_t;

typedef __m128 TSimdf32x3;
typedef __m128i TSimdi32x3;
typedef __m128 Tsimd_f32x3_t;
typedef __m128i Tsimd_i32x3_t;

typedef __m128 TSimdf32x2;
typedef __m128i TSimdi32x2;
typedef __m128 Tsimd_f32x2_t;
typedef __m128i Tsimd_i32x2_t;
#elif defined(TF_FEATURE_CPU_NEON)
#include <arm_neon.h>

Expand All @@ -33,14 +34,14 @@

#define TF_SIMDI_MAX 0xFFFFFFFF

typedef float32x4_t TSimdf32x4;
typedef int32x4_t TSimdi32x4;
typedef float32x4_t Tsimd_f32x4_t;
typedef int32x4_t Tsimd_i32x4_t;

typedef float32x4_t TSimdf32x3;
typedef int32x4_t TSimdi32x3;
typedef float32x4_t Tsimd_f32x3_t;
typedef int32x4_t Tsimd_i32x3_t;

typedef float32x2_t TSimdf32x2;
typedef int32x2_t TSimdi32x2;
typedef float32x2_t Tsimd_f32x2_t;
typedef int32x2_t Tsimd_i32x2_t;
#elif defined(TF_FEATURE_CPU_SCALAR)
#include <cmath>

Expand All @@ -49,41 +50,171 @@

#define TF_SIMDI_MAX 0xFFFFFFFF

typedef struct { float v[4]; } TSimdf32x4;
typedef struct { int32_t v[4]; } TSimdi32x4;
typedef struct { float v[4]; } Tsimd_f32x4_t;
typedef struct { int32_t v[4]; } Tsimd_i32x4_t;

typedef struct { float v[3]; } TSimdf32x3;
typedef struct { int32_t v[3]; } TSimdi32x3;
typedef struct { float v[3]; } Tsimd_f32x3_t;
typedef struct { int32_t v[3]; } Tsimd_i32x3_t;

typedef struct { float v[2]; } TSimdf32x2;
typedef struct { int32_t v[2]; } TSimdi32x2;
typedef struct { float v[2]; } Tsimd_f32x2_t;
typedef struct { int32_t v[2]; } Tsimd_i32x2_t;
#endif

struct simd_float4
typedef Tsimd_f32x4_t Tsimd_quat_f32x4_t;

struct Tsimd_f32x4x4_s {
union {
struct {
Tsimd_f32x4_t mCol0;
Tsimd_f32x4_t mCol1;
Tsimd_f32x4_t mCol2;
Tsimd_f32x4_t mCol3;
};
Tsimd_f32x4_t mCol[4];
};
};

struct Tsimd_f32x4x3_s {
union {
struct {
Tsimd_f32x4_t mCol0;
Tsimd_f32x4_t mCol1;
Tsimd_f32x4_t mCol2;
};
Tsimd_f32x4_t mCol[3];
};
};

struct Tsimd_f32x4x2_s {
union {
struct {
Tsimd_f32x4_t mCol0;
Tsimd_f32x4_t mCol1;
};
Tsimd_f32x4_t mCol[2];
};
};


// deprecate anything past this
// -------------------------------------------------------
//
struct TSimdFloat4x1 {
union
{
struct
{
Tsimd_f32x4_t mCol0;
};
Tsimd_f32x4_t mCol[1];
};
};

struct TSimdFloat4x2
{
union
{
struct
{
Tsimd_f32x4_t mCol0;
Tsimd_f32x4_t mCol1;
};
Tsimd_f32x4_t mCol[2];
};
};

struct TSimdFloat4x3 {
union {
struct {
Tsimd_f32x4_t mCol0;
Tsimd_f32x4_t mCol1;
Tsimd_f32x4_t mCol2;
};
Tsimd_f32x4_t mCol[3];
};
};

struct TSimdFloat4x4
{
TSimdf32x4 mCol0;
union
{
struct
{
Tsimd_f32x4_t mCol0;
Tsimd_f32x4_t mCol1;
Tsimd_f32x4_t mCol2;
Tsimd_f32x4_t mCol3;
};
Tsimd_f32x4_t mCol[4];
};
};

struct simd_float4x2
struct TSimdFloat3
{
TSimdf32x4 mCol0;
TSimdf32x4 mCol1;
Tsimd_f32x3_t mRow;
};

struct TSimdFloat3x1 {
union {
struct {
Tsimd_f32x3_t mCol0;
};
Tsimd_f32x3_t mCol[1];
};
};

struct simd_float4x3
struct TSimdFloat3x2
{
TSimdf32x4 mCol0;
TSimdf32x4 mCol1;
TSimdf32x4 mCol2;
union
{
struct
{
Tsimd_f32x3_t mCol0;
Tsimd_f32x3_t mCol1;
};
Tsimd_f32x3_t mCol[2];
};
};

struct simd_float4x4
struct TSimdFloat3x3
{
TSimdf32x4 mCol0;
TSimdf32x4 mCol1;
TSimdf32x4 mCol2;
TSimdf32x4 mCol3;
union
{
struct
{
Tsimd_f32x3_t mCol0;
Tsimd_f32x3_t mCol1;
Tsimd_f32x3_t mCol2;
};
Tsimd_f32x3_t mCol[3];
};
};

struct TSimdFloat2 {
Tsimd_f32x2_t mRow;
};

struct TSimdFloat2x1
{
union {
struct {
Tsimd_f32x2_t mCol0;
};
Tsimd_f32x2_t mCol[1];
};
};

struct TSimdFloat2x2
{
union {
struct {
Tsimd_f32x2_t mCol0;
Tsimd_f32x2_t mCol1;
};
Tsimd_f32x2_t mCol[2];
};
};



#endif
Loading
Loading