Wrt patch 4: is "yield CPU" an accurate description of what Sleep(0) does anymore? Separately, is that what we want, instead of NtYieldExecution()?
Indeed the comment isn't really accurate anymore. Still we might want to Sleep(), which is more similar to what we end up doing in wined3d_cs_wait_event(). I'll do some testing.
Wrt patch 5: I intend to sign off on the patch anyway, but I'm curious what if anything prevents us from going further. The subject mentions "minimally decreased" performance—was there a measurable (however minimal) loss, and do we remember with which applications?
That was a long time ago and I'm not entirely sure anymore. It was probably more to do with the (old) CPU of the box that I used for testing at the time not having any kind of boosting of individual cores based on total CPU load than any specific game. FWIW the game I was testing with this back then was probably World of Tanks, whatever version was current at the time, with whatever hacked wined3d version I had...
Basically, as I remember it, sometimes waiting in some form in the CS thread meant that we serviced the following commands a bit later and thus FPS went down (a couple of % points or so at most maybe? I can't say for sure). Nowadays it's very likely that we more than make up for that by freeing CPU time to be used by some application thread or just so that CPU cores already used by the application get more power headroom and can execute faster.
I could give some fresh testing to this as well.
I had an out-of-tree patch to use TID alerts, do you know if that helps enough to reduce the spin count further or eliminate it altogether? I believe you had another out-of-tree patch somewhere that did remove the spin count altogether, I'm curious if you remember more of the details around that.
Yeah, that would be in part 2 or 3 of the series :smile: We can probably just go ahead and get rid of the spinning entirely but I preferred to put the least controversial stuff at the front and get rid of most of the CPU cycles waste by the end of the first part. As I remember it, I didn't find downsides to just never spinning at the time, but then I recently found some other place in wined3d where maybe spinning a bit before waiting is a good idea. I'll reevaluate all that after this MR is done with.