initialize float4 (core.simd)

Bogdan olar.bogdan.dev at gmail.com
Sun Oct 6 09:59:45 UTC 2019


On Saturday, 21 September 2019 at 14:31:15 UTC, Stefan Koch wrote:
> On Saturday, 21 September 2019 at 13:42:09 UTC, Bogdan wrote:
>> Well, this seems to be working:
>>
>>> float[4] doSimd(float[4] values, float delta)
>>> {
>>>   float4 v_delta = delta;
>>> 
>>>   float4 v_values = __simd(XMM.ADDPS,
>>>                            __simd(XMM.LODAPS, values[0]),
>>>                            v_delta);
>>> 
>>>   return [v_values[0], v_values[1],v_values[2],v_values[3]];
>>> }
>>
>> Not sure if it's correct though.
>
> float4 x;
> float x1, x2, x3, x4;
> x[0] = x1;
> x[1] = x2;
> x[2] = x3;
> x[3] = x4;

Thank you! That also seems to be working.
Turns out that using this method for drawing a rectangle is about 
twice as slow than a naive implementation, so I'm almost 
certainly doing something silly/wrong. :)


More information about the Digitalmars-d-learn mailing list