mirror of
https://github.com/guezoloic/t3dsr.git
synced 2026-01-25 12:34:24 +00:00
fix: ensure code to compile correctly with MSVC
This commit is contained in:
@@ -15,11 +15,11 @@ Vec3f_t vec3f(float x, float y, float z)
|
|||||||
return (Vec3f_t){.x = x, .y = y, .z = z};
|
return (Vec3f_t){.x = x, .y = y, .z = z};
|
||||||
}
|
}
|
||||||
|
|
||||||
Vec3f_t vec3f_from_array(const float *__restrict val)
|
Vec3f_t vec3f_from_array(const float *restrict val)
|
||||||
{
|
{
|
||||||
Vec3f_t vec;
|
Vec3f_t vec;
|
||||||
#if defined (SIMD_X86)
|
#if defined (SIMD_X86)
|
||||||
__m128 arr = _mm_loadu_ps(val);
|
__m128 arr = _mm_load_ps(val);
|
||||||
_mm_store_ps(vec.data, arr);
|
_mm_store_ps(vec.data, arr);
|
||||||
#elif defined (SIMD_ARCH)
|
#elif defined (SIMD_ARCH)
|
||||||
float32x4_t arr = vld1q_f32(val);
|
float32x4_t arr = vld1q_f32(val);
|
||||||
@@ -54,7 +54,7 @@ Vec3f_t vec3f_zero(void)
|
|||||||
return vec3f_scalar(0.f);
|
return vec3f_scalar(0.f);
|
||||||
}
|
}
|
||||||
|
|
||||||
Vec3f_t vec3f_add_r(Vec3f_t *__restrict out, Vec3f_t a)
|
Vec3f_t vec3f_add_r(Vec3f_t *restrict out, Vec3f_t a)
|
||||||
{
|
{
|
||||||
#if defined (SIMD_X86)
|
#if defined (SIMD_X86)
|
||||||
__m128 va = _mm_load_ps(a.data);
|
__m128 va = _mm_load_ps(a.data);
|
||||||
@@ -79,7 +79,7 @@ Vec3f_t vec3f_add(Vec3f_t a, Vec3f_t b)
|
|||||||
return vec3f_add_r(&a, b);
|
return vec3f_add_r(&a, b);
|
||||||
}
|
}
|
||||||
|
|
||||||
Vec3f_t vec3f_sub_r(Vec3f_t *__restrict out, Vec3f_t a)
|
Vec3f_t vec3f_sub_r(Vec3f_t *restrict out, Vec3f_t a)
|
||||||
{
|
{
|
||||||
#if defined (SIMD_X86)
|
#if defined (SIMD_X86)
|
||||||
__m128 va = _mm_load_ps(out->data);
|
__m128 va = _mm_load_ps(out->data);
|
||||||
@@ -104,7 +104,7 @@ Vec3f_t vec3f_sub(Vec3f_t a, Vec3f_t b)
|
|||||||
return vec3f_sub_r(&a, b);
|
return vec3f_sub_r(&a, b);
|
||||||
}
|
}
|
||||||
|
|
||||||
Vec3f_t vec3f_scale_r(Vec3f_t *__restrict out, float scalar)
|
Vec3f_t vec3f_scale_r(Vec3f_t *restrict out, float scalar)
|
||||||
{
|
{
|
||||||
#if defined (SIMD_X86)
|
#if defined (SIMD_X86)
|
||||||
__m128 va = _mm_load_ps(out->data);
|
__m128 va = _mm_load_ps(out->data);
|
||||||
@@ -130,11 +130,11 @@ Vec3f_t vec3f_scale(Vec3f_t a, float scalar)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//Vec3f_t vec3f_add_r(Vec3f_t *__restrict out, Vec3f_t a);
|
//Vec3f_t vec3f_add_r(Vec3f_t *restrict out, Vec3f_t a);
|
||||||
//Vec3f_t vec3f_add(Vec3f_t a, Vec3f_t b);
|
//Vec3f_t vec3f_add(Vec3f_t a, Vec3f_t b);
|
||||||
//
|
//
|
||||||
//Vec3f_t vec3f_sub_r(Vec3f_t *__restrict out, Vec3f_t a);
|
//Vec3f_t vec3f_sub_r(Vec3f_t *restrict out, Vec3f_t a);
|
||||||
//Vec3f_t vec3f_sub(Vec3f_t a, Vec3f_t b);
|
//Vec3f_t vec3f_sub(Vec3f_t a, Vec3f_t b);
|
||||||
//
|
//
|
||||||
//Vec3f_t vec3f_scale_r(Vec3f_t *__restrict out, float scale);
|
//Vec3f_t vec3f_scale_r(Vec3f_t *restrict out, float scale);
|
||||||
//Vec3f_t vec3f_scale(Vec3f_t a, float scale);
|
//Vec3f_t vec3f_scale(Vec3f_t a, float scale);
|
||||||
|
|||||||
@@ -8,31 +8,37 @@
|
|||||||
#ifndef vec3_h
|
#ifndef vec3_h
|
||||||
#define vec3_h
|
#define vec3_h
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#define ALIGN16 __declspec(align(16))
|
||||||
|
#else
|
||||||
|
#define ALIGN16 __attribute__((aligned(16)))
|
||||||
|
#endif
|
||||||
|
|
||||||
typedef union
|
typedef union
|
||||||
{
|
{
|
||||||
struct {float x, y, z; };
|
struct {float x, y, z; };
|
||||||
float data[4];
|
float data[4];
|
||||||
} __attribute__((aligned(16))) Vec3f_t;
|
} ALIGN16 Vec3f_t;
|
||||||
|
|
||||||
Vec3f_t vec3f_from_array(const float *__restrict val);
|
Vec3f_t vec3f_from_array(const float *restrict val);
|
||||||
Vec3f_t vec3f(float x, float y, float z);
|
Vec3f_t vec3f(float x, float y, float z);
|
||||||
// (f, f, f)
|
// (f, f, f)
|
||||||
Vec3f_t vec3f_scalar(float f);
|
Vec3f_t vec3f_scalar(float f);
|
||||||
// (0, 0, 0)
|
// (0, 0, 0)
|
||||||
Vec3f_t vec3f_zero(void);
|
Vec3f_t vec3f_zero(void);
|
||||||
|
|
||||||
inline static Vec3f_t vec3f_clone(const Vec3f_t *__restrict v)
|
inline static Vec3f_t vec3f_clone(const Vec3f_t *restrict v)
|
||||||
{
|
{
|
||||||
return *v;
|
return *v;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vec3f_t vec3f_add_r(Vec3f_t *__restrict out, Vec3f_t a);
|
Vec3f_t vec3f_add_r(Vec3f_t *restrict out, Vec3f_t a);
|
||||||
Vec3f_t vec3f_add(Vec3f_t a, Vec3f_t b);
|
Vec3f_t vec3f_add(Vec3f_t a, Vec3f_t b);
|
||||||
|
|
||||||
Vec3f_t vec3f_sub_r(Vec3f_t *__restrict out, Vec3f_t a);
|
Vec3f_t vec3f_sub_r(Vec3f_t *restrict out, Vec3f_t a);
|
||||||
Vec3f_t vec3f_sub(Vec3f_t a, Vec3f_t b);
|
Vec3f_t vec3f_sub(Vec3f_t a, Vec3f_t b);
|
||||||
|
|
||||||
Vec3f_t vec3f_scale_r(Vec3f_t *__restrict out, float scale);
|
Vec3f_t vec3f_scale_r(Vec3f_t *restrict out, float scale);
|
||||||
Vec3f_t vec3f_scale(Vec3f_t a, float scale);
|
Vec3f_t vec3f_scale(Vec3f_t a, float scale);
|
||||||
|
|
||||||
#endif /* vec3_h */
|
#endif /* vec3_h */
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ Vec4f_t vec4f(float x, float y, float z, float w)
|
|||||||
return (Vec4f_t){.x = x, .y = y, .z = z, .w = w};
|
return (Vec4f_t){.x = x, .y = y, .z = z, .w = w};
|
||||||
}
|
}
|
||||||
|
|
||||||
Vec4f_t vec4f_from_array(const float *__restrict val)
|
Vec4f_t vec4f_from_array(const float *restrict val)
|
||||||
{
|
{
|
||||||
Vec4f_t vec;
|
Vec4f_t vec;
|
||||||
#if defined (SIMD_X86)
|
#if defined (SIMD_X86)
|
||||||
@@ -53,7 +53,7 @@ Vec4f_t vec4f_zero(void)
|
|||||||
return vec4f_scalar(0.f);
|
return vec4f_scalar(0.f);
|
||||||
}
|
}
|
||||||
|
|
||||||
Vec4f_t vec4f_add_r(Vec4f_t *__restrict out, Vec4f_t a)
|
Vec4f_t vec4f_add_r(Vec4f_t *restrict out, Vec4f_t a)
|
||||||
{
|
{
|
||||||
#if defined (SIMD_X86)
|
#if defined (SIMD_X86)
|
||||||
__m128 va = _mm_load_ps(a.data);
|
__m128 va = _mm_load_ps(a.data);
|
||||||
@@ -80,7 +80,7 @@ Vec4f_t vec4f_add(Vec4f_t a, Vec4f_t b)
|
|||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vec4f_t vec4f_sub_r(Vec4f_t *__restrict out, Vec4f_t a)
|
Vec4f_t vec4f_sub_r(Vec4f_t *restrict out, Vec4f_t a)
|
||||||
{
|
{
|
||||||
#if defined (SIMD_X86)
|
#if defined (SIMD_X86)
|
||||||
__m128 va = _mm_load_ps(out->data);
|
__m128 va = _mm_load_ps(out->data);
|
||||||
@@ -108,7 +108,7 @@ Vec4f_t vec4f_sub(Vec4f_t a, Vec4f_t b)
|
|||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vec4f_t vec4f_scale_r(Vec4f_t *__restrict out, float scalar)
|
Vec4f_t vec4f_scale_r(Vec4f_t *restrict out, float scalar)
|
||||||
{
|
{
|
||||||
#if defined (SIMD_X86)
|
#if defined (SIMD_X86)
|
||||||
__m128 va = _mm_load_ps(out->data);
|
__m128 va = _mm_load_ps(out->data);
|
||||||
|
|||||||
@@ -1,31 +1,38 @@
|
|||||||
#ifndef VECTOR4_H
|
#ifndef VECTOR4_H
|
||||||
#define VECTOR4_H
|
#define VECTOR4_H
|
||||||
|
|
||||||
|
#include "vec3.h"
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#define ALIGN16 __declspec(align(16))
|
||||||
|
#else
|
||||||
|
#define ALIGN16 __attribute__((aligned(16)))
|
||||||
|
#endif
|
||||||
|
|
||||||
// must be aligned by 16 Bytes (less instruction executed for SSE)
|
// must be aligned by 16 Bytes (less instruction executed for SSE)
|
||||||
typedef union
|
typedef union
|
||||||
{
|
{
|
||||||
struct { float x, y, z, w; };
|
struct { float x, y, z, w; };
|
||||||
float data[4];
|
float data[4];
|
||||||
}__attribute__((aligned(16))) Vec4f_t;
|
} ALIGN16 Vec4f_t;
|
||||||
|
|
||||||
Vec4f_t vec4f_from_array(const float *__restrict val);
|
Vec4f_t vec4f_from_array(const float *restrict val);
|
||||||
Vec4f_t vec4f(float x, float y, float z, float w);
|
Vec4f_t vec4f(float x, float y, float z, float w);
|
||||||
// (f, f, f, f)
|
// (f, f, f, f)
|
||||||
Vec4f_t vec4f_scalar(float f);
|
Vec4f_t vec4f_scalar(float f);
|
||||||
// (0, 0, 0, 0)
|
// (0, 0, 0, 0)
|
||||||
Vec4f_t vec4f_zero(void);
|
Vec4f_t vec4f_zero(void);
|
||||||
|
|
||||||
inline static Vec4f_t vec4f_clone(const Vec4f_t *__restrict v)
|
inline static Vec4f_t vec4f_clone(const Vec4f_t *restrict v)
|
||||||
{
|
{
|
||||||
return *v;
|
return *v;
|
||||||
}
|
}
|
||||||
Vec4f_t vec4f_add_r(Vec4f_t *__restrict out, Vec4f_t a);
|
Vec4f_t vec4f_add_r(Vec4f_t *restrict out, Vec4f_t a);
|
||||||
Vec4f_t vec4f_add(Vec4f_t a, Vec4f_t b);
|
Vec4f_t vec4f_add(Vec4f_t a, Vec4f_t b);
|
||||||
|
|
||||||
Vec4f_t vec4f_sub_r(Vec4f_t *__restrict out, Vec4f_t a);
|
Vec4f_t vec4f_sub_r(Vec4f_t *restrict out, Vec4f_t a);
|
||||||
Vec4f_t vec4f_sub(Vec4f_t a, Vec4f_t b);
|
Vec4f_t vec4f_sub(Vec4f_t a, Vec4f_t b);
|
||||||
|
|
||||||
Vec4f_t vec4f_scale_r(Vec4f_t *__restrict out, float scale);
|
Vec4f_t vec4f_scale_r(Vec4f_t *restrict out, float scale);
|
||||||
Vec4f_t vec4f_scale(Vec4f_t a, float scale);
|
Vec4f_t vec4f_scale(Vec4f_t a, float scale);
|
||||||
|
|
||||||
float vec4_dot(Vec4f_t a, Vec4f_t b);
|
float vec4_dot(Vec4f_t a, Vec4f_t b);
|
||||||
|
|||||||
Reference in New Issue
Block a user