Game Development Reference
In-Depth Information
structdrawElementsIndirectCommand
{
GLuint count;
GLuintinstanceCount;
GLuintfirstIndex;
GLintbaseVertex;
GLuintbaseInstance;
};
...
// At creation time
glBindBuffer(GL_DRAW_INDIRECT_BUFFER, BufferName);
glBufferData(GL_DRAW_INDIRECT_BUFFER,
sizeof (drawElementsIndirectCommand) * DrawCount, NULL, GL_STATIC_COPY);
glBindBuffer(GL_DRAW_INDIRECT_BUFFER, 0);
...
// In the rendering loop
glBindBuffer(GL_DRAW_INDIRECT_BUFFER, BufferName);
glMultiDrawElementsIndirect(GL_TRIANGLES ,
GL_UNSIGNED_INT , 0, DrawCount, sizeof (drawElementsIndirectCommand));
Listing 2.3. Creation and use of a multi draw indirect buffer.
An OpenCL kernel or an OpenGL compute shader is capable of building the
multi draw indirect buffer. Just like the CPU visibility culling thread, the GPU
processes a batch of object-bounding volumes. When the bounding volumes pass
the visibility tests, the corresponding draw parameters for the objects fill the draw
x -axis: Number of Draw
y -axis: Processing Time (ms)
250
200
150
100
50
0
128,000
256,000
1,000
2,000
4,000
8,000
16,000
32,000
64,000
glDrawArraysIndirect
glMultiDrawArraysIndirect
Figure 2.8. Performance comparisons between glDrawArraysIndirect and glMulti
DrawArraysIndirect .
 
 
Search Nedrilad ::




Custom Search