FNA-XNA / FNA3D

FNA3D - 3D Graphics Library for FNA
http://fna-xna.github.io/
Other
287 stars 48 forks source link

Rough fix for Texture.GetData being horribly slow on Vulkan backend #204

Closed kg closed 4 months ago

kg commented 7 months ago

Feedback welcome on how this should actually be fixed. Looking into why GetData is really slow on Vulkan, I think I found a few things:

The fixes I tried to apply here:

My game is doing one small (320x180x8bpp) GetData per frame at the very start before any drawing happens, on a render target from the previous frame. Without these fixes, D3D11 gets around 1150fps and Vulkan gets ~45fps. With these fixes Vulkan gets ~950fps.

kg commented 7 months ago

Based on discussions on discord, I think the only essential change in here is to make sure transfer buffers are always in host memory, not device memory. Right now it's possible for transfer buffers to end up in device memory, which means writes aren't efficient huge DMAs and reads are especially-inefficient small block transfers.

The present/submit/flush stuff does seem wrong too but I don't think it was the root cause of the performance issues with GetData.

thatcosmonaut commented 4 months ago

Our SDL GPU proposal is approved now, and that Vulkan implementation is enormously superior to FNA3D's, so I'm closing this with the expectation that we will be deleting FNA3D_Driver_Vulkan completely in the near future.