Skip to content

Commit

Permalink
Add matrix constructors from floatN vectors for square matrices
Browse files Browse the repository at this point in the history
  • Loading branch information
redorav committed May 16, 2020
1 parent 0639b21 commit 1b9b62b
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions include/hlsl++_matrix_float.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,8 @@ namespace hlslpp

explicit hlslpp_inline float2x2(float f) : vec(_hlslpp_set1_ps(f)) {}

hlslpp_inline float2x2(const float2& f1, const float2& f2) : vec(_hlslpp_shuf_xyxy_ps(f1.vec, f2.vec)) {}

hlslpp_inline float2x2(const float2x2& m) : vec(m.vec) {}

union
Expand Down Expand Up @@ -291,6 +293,8 @@ namespace hlslpp

hlslpp_inline float3x3(const float3x3& m) : vec0(m.vec0), vec1(m.vec1), vec2(m.vec2) {}

hlslpp_inline float3x3(const float3& f1, const float3& f2, const float3& f3) : vec0(f1.vec), vec1(f2.vec), vec2(f3.vec) {}

static const float3x3& identity() { static const float3x3 iden = float3x3(1, 0, 0, 0, 1, 0, 0, 0, 1); return iden; }

union
Expand Down Expand Up @@ -407,6 +411,9 @@ namespace hlslpp

explicit hlslpp_inline float4x4(float f) : vec0(_hlslpp256_set1_ps(f)), vec1(_hlslpp256_set1_ps(f)) {}

hlslpp_inline float4x4(const float4& f1, const float4& f2, const float4& f3, const float4& f4)
: vec0(_hlslpp256_set128_ps(f1.vec, f2.vec)), vec1(_hlslpp256_set128_ps(f3.vec, f4.vec)) {}

hlslpp_inline float4x4(const float4x4& m) : vec0(m.vec0), vec1(m.vec1) {}

union
Expand Down Expand Up @@ -478,6 +485,8 @@ namespace hlslpp

explicit hlslpp_inline float4x4(float f) : vec0(_hlslpp_set1_ps(f)), vec1(_hlslpp_set1_ps(f)), vec2(_hlslpp_set1_ps(f)), vec3(_hlslpp_set1_ps(f)) {}

hlslpp_inline float4x4(const float4& f1, const float4& f2, const float4& f3, const float4& f4) : vec0(f1.vec), vec1(f2.vec), vec2(f3.vec), vec3(f4.vec) {}

hlslpp_inline float4x4(const float4x4& m) : vec0(m.vec0), vec1(m.vec1), vec2(m.vec2), vec3(m.vec3) {}

union
Expand Down

0 comments on commit 1b9b62b

Please sign in to comment.