Sinus function in HLSL not working properly

Hi there,

I am working on a Unity project, where I am simulating a Radar system. For the detection/calculation of the receive signal I use a compute shader. I have 4 receivers, which are supposed to be calculated in parallel, with 1000 samples each.

// Each #kernel tells which function to compile; you can have many kernels
#pragma kernel  SignalCalculationShader
#pragma enable_d3d11_debug_symbols

RWStructuredBuffer<float> _DistanceBuffer;
RWStructuredBuffer<float> _ReceivedSignals;
RWStructuredBuffer<float> _ChirpSignal;
float _Bandwidth;
float _ChirpDuration;
float _SamplingRate;
float _StartFrequency;
int _NumTxAntennas;
int _NumRxAntennas;
int _ChirpSignalLength;

[numthreads(1, 1, 1)]
void SignalCalculationShader(uint3 dispatchThreadId : SV_DispatchThreadID)
{
int rxIndex = dispatchThreadId.x;

if (rxIndex >= _NumRxAntennas)
{
return;
}

float distance = _DistanceBuffer[rxIndex];

if (distance >= 0)
{
float delay = (distance * 2) / 3e8f;
float chirpRate = _Bandwidth/_ChirpDuration;

for (int i = 0; i < _ChirpSignalLength; i++)
{
float t = (float)i / _SamplingRate;
//float t = delay + (float)i / _SamplingRate; 
float frequency = _StartFrequency + chirpRate * (t - delay);
// Simulated received signal at sample i
int bufferIndex = rxIndex * _ChirpSignalLength + i;
_ReceivedSignals[bufferIndex] = sin(2.0*3.14159265359*frequency*t);
}
}
}

The problem lies somehow in the last line. If I change that line to simply 2.03.14159265359frequency*t it works just fine, but as soon as I try to run the project with the sine function included, I get very weird results. Only the first 14-15 signal samples are calculated and those are also wrong results. Could it be possible, that my GPU can not handle the calculation? I am using an RTX 2060 Super.

Does anyone know what could be the problem or has any suggestions or a workaround? (I also tried approximation methods for the sine function but those did not seem to work either.)

Thanks a lot in advance!