Hello Everyone,
I’m calculating the camera frustum on each frame to find out which objects need to be sent to the GPU for rendering using Graphics.DrawMeshInstancedIndirect, but most of the objects have already been sent to the GPU in the previous frames, which seems a waste of CPU time.
so is there a way to persist the rendered objects in the GPU instead of resending them each frame?
Thank you!
There is no concept of “objects” in the GPU. When you render using DrawMesh(Instanced), what you are actually doing is sending a Draw command to the GPU for a set of vertices with the shader program and its respective set of shader properties (aka Material) to use for drawing.
So in the GPU it only recognizes a set of vertices to render. The “mesh” reference is only held in the CPU.
Now with modern improvements to GPUs and GLs, there is a concept of using constant buffers / compute buffers, which might be treated like an object. However, this solution, might be more complicated than what you might wish for.
The only simple “persistence” for the GPU is the frame buffer, that you could choose to clear or not.
1 Like
If you look into the internal workings of the SRP batcher, that is the closest answer that you can get for saving drawing loops.
1 Like
That’s super clear, thank you!