Search Unity

  1. Dismiss Notice
  2. Looking for a job or to hire someone for a project? Check out the re-opened job forums.
    Dismiss Notice
  3. Unity 2020 LTS & Unity 2021.1 have been released.
    Dismiss Notice
  4. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Help Wanted Persist the rendered objects in the GPU

Discussion in 'General Graphics' started by Opeth001, Nov 26, 2020.

  1. Opeth001

    Opeth001

    Joined:
    Jan 28, 2017
    Posts:
    784
    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!
     
  2. weiping-toh

    weiping-toh

    Joined:
    Sep 8, 2015
    Posts:
    155
    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.
     
    Opeth001 likes this.
  3. weiping-toh

    weiping-toh

    Joined:
    Sep 8, 2015
    Posts:
    155
    Opeth001 likes this.
  4. Opeth001

    Opeth001

    Joined:
    Jan 28, 2017
    Posts:
    784
    That’s super clear, thank you!
     
unityunity