ValveSoftware / Fossilize

A serialization format for various persistent Vulkan object types.
MIT License
584 stars 47 forks source link

Why is this CPU bound? #243

Closed kentslaney closed 6 months ago

kentslaney commented 6 months ago

More of a general understanding question than a specific bug, but why is a graphics pipeline so heavily CPU bound? Is the limiting factor for offloading to GPU the memory IO or the marginal utility?

Edit: Further investigation has led me to #93 which leads me to guess it's a development time problem. At some point (I hope) I'll look into how the multithreading thing was fixed to see what the memory situation looks like.

kakra commented 6 months ago

The multithreading is fixed. The shader compiler runs on CPU in the driver, not on GPU. It should not even use VRAM tho I've found that fossilize uses at least a little VRAM on NVIDIA, probably due to initializing the driver.

If you look at it this way: The generic pre-recorded shader pipelines cannot be understood by the GPU, so before running them on the GPU, they must be compiled by the CPU. Fossilize does this in advance to let the driver cache the compiled shader pipelines through its own mechanism, so when they are needed in the game later, rendering would not block while waiting on shaders.