Vertex Rendering

Revision as of 09:48, 1 September 2012 by Alfonse (talk | contribs) (Indirect rendering: started indirect section.)

Jump to: navigation, search

Vertex Rendering is the process of taking vertex data specified in arrays and rendering one or more Primitives with this vertex data.


Direct rendering

Transform feedback rendering

Indirect rendering

Indirect rendering
Core in version 4.5
Core since version 4.0
Core ARB extension ARB_draw_indirect, ARB_multi_draw_indirect, ARB_base_instance

Indirect rendering is the process of issuing a rendering command to OpenGL, except that most of the parameters to that command come from GPU storage provided by a Buffer Object. For example, glDrawArrays takes a primitive type, the number of vertices, and the starting vertex. When using the indirect rendering command glDrawArraysIndirect, the starting vertex and number of vertices to render would instead be stored in a buffer object.

The purpose of this is to allow GPU processes to fill these values in. This could be a compute shader, a specially designed geometry shader coupled with transform feedback, or an OpenCL/CUDA process. The idea is to avoid the GPU->CPU->GPU round-trip; the GPU decides what range of vertices to render with. All the CPU does is decide when to issue the rendering command, as well as which Primitive is used with that command.

The indirect rendering functions take their data from the buffer currently bound to the GL_INDIRECT_BUFFER binding.

Conditional rendering

Conditional Rendering
Core in version 3.0
Vendor extension NV_conditional_render

Conditional rendering is a mechanism for making the execution of one or more rendering commands conditional on the result of an Occlusion Query operation. This is done with the following functions:

glBeginConditionalRender(GLuint id​, GLenum mode​);

All rendering commands issued within the boundaries of these two functions will only execute if the occlusion condition specified by id​ is tested to be true. For GL_SAMPLES_PASSED queries, it is considered true (and thus rendering commands are executed) if the number of samples is not zero.

The commands that can be conditioned are:

The mode​ parameter determines how the discarding of the rendering functions is performed. It can be one of the following:

  • GL_QUERY_WAIT​: OpenGL will wait until the query result is returned, then decide whether to execute the rendering command. This ensures that the rendering commands will only be executed if the query fails.
  • GL_QUERY_NO_WAIT​: OpenGL may execute the rendering commands anyway. It will not wait to see if the query test is true or not. This is used to prevent pipeline stalls if the time between the query test and the execution of the rendering commands is too short.
  • GL_QUERY_BY_REGION_WAIT: OpenGL will wait until the query result is returned, then decide whether to execute the rendering command. However, the rendered results will be clipped to the samples that were actually rasterized in the occlusion query. Thus, the rendered result can never appear outside of the occlusion query area.
  • GL_QUERY_BY_REGION_NO_WAIT: As above, except that it may not wait until the occlusion query is finished. The region clipping still holds.

Note that "wait" in this case does not mean that glEndConditionalRender itself will stall on the CPU. It means that the first command within the conditional rendering scope will not be executed by the GPU until the query has returned. So the CPU will continue processing, but the GPU itself may have a pipeline stall.

See Also