NVIDIAGameWorks / FleX

Other
669 stars 100 forks source link

Atomic operations on float4 #40

Open korzen opened 6 years ago

korzen commented 6 years ago

Hi,

I am writing a kernel for projecting custom constraints type. I would like to solve them in a constraint centric way. However, I am not sure how to use atomic operations such a as add on structs such as float4. From the unified particles paper I know that such approach is being used in Flex.

Some code snippet would be much appreciated.

Thanks

mmacklin commented 6 years ago

Hi there,

We simply emulate float4 atomics by performing it on each element, i.e.: in CUDA calling atomicAdd() 4 times. D3D11 does not have atomic floating point operations so they have to be emulated using InterlockedCompareExchange().

Hope that helps.

Cheers, Miles