chrisforbes / mesa

chrisf's mesa hacks
2 stars 0 forks source link

ARB_draw_indirect support (Gen7+) #32

Closed chrisforbes closed 10 years ago

chrisforbes commented 11 years ago

The idea with draw_indirect is to source parameters for rendering commands from a BO. This allows better pipelined rendering if the GPU is generating the rendering commands.

On Gen7, this is done as follows:

NOTE: This can be reasonably extended to ARB_multi_draw_indirect by looping over offsets in the BO. The hardware provides no facility for automatically walking the BO, moving values to the MMIO registers and triggering draws, but the driver knows how big it is so can do the right thing.

chrisforbes commented 11 years ago

Here's the indirect buffer layout:

        typedef struct {
          GLuint count;
          GLuint primCount;
          GLuint firstIndex;
          GLint  baseVertex;
          GLuint reservedMustBeZero;
        } DrawElementsIndirectCommand;
chrisforbes commented 11 years ago

and for nonindexed rendering:

        typedef struct {
          GLuint count;
          GLuint primCount;
          GLuint first;
          GLuint reservedMustBeZero;
        } DrawArraysIndirectCommand;
chrisforbes commented 11 years ago

The immediate HUGE wrinkle in this is that hardware wants a vertex count, but the spec requires the BO to contain a primitive count.

chrisforbes commented 11 years ago

Scratch that, I misread the spec.

chrisforbes commented 11 years ago

This basically works now, except that Haswell doesn't like the register writes from a userspace batch.