Comment #0 by WorksOnMyMachine — 2012-08-12T13:56:18Z
Making a struct wrapper around the core vector types like core.simd.float4:
struct vfloat
{
public:
float4 f32;
this(float X) nothrow
{
f32.ptr[0] = X;
f32.ptr[1] = X;
f32.ptr[2] = X;
f32.ptr[3] = X;
}
this(float X, float Y, float Z, float W) nothrow
{
f32.array[0] = X;
f32.array[1] = Y;
f32.array[2] = Z;
f32.array[3] = W;
}
this(float[4] values) nothrow
{
f32 = values;
}
}
none of these constructors are callable for global constants:
immutable auto GvfGlobal_ThreeA = vfloat(3.0f);
immutable auto GvfGlobal_ThreeB = vfloat(3.0f, 3.0f, 3.0f, 3.0f);
immutable auto GvfGlobal_ThreeC = vfloat([3.0f, 3.0f, 3.0f, 3.0f]);
vmath\sse\sse_vfloat.d(22): Error: cannot cast vfloat(nanF).f32 to float[4u] at compile time
vmath\sse\sse_globals.d(39): called from here: vfloat(nanF).this(3F)
vmath\sse\sse_globals.d(40): Error: cannot cast float to float[4u]
vmath\sse\sse_vfloat.d(29): Error: cannot determine length of cast(float[4u])this.f32 at compile time
vmath\sse\sse_globals.d(40): called from here: vfloat(nanF).this(3F,3F,3F,3F)
vmath\sse\sse_vfloat.d(36): Error: cannot implicitly convert expression (values) of type float[4u] to __vector(float[4u])
vmath\sse\sse_globals.d(41): called from here: vfloat(nanF).this([3F,3F,3F,3F])
I also tried to coerce the constructor arguments into a float4 and perform assignment like so:
float4 foo = [X,X,X,X];
and also got : vmath\sse\sse_vfloat.d(22): Error: Cannot interpret cast(__vector(float[4u]))[X,X,X,X] at compile time
I also tried the following for the array constructor:
this(float[4] values) nothrow
{
f32.array = values;
}
This returned the following error:
vmath\sse\sse_vfloat.d(37): Error: CTFE ICE: cannot resolve array length