This question directly follows on from this one:

How can I implement a renderer that can draw many kinds of primitives?

I have a small amount of drawing code structured in the following way:

A mesh object can be instantiated with different configurations of vertices and indices in order to form any desired shape. A reference to this mesh is then passed to every gameObject class, this class holds spacial information and a draw method that combines this data with that of the mesh to draw that object with the proper transforms.

The mesh is simply responsible for holding pointers to the appropriate buffers.

I was under the impression (wrongly I think) that because I actually only have one object of each type that I'm drawing multiple times, that this WAS instancing. I know this isn't the case.

What EXACTLY is the difference between what I'm doing and hardware instancing and what changes do I need to make to achieve it?

  • \$\begingroup\$ Short answer is that hardware instancing is where one set of render data is prepared (like you have) and then a list of positions is uploaded and then they're all drawn at once (not like you have) without further intervention. You may or may not get any speedup from this depending on how many objects you're drawing, be sure to profile. \$\endgroup\$ Dec 3, 2011 at 11:45
  • \$\begingroup\$ @PatrickHughes OOOOHHH!! so you UPLOAD the transforms. I thought you just cycled through them in a loop. This is making much more sense now. \$\endgroup\$ Jan 4, 2012 at 15:12

1 Answer 1


Anything I can say on the subject is said better here: http://http.developer.nvidia.com/GPUGems2/gpugems2_chapter03.html, but I'll give you my best shot anyway.

The idea behind hardware instancing is that you reduce the amount of GPU draw calls by sending each mesh only once, together with a list of transforms. This offloads some of the work done by the CPU to the GPU and reduces amount the communication between CPU and the GPU.

So the difference between hardware instancing and your approach is that you apply the per-instance transforms on the CPU and that use a draw call for each instance. Vs a draw call per mesh for hardware instancing.

To implement hardware instancing you would have write a shader to apply the per-instance transforms and pass the relevant data to this shader. Also you need to use a different OpenGl or DirectX function to do the drawing (for OpenGl you would need to use glDrawInstanced instead of glDraw).

For more details on how to do this exactly, please read the Gpu Gems chapter in the link.

  • \$\begingroup\$ What is the minimum DX and OGL requirement for this feature? \$\endgroup\$ Dec 3, 2011 at 12:52
  • 1
    \$\begingroup\$ OpenGl supports instancing from 3.0 (en.wikipedia.org/wiki/OpenGL). DirectX I think from version 9. \$\endgroup\$
    – thomasD
    Dec 3, 2011 at 13:28
  • \$\begingroup\$ The minimum for DirectX 9 is shader model 2.0, specifically vs_2_0 for vertex shaders where instancing takes place. \$\endgroup\$
    – ChrisC
    Dec 3, 2011 at 18:39
  • \$\begingroup\$ updated link here \$\endgroup\$
    – KeyC0de
    Nov 12, 2020 at 23:51

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .