why are draw calls expensive?

后端 未结 3 1746
悲哀的现实
悲哀的现实 2020-12-22 16:28

assuming the texture, vertex, and shader data are already on the graphics card, you don\'t need to send much data to the card. there\'s a few bytes to identify the data, and

3条回答
  •  不知归路
    2020-12-22 17:01

    Short answer: The driver buffers some or all of the actual the work until you call draw. This will show up as a relatively predictable amount of time spent in the draw call, depending how much state has changed.

    This is done for a few reasons:

    • to avoid doing unnecessary work: If you (unnecessarily) set the same state multiple times before drawing it can avoid doing expensive work each time this occurs. This actually becomes a fairly common occurrence in a large codebase, say a production game engine.
    • to be able to reconcile what internally are interdependent states instead of processing them immediately with incomplete information

    Alternate answer(s):

    • The buffer the driver uses to store rendering commands is full and the app is effectively waiting for the GPU to process some of the earlier work. This will typically show up as extremely large chunks of time blocking in a random draw call within a frame.
    • The number of frames that the driver is allowed to buffer up has been reached and the app is waiting on the GPU to process one of them. This will typically show up as a large chunk of time blocking in the first draw call within a frame, or on Present at the end of the previous frame.

提交回复
热议问题