Vulkan
Vulkan copied to clipboard
Feature request: off screen rendering of models to large to fit into memory
I'd like to create an offscreen rendering of a model that is too large (too many vertices) to fit into my graphics card memory.
What I thought of doing is something like:
- Initialize an empty color attachment and depth buffer
- Setup the shader and graphics pipeline
- Loop over chunks of vertices from my huge model
- Upload the chunk of vertices from the CPU to the GPU
- Render into the color and depth buffers (on "top" of the previous values in the color and depth attachments)
- Repeat next chunk
- Download the resulting color image and save as png
I realize that I have to modify the renderheadless.cpp example to interlace the "upload" commands with the drawing commands, but my understanding of Vulkan is still not strong enough to understand how to do that. An example of how to do this would be much appreciated!
Can you not just put the render data in ram? Then the driver will do all the copying for you on the fly.
I don't understand what you meant by "render data in ram"? Could you elaborate?
I actually implemented the solution that I described above, and it works fine. There was some trickiness needed to retain and paint on the same image in multiple drawing passes. But once I figured that out, it was more or less the same as the offscreen rendering example.
Sorry I meant render FROM Ram. You can bind memory with the HOST_VISIBLE_BIT (or use VMA_CPU_TO_GPU if you use the VMA library), this should cause an allocation of RAM. (specifically memory addressable by the PCI driver, which may or may not be all your RAM). Render calls using this buffer are perfectly valid, they just tend to be a bit slower because reads have to go over the PCI bus.
Oh, interesting. I didn't know that you could use host memory as a source for VBA's. That really makes the my chunk based approach redundant. I have to explore that. Thanks!
The feature request still stands though, as it would be nice to have such an example in the repo.
I don't plan on creating such a sample.