Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Would it be possible to have frames with zero draw calls?

Discussion in 'General Discussion' started by Arowx, Nov 3, 2016.

  1. Arowx

    Arowx

    Joined:
    Nov 12, 2009
    Posts:
    8,194
    Modern API's like Vulkan and DirectX 12 aim to massively reduce the bandwidth between CPU and GPU.

    So could you have a scene where nothing moves and therefore no additional draw calls are needed?

    Or the whole of a scene in GPU memory and only move the camera so no additional draw calls are needed?
     
  2. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    10,936
  3. dogzerx2

    dogzerx2

    Joined:
    Dec 27, 2009
    Posts:
    3,957
    For something like that you'd need a very advanced software that lets you choose when to call the render function such as Blitz3D :B

    But that's too leet
     
  4. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    20,026
    Wouldn't a frame with zero draw calls simply be a blank frame? :p
     
    AndrewGrayGames likes this.
  5. neginfinity

    neginfinity

    Joined:
    Jan 27, 2013
    Posts:
    13,301
    Yes. "Clear backbuffer" is not technically a draw call. So you can have a blank frame.
     
    AndrewGrayGames likes this.
  6. gian-reto-alig

    gian-reto-alig

    Joined:
    Apr 30, 2013
    Posts:
    756
    Whats the point? Draw calls are not inherently evil. To many of them can overload your CPU, yes.

    Why not go with "low amount of drawcalls" and call it a day instead of striving for the impossible?
     
    angrypenguin and AndrewGrayGames like this.
  7. Schneider21

    Schneider21

    Joined:
    Feb 6, 2014
    Posts:
    3,510
    Make an audio-only game and your entire project can have zero draw calls!
     
  8. imaginaryhuman

    imaginaryhuman

    Joined:
    Mar 21, 2010
    Posts:
    5,834
    A "draw call" is a set of api instructions typically to setup what material will be used... where a material really is a set of instructions relating to rendering like loading a shader, setting up a texture, enabling multitexturing, setting up lighting, etc. So usually when a texture or shader changes or is modified it invokes the need for a new draw call. So even if you had a totally stationary scene, if it were not able to use a single material shared by every single model, it will still require multiple draw calls. The API and the hardware would both have to support multiple simultaneous draw-calls, ie storage of many more instances of settings, in order for you to in any way overcome this.
     
    Ryiah and AndrewGrayGames like this.
  9. gian-reto-alig

    gian-reto-alig

    Joined:
    Apr 30, 2013
    Posts:
    756
    Ha... the witty would respond to that that you could draw the screen once and then never refresh it, while the game engine idles away in the background (thus technically, there still is a "frame" every 1/60 second). No idea if Unity supports that kind of lazy screen refresh though.

    Also, I have no idea what the point of that should be... but hey, its an Arowx thread, so I would not even date to ask that question.
     
    AndrewGrayGames and dogzerx2 like this.
  10. neginfinity

    neginfinity

    Joined:
    Jan 27, 2013
    Posts:
    13,301
    You'll still need to draw UI.
     
  11. Schneider21

    Schneider21

    Joined:
    Feb 6, 2014
    Posts:
    3,510
    No, audio only! It's just a blank screen with audio prompts to do things, and audio-only feedback! Like a game for 100% blind people.
     
  12. dogzerx2

    dogzerx2

    Joined:
    Dec 27, 2009
    Posts:
    3,957
    The real challenge is making a game without visuals nor audio! :B
     
    theANMATOR2b and Schneider21 like this.
  13. neginfinity

    neginfinity

    Joined:
    Jan 27, 2013
    Posts:
    13,301
    I think something like that was released on steam actually. It still had an ui. Audio only game. I forgot what it was called, though.
     
  14. Schneider21

    Schneider21

    Joined:
    Feb 6, 2014
    Posts:
    3,510
    I think I'm up to that challenge...

    Sounds like they halfassed the "audio only" portion to me, then. :p
     
    Deleted User likes this.
  15. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    It might be possible to write a shader that does caching. That might work. Or it might not.
     
  16. zombiegorilla

    zombiegorilla

    Moderator

    Joined:
    May 8, 2012
    Posts:
    8,950
    Not. ;)
     
  17. zombiegorilla

    zombiegorilla

    Moderator

    Joined:
    May 8, 2012
    Posts:
    8,950
    Zero draw calls on the GPU:
    monopoly8.jpg
     
  18. imaginaryhuman

    imaginaryhuman

    Joined:
    Mar 21, 2010
    Posts:
    5,834
    I would think you can probably get close to 1 draw call for a scene, even if its animated or the camera is moving or whatever.

    Or if you want zero, render your scene into a render texture in one frame, then in the next frames, just render the rendertexture to the backbuffer... but oh... wait, texture mapping requires a draw call. Darn it.
     
  19. zombiegorilla

    zombiegorilla

    Moderator

    Joined:
    May 8, 2012
    Posts:
    8,950
    Sure, you can get one, as an experiment when the Sprite system was introduced a few years back, I made a solitaire game with that goal in mind. I was able to do it in a single draw call, jamming everything onto a single texture. Not particularly practical or performant, but doable.

    For zero, you can just remove all cameras and canvases. ;)
     
    Kiwasi likes this.
  20. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    Fair enough. I've written exactly one shader so far, so I defer to your experience.

    Is shader caching actually a thing at all? Or am I making stuff up.

    Its actually possible to get far better graphics performance on that platform, however it often comes at the cost of player processing time.

     
    theANMATOR2b, Ryiah and zombiegorilla like this.
  21. zombiegorilla

    zombiegorilla

    Moderator

    Joined:
    May 8, 2012
    Posts:
    8,950
    Well, yes, but not in the way you suggested. As in caching results. Think of a shader as a static method, like Vector3.Distance or Mathf.Abs. You pass it a bunch of data, it returns a color. (for a frag, for example). It really isn't aware of much. But even if hypothetically it was aware of what it did last time, running it to return that stored result would still be a draw call, though you would be trading calculatation speed for memory storage/retrieval.
     
    Kiwasi likes this.
  22. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    Makes sense. I like the static analogy.

    My mind is currently running away with possibilities faster then my skill with writing shaders. It will calm down again soon.
     
  23. neginfinity

    neginfinity

    Joined:
    Jan 27, 2013
    Posts:
    13,301
    Actually, I think it is theoretically possible to have exactly one drawcall.

    You'll need a scene drawn by raycasting shader. Then you'll need to plug in the whole world as data into that shader. It won't be terribly fast or terribly efficient but it can be done.

    I think it can actually be done. Not 100% sure of it and haven't explored it.
    Basically, compute shaders can write to data, and both OpenGL/Directx should have writeable storage objects accessible from shaders.
    https://www.opengl.org/wiki/Shader_Storage_Buffer_Object
    http://stackoverflow.com/questions/32094598/opengl-compute-shader-ssbo
     
  24. zombiegorilla

    zombiegorilla

    Moderator

    Joined:
    May 8, 2012
    Posts:
    8,950
    Well... Yes it 'could' be done, but that is typically for more complex processes. Using buffers for caching results from an optimized shader pass(s), wouldn't necessarily result in a time reduction, and wouldn't reduce draw calls as the shader (material) is still performing the action. Though as mentioned before, draw calls by themselves aren't a strong performance metric. Caching type functionality can be handled more optimally in other parts of the rendering pipeline.
     
  25. eskovas

    eskovas

    Joined:
    Dec 2, 2009
    Posts:
    1,373
  26. zombiegorilla

    zombiegorilla

    Moderator

    Joined:
    May 8, 2012
    Posts:
    8,950
  27. eskovas

    eskovas

    Joined:
    Dec 2, 2009
    Posts:
    1,373
    It's probably really super inefficient to be running in a GPU, but it works :D
     
  28. zombiegorilla

    zombiegorilla

    Moderator

    Joined:
    May 8, 2012
    Posts:
    8,950
    Sure it is very inefficient, but so is playing Tetris on building with christmas lights:


    Or playing Doom on a printer:


    Or Defender in a favicon:
    http://www.p01.org/defender_of_the_favicon/

    Or building a low resolution aerial display using 100 synced drones:


    Efficiency be damned! Cool is just cool!
     
    eskovas and Kiwasi like this.