ConfettiFX / The-Forge

The Forge Cross-Platform Rendering Framework PC Windows, Steamdeck (native), Ray Tracing, macOS / iOS, Android, XBOX, PS4, PS5, Switch, Quest 2
Apache License 2.0
4.65k stars 491 forks source link

Question : way to read texture back from GPU to CPU ? #209

Closed vlmillet closed 2 years ago

vlmillet commented 3 years ago

I wanted to port my gpu based mouse picking system to The Forge so I've searched the whole ResourceLoader/Renderer API and I'm not able to find how to do the equivalent of Vulkan vkCmdCopyImageToBuffer, is this possible in some way ? Thanks.

wolfgangfengel commented 3 years ago

You want to check out the screenshot support files. We used it in there.

wolfgangfengel commented 3 years ago

https://github.com/ConfettiFX/The-Forge/blob/master/Common_3/OS/Core/Screenshot.cpp

vlmillet commented 2 years ago

Thank you ! I've found it and began exploring it. I was wondering while reading the code why isn't there a more generic "Texture to buffer" function in the general API instead of a very specific Screenshot/SwapChain to buffer which could be based on a common code ?

wolfgangfengel commented 2 years ago

The main reason is that people do not understand the performance impact of a read-back. So we make it a bit more difficult to do the wrong thing.

wolfgangfengel commented 2 years ago

This is now available in the resource loader ...

vlmillet commented 2 years ago

Sorry, haven't noticed the change, thank you for this !