I'm not well enough at the moment to examine this series thoroughly, but what issues is it designed to fix? I understand that in d3d12_device_flush_blocked_queues_once() a blocked queue which has been buffered in blocked_queues[] for re-adding may be unblocked and then re-added in another thread, then added again from blocked_queues[]. Can we just perform deduplication on the blocked queue array (maybe only if fills up), since flushing an unblocked queue is harmless, or would there still be an issue?
No, I don't think there would. But I think that at least there should be an actual deduplication procedure that happens every now and then. The corner case I am concerned about is that for some bad access pattern queues get added over and over to the blocked list and never removed. I'll think more about this.
Anyway, the important patch is the third one, and the second one is basically a preparation for it. The goal is to avoid to access mutex protected fields without holding the mutex, specifically `is_flushing` (and also `ops_count`, but that is less critical, it could just be removed).
It may be much better to create a worker thread for queue flushing, similar to how vkd3d-proton does it. Henri rejected the idea a while ago because it may fail badly on external acquisition, but if that issue is fixed then maybe a thread is the best solution to remaining problems with blocked queue handling.