https://bugs.winehq.org/show_bug.cgi?id=52684
--- Comment #10 from Zebediah Figura z.figura12@gmail.com --- (In reply to Zebediah Figura from comment #7)
(1) Normally the sysmem texture would be left in WINED3D_LOCATION_SYSMEM after the map, but because of the flag, we don't invalidate ~map_binding, hence CLEARED is valid. Based on some testing I believe this code path is incorrect, although I'm not sure it was possible to trigger an actual bug before the offending commit. Unfortunately we rely on that lack of invalidation in some other places, so those will also need to be fixed. In particular I believe we should be respecting the dirty regions for managed textures in wined3d_texture_load_location(), not when mapping. Even for managed textures SYSMEM should still be valid; it's just not uploaded to the GPU.
One snag here is that the dirty regions are currently tracked on the client thread. In order to fix this we'd need to move that to the CS thread. Alternatively, we could move the entirety of MANAGED resource handling out of the CS thread (which probably means explicitly keeping two different wined3d_texture objects and blitting from one to the other as necessary), which is arguably cleaner in some ways but does have its own complications.