lovr icon indicating copy to clipboard operation
lovr copied to clipboard

Indirect Drawing

Open bjornbytes opened this issue 5 years ago • 1 comments

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.

bjornbytes avatar May 21 '20 23:05 bjornbytes

Implemented on dev branch, along with indirect compute dispatch.

bjornbytes avatar Aug 04 '22 21:08 bjornbytes