by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
sibest
@sibest
those forced (Float) cast
?
Hugh Sanderson
@hughsando
I think the main reason to use float32 is for storage. Half the size is much better - especially in arrays. But as for calculations, I do not think this is going to be any measurable speedup unless you have some kind of SIMD optimization. But in that case, you really want float32x4 variables or similar, not float32. A lot of c++ calling convention will upgrade a float32 to a float64, perform a calculation, and convert it back. So float32 can be slower. I would recommend writing some naitve c++ code to see the type of speedups you might get and see if its worth it. That said, using explicit arrays for float32 is a pretty easy and worthwhile thing to do. Maybe some structure, like "Point" that you have a lot of might be worth having a f32 version but I think it is borderline.
sibest
@sibest
Well I ended up keeping double precision but replacing all array<float> and vector<float> with float32
I did a brutal replace in my entite project, in lime and openfl
And surprisingly it worked flawlessy
I’ve also rewritten some part of openfl and lime to directly send the vertexbuffers into the gpu without making copies
Gabriel Hayes
@piboistudios
Poking at hscript for a game. Maybe I just never looked at the bottom of the README but seems there was a lot of cool stuff I didn't know about.
But what are events?
For the hscript.Checker
Gabriel Hayes
@piboistudios
Also what is hscript.Async.toAsync(?topLevelSync:Bool)
nanjizal
@nanjizal
@sibest can you clarify: array<float> and vector<float> with float32
Have you swapped 'Float' in your code for something else?
sibest
@sibest
@nanjizal My solution works only for cpp target
typedef Float32Vector = openfl.Vector<Float32>;
openfl.Vector is a typedef of Array<
in the cpp target
typedef Float32Vector = Array<Float32>;
then replace every openfl.Vector<Float> and Array<Float> with Float32Vector
backup first
nanjizal
@nanjizal
I am not directly using openfl.Vector
I am using Float32Array
weird error were float1 - float2 crashes
sibest
@sibest
float1 - float2 crashes ?
Haxe does a forced cast to double to every math operation
it's useless to use Float32 for local or class vars
u
I'm using Float32 in array of float to improve memory usage plus directly send vertexbuffers to the gp
You can force Hxcpp to use Float32 instead of double with the haxeflag HXCPP_FLOAT32
the problem is, it will force every math operation to (float)
sibest
@sibest
for example UInt32 a = 0xFF000000; UInt32 b = 0x100; UInt32 c = a/b; Haxe will generate the absolutely weird cpp code c = (float)((float)a / (float)b)
which obviously will lead to wrong math results for lack of precision
the solution would be to change the cpp generator to avoid forced typecasting
and, the lime library is using Float to send datapointer address, which normally is #define Float double and it's ok
but when you use the 32bit float flag, it will crash, you will need to fix the lime library to use size_t instead of Float for datapointers, but it's an easy fix
nanjizal
@nanjizal
are you on mac?
```static inline 
function dist( px: Float, py: Float, qx: Float, qy: Float  ): Float {
    var x = px - qx; //<-- line 186 failing here!!?
    var y = py - qy;
    return x*x + y*y;
}```
oh I need to change lime?
but I had no joy on nme
only on html lime and webgl js direct
if your on mac I could send you the app to see, it's all online but distributed so unlikely you would want to try.
sibest
@sibest
i'm on windows, but i'm pretty sure it can't crash there
you are using inline functions
you have to disable inline to see the real line number
Hugh Sanderson
@hughsando
Division is defined as double-precision in haxe, so you can't change this output. You could try cpp.NativeMath.idiv( a, b ) or define your own div function.
Given the inline function is failing, it depends on the source or the variables. For example, if you used dist(nullArray[0].x, nullArray[0].y, nullArray[1].x, nullArray[1].y) I would expect a crash like this. If you use a native debugger, it should be easier to work out what is going on.
Gabriel Hayes
@piboistudios
I am surprised no one has written hxnodejs externs for the Google closure-library (it's used in gRPC-web)
Philippe
@elsassph
Maybe because it's huge, and it's using some weird ass google compiler and jsdoc conventions :D
Hmm maybe using the "TS port" https://github.com/DreierF/ts-closure-library
The updated ts2hx tool may be able to handle it
Philippe
@elsassph
I'm wondering how up to date the lib is though