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ä -
Vastauksena käyttäjille @tloch14 ja @adamjmiles
Okay, but no other accesses to that buffer in the first shader? Then on D3D11, you need to do nothing else. On D3D12, you need a UAV barrier on that buffer between the two dispatches.
1 vastaus 0 uudelleentwiittausta 0 tykkäystä -
Vastauksena käyttäjille @rygorous ja @adamjmiles
Interesting. I've seen the problem (it manifests as flickering in the final result) on d3d11. We run Vulkan, D3D12, and D3D11 with an abstraction layer in between, so I'll be digging for a missing barrier. FWIW, problem goes away on Nvidia if I set numthreads(1,1,1).
1 vastaus 0 uudelleentwiittausta 0 tykkäystä
Sorry -- to answer the question: No other access in the first shader. I'm fairly straightforward about what buffers are "reads" and what are "writes", with only 1 place of writing for any given buffer.
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.