On Sat Nov 5 17:01:44 2022 +0000, **** wrote:
Paul Gofman replied on the mailing list:
This will unlikely do it for a generic case. Affinity can be change after CS thread is created (both ways). Besides, cs thread serves other purposes besides optimization (e. g., shader compilation used to break on nv drivers sometimes when non-default FPU setup is used). I guess a better thing to do would be maybe to get rid of spinlocking in cs thread which should also be helping in favour of SRW lock / condition variable?
I don't think we can just replace the spin locks with condition variable as it would add a significant overhead to the map/unmap calls.
I tried replacing YieldProcessor() calls with SwitchToThread() and removing spinning in wined3d_cs_run() and although it improved performance for the 3 games from the bug reports, 2 of them (Midtown Madness Trial and Settlers II: 10th Anniversary Demo) were still slower compared to either disabling CSMT or disabling SetProcessAffinityMask(). Midtown Madness issues draw calls with user memory data, and Settlers II maps, writes and unmaps vertex and index buffers before each draw call.
I can think of the following options: - Rewrite buffer map/unmap implementation so that it does not wait for the CS thread to finish (at least in some cases). I don't know how hard this would be, but it should help many other games as well. - Ignore the CS thread in SetProcessAffinityMask() (probably too hacky).