as to extension I opt for some years just to include some hardware accelerated types as a primitive types in c language
That's what C++ math libraries will give you, such as
GLM, etc... Since C doesn't have operator overloading, you can't do this with just a library
If you want to extend the language with niceties like that, maybe you should mix some C++ into your C code
That example with the isp
C extensions would look like this, where on SSE the
foreach loop will increment by 4 each time and the "
varying float" values are
float4's (
or on AVX the loop increments by 8 each time and the varying float values are float8's).
//export means this function is callable from regular C code:
export void Example( uniform const float aIn[], uniform const float bIn[], uniform const float cIn[], uniform const float dOut[], uniform uint count )
{
//Assuming you've just got 4 values:
// programCount and programIndex are magic variables telling us how wide the SIMD instructions are.
assert( programCount == 4 ); //assert we're on SSE float4 instructions... On AVX this would be 8.
varying float a = aIn[programIndex]; // load 4 floats
varying float b = bIn[programIndex]; // load 4 floats
varying float c = cIn[programIndex]; // load 4 floats
varying float d = c + a / b; // do 4-wide SIMD math
dOut[programIndex] = d; // store N floats
//OR: If you've got any number of values to process:
foreach( index = 0 ... count ) // increment N at a time
{
varying float a = aIn[index]; // load N floats
varying float b = bIn[index]; // load N floats
varying float c = cIn[index]; // load N floats
varying float d = c + a / b; // do N-wide SIMD math
dOut[index] = d; // store N floats
}
}