jdelauney / SIMD-VectorMath-UnitTest

For testing asm SIMD (SSE/SSE 2/SSE 3/SSE 4.x / AVX /AVX 2) vector math library (2f, 4f, matrix, quaternion...) with Lazarus and FreePascal Compiler
Mozilla Public License 2.0
8 stars 0 forks source link

Vector and Trigonometric functions #26

Open jdelauney opened 6 years ago

jdelauney commented 6 years ago

According to you, how could we implement these functions with our vector's records ? Inside record ? or out for scalar as simple function like sin/cos ? or Both

I say that because yesterday reading some interesting articles here http://www.iquilezles.org/www/index.htm and go to https://www.shadertoy.com I've play a bit with 2D planar deformation. I started to add some GLSL scalar into GLZMaths. like smoothstep, step... (https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/) this is why ;)

dicepd commented 6 years ago

A lot there on the first ref you gave, which function set are you looking at ?

jdelauney commented 6 years ago

I'm looking for basic like sin, cos, exp, and some non-trigonometric like floor, fract... Actually we have Round and Trunc in TGLZVector2f and 4f. After thinking, Regarding function like : vec2 p = 0.5*sin(vec2(1.1,1.3)*t+vec2(0.0,0.5) ); it will better if we have those function like scalar eg: function Round(V:TGLZVector2f):TGLZVector2i, Sin(V:TGLZVector2f):TGLZVector2f But don't really say if we need keep those in record to

jdelauney commented 6 years ago

It have also Sqrt, InvSqrt. I'd also like to implement a Matrix2f for 2D manipulation

dicepd commented 6 years ago

I still have Ceil and Fract broken in Native

jdelauney commented 6 years ago

Ok i take a look

jdelauney commented 6 years ago

Do you already have Ceil and Fract broke ? The only tests are not really right is InvSqrt but it's normal it's an approximation

dicepd commented 6 years ago

@For Configs Native_CONFIG_1 Native_CONFIG_2 we get the following errors.

Ceil:Sub3 X failed " expected: <-5>; but was: <-4> Fract:Sub3 X failed " expected: <-0.7> but was: <0.3>

So the assembler for these may be passing tests but as the underlying pascal is wrong the assembler will be wrong as well.

jdelauney commented 6 years ago

Ok it's fixed i had left const OnveVector2f to (0,0) and i mimic Native Delphi's code. All is green :)

dicepd commented 6 years ago

Ok I have something strange going on here with native Ceil is somehow getting into GLMath.Floor from TGLZVector2f.Ceil Impossible calll stack below

#0 FLOOR(-5.69999886) at ../UtilsClasses/GLZMath.pas:451
#1 CEIL({V = {-5.69999886, -6.69999886}, X = -5.69999886, Y = -6.69999886, WIDTH = -5.69999886, HEIGHT = -6.69999886}) at ../VectorClasses/vectormath_vector2f_native_imp.inc:247
#2 TESTCEIL(0x7ffff7f943f0) at Vector2fFunctionalTest.pas:626
#3 FPCUNIT$_$TTESTCASE_$__$$_RUNTEST at :0

And at the moment I do not have a clue what is going on.

jdelauney commented 6 years ago

Humm very strange, all ok here with native and sse. Try to remove {$HINTS OFF} .. {$HINTS ON} in function fo see. And remove all compiled file at hand