mirror of
https://github.com/bkaradzic/bx.git
synced 2026-06-08 03:03:48 +00:00
Added float4x4_inverse test. (#391)
* Added float4x4_inverse test. * Bump tolerance. * Fixed broadcast bug in simd128_f32_dot_ni.
This commit is contained in:
committed by
GitHub
parent
c8f135d579
commit
6bb55b32eb
@@ -419,8 +419,8 @@ namespace bx
|
||||
const Ty xyzw = simd_f32_mul(_a, _b);
|
||||
const Ty zwxy = simd128_x32_swiz_zwxy(xyzw);
|
||||
const Ty tmp0 = simd_f32_add(xyzw, zwxy);
|
||||
const Ty yyyy = simd128_x32_swiz_yyyy(tmp0);
|
||||
const Ty result = simd_f32_add(tmp0, yyyy);
|
||||
const Ty yxwz = simd128_x32_swiz_yxwz(tmp0);
|
||||
const Ty result = simd_f32_add(tmp0, yxwz);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
46
tests/float4x4_test.cpp
Normal file
46
tests/float4x4_test.cpp
Normal file
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright 2010-2026 Branimir Karadzic. All rights reserved.
|
||||
* License: https://github.com/bkaradzic/bx/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
#include "test.h"
|
||||
#include <bx/float4x4_t.h>
|
||||
#include <bx/math.h>
|
||||
#include <bx/string.h>
|
||||
|
||||
TEST_CASE("float4x4_inverse", "[float4x4]")
|
||||
{
|
||||
const float src[] =
|
||||
{
|
||||
1.20629f, 0.0f, 0.0f, 0.0f,
|
||||
0.0f, 2.14451f, 0.0f, 0.0f,
|
||||
0.0f, 0.0f, -1.00001f, -1.0f,
|
||||
0.0f, 0.0f, -2.00001f, 0.0f,
|
||||
};
|
||||
static_assert(BX_COUNTOF(src) == 16);
|
||||
|
||||
bx::float4x4_t mtx;
|
||||
mtx.col[0] = bx::simd128_ld(src[ 0], src[ 1], src[ 2], src[ 3]);
|
||||
mtx.col[1] = bx::simd128_ld(src[ 4], src[ 5], src[ 6], src[ 7]);
|
||||
mtx.col[2] = bx::simd128_ld(src[ 8], src[ 9], src[10], src[11]);
|
||||
mtx.col[3] = bx::simd128_ld(src[12], src[13], src[14], src[15]);
|
||||
|
||||
bx::float4x4_t inv;
|
||||
bx::float4x4_inverse(&inv, &mtx);
|
||||
|
||||
float ref[16];
|
||||
bx::mtxInverse(ref, src);
|
||||
|
||||
BX_ALIGN_DECL_16(float) result[16];
|
||||
bx::simd128_st(&result[ 0], inv.col[0]);
|
||||
bx::simd128_st(&result[ 4], inv.col[1]);
|
||||
bx::simd128_st(&result[ 8], inv.col[2]);
|
||||
bx::simd128_st(&result[12], inv.col[3]);
|
||||
|
||||
for (uint32_t ii = 0; ii < 16; ++ii)
|
||||
{
|
||||
const float diff = bx::abs(result[ii] - ref[ii]);
|
||||
INFO("ii=" << ii << " result=" << result[ii] << " ref=" << ref[ii] << " diff=" << diff);
|
||||
CHECK(bx::isEqual(result[ii], ref[ii], 0.0001f) );
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user