Closed devshgraphicsprogramming closed 1 year ago
You can use the following typedefs for quick testing the engine without replacing occurences in every file
#define _IRR_LEGACY_VEC_TYPE_
#ifdef _IRR_LEGACY_VEC_TYPE_
typedef uvec4 vectorSIMDu32;
typedef ivec4 vectorSIMDi32;
//! Typedef for an integer 3d vector.
typedef vectorSIMDu32 vector4du32_SIMD;
typedef vectorSIMDu32 vector3du32_SIMD;
typedef vectorSIMDu32 vector2du32_SIMD;
typedef vectorSIMDi32 vector4di32_SIMD;
typedef vectorSIMDi32 vector3di32_SIMD;
typedef vectorSIMDi32 vector2di32_SIMD;
typedef vec4 vector4df_SIMD;
typedef vec4 vector3df_SIMD;
typedef vec4 vector2df_SIMD;
#endif
In a later phase of the PR you can use (but not yet cause I fear that some code may assume that vec2=vec3=vec4)
#define _IRR_LEGACY_VEC_TYPE_
#ifdef _IRR_LEGACY_VEC_TYPE_
//! Typedef for an integer 3d vector.
typedef uvec4 vector4du32_SIMD;
typedef uvec3 vector3du32_SIMD;
typedef uvec2 vector2du32_SIMD;
typedef ivec4 vector4di32_SIMD;
typedef ivec3 vector3di32_SIMD;
typedef ivec2 vector2di32_SIMD;
typedef vec4 vector4df_SIMD;
typedef vec3 vector3df_SIMD;
typedef vec2 vector2df_SIMD;
#endif
Lib MIME has public domain implementations of logarithmic and trigonometric functions (if we want parity with glsl)
best approach https://t0rakka.silvrback.com/simd-scalar-accessor
going to use https://github.com/redorav/hlslpp
Then the following for missing free functions (transcendentals) etc:
See #209 as well
The idea is to move a lot of stuff from
vectorSIMD.h
to many headers (and finally have them sitting ininclude/irr/core/math
)Allowed tech: SSE4.2 and NEON.
Changes to do:
Curiously Recurring Template Parameter
liberallyLoose spec:
alignas
) vector class to nearest power of twoIdeas for implementation:
Note that the base class is "zero sized" and depends on a CRTP parameter.
We will need a basic bit-field class like we have right now for expressing non-int things such as &,^,~,|, etc. but no bitshifts (that's sign value dependent)
Then certain
T
-specific operators and member functions could be implemented in derivations, likeT=some integer type
orT=some floating point type
This could get even more specific for example for
T=unsigned
vsT=signed
, orT=float
vsT=double
For ensuring the vector's choice of dimension and type can be represented another class can be used.
You will have to provide a constexpr template specialization of
findMSB
.Finally specific "instantiable" vectors could be forward declared
and the methods (but not the members) implemented like this with partial-template-specialization (note: in this example "single float" means single precision float, as opposed to a double)
Doing it this way saves a lot of duplicate code, since members are declared separately, we don't need a separate class and union declaration for every
T
, just for every dimension count.The upside of implementing it all like this, is that the SSE4.2 or NEON intrinsics code does not need to be complete for every function/operator and can get filled in (implemented) over time.
All the GLSL functions like
fract
,mix
, etc. can be implemented as templates, i.e.With explicit specializations as definitions later on that contain as little SSE/NEON as possible.
The vec3 type (non power of two dimensions) are actually going to be defined as restricted versions of their next power-of-two sized vector (for alignment reasons). So in GLSL with std140 packing a vec3 is actually a vec4 but it just has a different type.
Lastly the {i,u,d}vec[5,6,7,8] vectors should just be defined as