FNA3D icon indicating copy to clipboard operation
FNA3D copied to clipboard

Detect multithreaded use of common FNA3D operations with the SDL_GPU backend and assert in debug builds

Open kg opened this issue 4 months ago • 2 comments

Idea came up on discord. It's not safe to do multithreaded operations on the SDL_GPU backend even though it's guarded by a mutex (the explanation for why not is complicated and I've partially forgotten) so ideally anyone having trouble can run with a debug build of FNA3D and the asserts will help them spot the bug in their code.

kg avatar Dec 01 '25 21:12 kg

The idea makes sense but we can possibly do this at a higher level; this can be done in FNA3D.c with a custom define that just checks the TID regardless of backend, and we can disable it by default in CMake.

flibitijibibo avatar Dec 02 '25 01:12 flibitijibibo

The idea makes sense but we can possibly do this at a higher level; this can be done in FNA3D.c with a custom define that just checks the TID regardless of backend, and we can disable it by default in CMake.

AFAIK it is completely safe to do multithreaded FNA3D on the D3D11 backend, and the OpenGL backend will break horribly, so I'm not sure we need to do it. I'm not opposed to doing it in a backend-agnostic way though, it just seemed most important to do it for SDL_GPU since the hazard is invisible.

kg avatar Dec 02 '25 17:12 kg