Skip to content

Commit

Permalink
feat: update math type
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Pollind <[email protected]>
  • Loading branch information
pollend committed Aug 6, 2024
1 parent 45a68e4 commit 6bd203c
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 53 deletions.
72 changes: 51 additions & 21 deletions Forge/Math/Internal/ScalarTypes.h
Original file line number Diff line number Diff line change
@@ -1,46 +1,76 @@
#pragma once
#ifndef TF_MATH_INTERNAL_SCALAR_TYPES_H
#define TF_MATH_INTERNAL_SCALAR_TYPES_H
#include <cstdint>
#include "Forge/TF_Types.h"


struct float4
{
struct Tf32x4_s {
union
{
struct
{
float x, y, z, w;
};
struct
{
float r, g, b, a;
};
float v[4];
};
};
TF_COMPILE_ASSERT(sizeof(struct Tf32x4_s) == 4 * 4);

struct float4x1 {
float4 mCol0;
};
struct Tf32x3_s {
union
{
struct
{
float x, y, z;
};
struct
{
float r, g, b;
};
float v[3];
};

struct float4x2
{
float4 mCol0;
float4 mCol1;
};
TF_COMPILE_ASSERT(sizeof(struct Tf32x3_s) == 3 * 4);

struct float4x3
{
float4 mCol0;
float4 mCol1;
float4 mCol2;
struct Tf64x4_s{
union
{
struct
{
double x, y, z, w;
};
double v[4];
};
};
TF_COMPILE_ASSERT(sizeof(struct Tf64x4_s) == 8 * 4);

struct float4x4
{
struct Tu8x3_s {
union
{
struct
{
uint8_t x, y, z;
};
uint8_t v[3];
};

float4 mCol0;
float4 mCol1;
float4 mCol2;
float4 mCol3;
};

struct Tf64x3_s{
union
{
struct
{
double x, y, z;
};
double v[3];
};
};

struct half
{
Expand Down
6 changes: 6 additions & 0 deletions Forge/Math/TF_Math.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#include "TF_Types.h"

static const float TF_PI = 3.14159265358979323846f;
static const float TF_TAU = 6.283185307179586476925f; //!< pi*2 constant
static const float TF_HALF_PI = 1.570796326794896619231f; //!< pi/2 constant

31 changes: 1 addition & 30 deletions Forge/Math/TF_Scalar.h
Original file line number Diff line number Diff line change
@@ -1,33 +1,4 @@
static const float TF_PI = 3.14159265358979323846f;
static const float TF_TAU = 6.283185307179586476925f; //!< pi*2 constant
static const float TF_HALF_PI = 1.570796326794896619231f; //!< pi/2 constant
#include "Internal/ScalarTypes.h"

struct float2
{
};

struct float2x3
{
};

struct float2x4
{
};

struct float3
{
};

struct float3x2
{
};

struct float3x3
{
};

struct float3x4
{
};


3 changes: 3 additions & 0 deletions Forge/Math/TF_Types.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#include "Internal/SimdTypes.h"
#include "Internal/ScalarTypes.h"

Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ load(
"@prelude//cxx:comp_db.bzl",
"CxxCompilationDbInfo",
)
load("@prelude//:paths.bzl", "paths")
load("@prelude//paths.bzl", "paths")

def _gen_compile_command(ctx: BxlContext) -> None:
Expand Down
15 changes: 14 additions & 1 deletion Forge/build_defs/package_app.bzl
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@

load("@prelude//paths.bzl", "paths")
load(
"@prelude//linking:shared_libraries.bzl",
"merge_shared_libraries",
)

def _package_app(ctx: AnalysisContext) -> list[Provider]:
artifacts = []
Expand All @@ -16,13 +20,22 @@ def _package_app(ctx: AnalysisContext) -> list[Provider]:
dest = ctx.actions.declare_output(paths.join(res[0], f.short_path))
artifacts.append(dest)
ctx.actions.copy_file(dest, f)


#for shared_dep in ctx.attrs.cxx_shared_deps:
# extra_shared_libs = traverse_shared_library_info(
# merge_shared_libraries(
# actions = ctx.actions,
# deps = [dep.get(SharedLibraryInfo) for dep in shared_dep],
# ),
# )

return [DefaultInfo(default_outputs = artifacts)]


package_app = rule(
impl = _package_app,
attrs = {
#"cxx_shared_deps": attrs.list(attrs.dep()),
"resources": attrs.list(attrs.tuple(attrs.string(),attrs.dep()), default = []),
"files": attrs.named_set(attrs.source(), sorted = True, default = [])
},
Expand Down

0 comments on commit 6bd203c

Please sign in to comment.