I have the following compute shader code that works where I use double3s:
RWStructuredBuffer<double3> Positions;
uint NSoldiers;
[numthreads(GROUP_SIZE, 1, 1)]
void main(uint3 DispatchThreadID : SV_DispatchThreadID, uint3 GroupThreadID : SV_GroupThreadID){
if (DispatchThreadID.x >= NSoldiers) { return; }
double3 loc = Positions[DispatchThreadID.x];
loc.x += 1.0f;
Positions[DispatchThreadID.x] = loc;
}
But I cannot use this code because UE5 refuses to package a project that has doubles in HLSL code. So I have to use the provided DoubleFloatlibrary. The problem is that when using FDFVector3s instead of double3s the code doesn’t work at all:
RWStructuredBuffer<FDFVector3> Positions;
uint NSoldiers;
[numthreads(GROUP_SIZE, 1, 1)]
void main(uint3 DispatchThreadID : SV_DispatchThreadID, uint3 GroupThreadID : SV_GroupThreadID)
{
if (DispatchThreadID.x >= NSoldiers)
{
return;
}
//float3 loc = DFDemote(Positions[DispatchThreadID.x]);
FDFVector3 pos = Positions[DispatchThreadID.x];
FDFVector3 delta = DFPromote(float3(1.0f, 0.0f, 0.0f));
Positions[DispatchThreadID.x] = DFAdd(pos, delta);
}
The data on the CPU that is passed to the RWStructruedBuffer is a TArray<FVector>. I have verified that FVectors, FDFVector3s and double3s are the same size (24 bytes). Also the shader does not output random data when using DoubleFloats, rather it appears to leave the data unchanged.