lovr
lovr copied to clipboard
Indirect Drawing
Sometimes it is useful to draw a Mesh, but with info (draw range, instance count) sourced from a ShaderBlock. This is called indirect drawing.
An idea for an API for this would be:
Mesh:draw(transform, shaderBlock, [byteOffset = 0])
Which would map onto the glDrawArraysIndirect or glDrawElementsIndirect function, depending on if the Mesh has an active vertex map.
One wrinkle is that because the instance count is stored in GPU memory by the user, it needs to be adjusted to handle the instance multiplier LÖVR normally applies internally when using instanced stereo. LÖVR can start sending this to compute shaders, but the caveat is that it will only be correct if you have a Canvas of the correct type (stereoness) bound while doing the compute call.
Implemented on dev branch, along with indirect compute dispatch.