Im not sure I’ve ever seen InterlockedAdd (hlsl) work correctly on Nvidia. Works on AMD tho. Can’t help but wonder if I’m doing something wrong, and AMD is more permissive. Seen a few reports of other people noticing the same thing.
-
-
Vastauksena käyttäjälle @tloch14
InterlockedAdd is bread and butter in a Compute Shader, used all the time by thousands of titles. If NVIDIA have a problem with it it'll be very scenario or driver specific. Anything to illustrate what you're doing?
1 vastaus 0 uudelleentwiittausta 3 tykkäystä -
Vastauksena käyttäjälle @adamjmiles
See, that's my line of thought. Always question your own code first, right? Just something to the gist of: RWBuffer<uint> someBuffer; [numthreads(64,1,1)] void main( uint3 dtId : ... ) { //... InterlockedAdd(someBuffer[dtId.x], someVal); }
2 vastausta 0 uudelleentwiittausta 0 tykkäystä -
Vastauksena käyttäjille @tloch14 ja @adamjmiles
64 threads is one wavefront on AMD but two warps on NVidia. What do you do with someBuffer after? You're probably missing memory barriers.
1 vastaus 0 uudelleentwiittausta 0 tykkäystä -
Vastauksena käyttäjille @rygorous ja @adamjmiles
I'm willing to accept a memory barrier is missing. Every time I feel like I understand barriers, they always seem to have another hand to reveal. SomeBuffer is used in another compute shader immediately following this one.
2 vastausta 0 uudelleentwiittausta 0 tykkäystä -
It'd be unusual to need a memory barrier if you're using atomics on UAVs. But if you're trying to read straight back out of someBuffer that could be iffy. Are you sure you didn't want to use the 3 operand version of InterlockedAdd with the 'old' return value?
1 vastaus 0 uudelleentwiittausta 0 tykkäystä -
Vastauksena käyttäjille @adamjmiles ja @rygorous
I use the 3 operand version (and store the result in another buffer). Twitter just didn't give me enough space to write it all out.
1 vastaus 0 uudelleentwiittausta 0 tykkäystä -
Vastauksena käyttäjille @tloch14 ja @adamjmiles
Wait you need to post something that reproduces the actual problem you're seeing or else this is pointless. Use http://gist.github.com or some other pastebin maybe? :)
1 vastaus 0 uudelleentwiittausta 0 tykkäystä -
Vastauksena käyttäjille @rygorous ja @adamjmiles
Yeah I need to create a small test case outside of our massive codebase. I've known I needed to do this, but haven't had the time to commit to it. I'll see if I can carve out some time to do that and then let you know.
1 vastaus 0 uudelleentwiittausta 0 tykkäystä
BTW thanks to both of you for reaching out. You've both given me some leads to look into.
Lataaminen näyttää kestävän hetken.
Twitter saattaa olla ruuhkautunut tai ongelma on muuten hetkellinen. Yritä uudelleen tai käy Twitterin tilasivulla saadaksesi lisätietoja.