wip sw renderer...bsp is borked, also lots of other things
This commit is contained in:
parent
415d424057
commit
c771fa665d
56 changed files with 8151 additions and 1261 deletions
|
|
@ -4,16 +4,49 @@
|
|||
|
||||
#include "pxl8_types.h"
|
||||
|
||||
#if defined(__x86_64__) || defined(_M_X64)
|
||||
#include <xmmintrin.h>
|
||||
#elif defined(__aarch64__) || defined(_M_ARM64)
|
||||
#include <arm_neon.h>
|
||||
#endif
|
||||
|
||||
#define PXL8_PI 3.14159265358979323846f
|
||||
#define PXL8_TAU (PXL8_PI * 2.0f)
|
||||
|
||||
static inline f32 pxl8_fast_inv_sqrt(f32 x) {
|
||||
#if defined(__x86_64__) || defined(_M_X64)
|
||||
__m128 v = _mm_set_ss(x);
|
||||
v = _mm_rsqrt_ss(v);
|
||||
return _mm_cvtss_f32(v);
|
||||
#elif defined(__aarch64__) || defined(_M_ARM64)
|
||||
float32x2_t v = vdup_n_f32(x);
|
||||
float32x2_t est = vrsqrte_f32(v);
|
||||
est = vmul_f32(est, vrsqrts_f32(vmul_f32(v, est), est));
|
||||
return vget_lane_f32(est, 0);
|
||||
#else
|
||||
f32 half = 0.5f * x;
|
||||
i32 i = *(i32*)&x;
|
||||
i = 0x5f3759df - (i >> 1);
|
||||
x = *(f32*)&i;
|
||||
x = x * (1.5f - half * x * x);
|
||||
return x;
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline f32 pxl8_fast_rcp(f32 x) {
|
||||
#if defined(__x86_64__) || defined(_M_X64)
|
||||
__m128 v = _mm_set_ss(x);
|
||||
__m128 rcp = _mm_rcp_ss(v);
|
||||
rcp = _mm_add_ss(rcp, _mm_mul_ss(rcp, _mm_sub_ss(_mm_set_ss(1.0f), _mm_mul_ss(v, rcp))));
|
||||
return _mm_cvtss_f32(rcp);
|
||||
#elif defined(__aarch64__) || defined(_M_ARM64)
|
||||
float32x2_t v = vdup_n_f32(x);
|
||||
float32x2_t est = vrecpe_f32(v);
|
||||
est = vmul_f32(est, vrecps_f32(v, est));
|
||||
return vget_lane_f32(est, 0);
|
||||
#else
|
||||
return 1.0f / x;
|
||||
#endif
|
||||
}
|
||||
|
||||
typedef struct pxl8_vec2 {
|
||||
|
|
@ -33,18 +66,27 @@ typedef struct pxl8_mat4 {
|
|||
} pxl8_mat4;
|
||||
|
||||
typedef struct pxl8_plane {
|
||||
pxl8_vec3 normal;
|
||||
f32 distance;
|
||||
pxl8_vec3 normal;
|
||||
} pxl8_plane;
|
||||
|
||||
typedef struct pxl8_frustum {
|
||||
pxl8_plane planes[6];
|
||||
} pxl8_frustum;
|
||||
|
||||
typedef struct pxl8_projected_point {
|
||||
f32 depth;
|
||||
i32 x;
|
||||
i32 y;
|
||||
bool visible;
|
||||
} pxl8_projected_point;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
u32 pxl8_hash32(u32 x);
|
||||
|
||||
pxl8_vec2 pxl8_vec2_add(pxl8_vec2 a, pxl8_vec2 b);
|
||||
f32 pxl8_vec2_dot(pxl8_vec2 a, pxl8_vec2 b);
|
||||
f32 pxl8_vec2_length(pxl8_vec2 v);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue