Comments on: Order your graphics draw calls around!http://realtimecollisiondetection.net/blog/?p=86
Coding wisdom and rants of Christer EricsonFri, 26 Feb 2016 07:46:15 +0000hourly1https://wordpress.org/?v=4.4.5By: Stateless, layered, multi-threaded rendering – Part 1 | Molecular Musingshttp://realtimecollisiondetection.net/blog/?p=86#comment-53855
Thu, 06 Nov 2014 16:49:54 +0000http://realtimecollisiondetection.net/blog/?p=86#comment-53855[…] Christer Ericson’s blog explains the concept well, if you are not familiar with it. […]
]]>By: Optimize state changes within a render queue | Question and Answerhttp://realtimecollisiondetection.net/blog/?p=86#comment-38502
Tue, 03 Jun 2014 23:00:12 +0000http://realtimecollisiondetection.net/blog/?p=86#comment-38502[…] searching a little more, I have found this helpful article : http://realtimecollisiondetection.net/blog/?p=86. It seems to be an elegant way to sort object by depth and materials. And in the material id, I can […]
]]>By: christerhttp://realtimecollisiondetection.net/blog/?p=86#comment-29628
Sun, 16 Mar 2014 02:24:45 +0000http://realtimecollisiondetection.net/blog/?p=86#comment-29628Frederic, your question is addressed in the third paragraph. I’m suggesting filling in an array, with each new entry, and just using any standard sorting algorithm to sort the array when it is filled. The cost of the sort is negligible as it takes place just once a frame.

ricardoquesada, you can e.g. normalize the floats so they are in the same exponent range with the same sign, at which point only the fraction bits of the floats need to be considered (of which there are 23 bits plus one implicit bit which is always 1). Pick the top N bits of the fraction bits, and store those in your key.

]]>By: frederichttp://realtimecollisiondetection.net/blog/?p=86#comment-29557
Sat, 15 Mar 2014 18:01:04 +0000http://realtimecollisiondetection.net/blog/?p=86#comment-29557As you mention a key/value system I assume you have to use map or unordered_map but is the former or the latter better? map is already sorted upon insertion whereas the unordered map would still need to be sorted. I’m not even sure it’s straightforward to do with algorithm’s sort(it.begin(),it.end()); or something like this. Another caveat is that internally it uses a hashed key…
]]>By: ricardoquesadahttp://realtimecollisiondetection.net/blog/?p=86#comment-12330
Fri, 27 Sep 2013 18:19:46 +0000http://realtimecollisiondetection.net/blog/?p=86#comment-12330Hi Christer,

I have a question regarding the depth key.
I have all the depth values in floats, and I want to use those values in the key.
What is the best way to encode floats into ‘bits’ (or integer) so that I can use it as part of the key ?

This might be a naive question as I’m not graphics programmer, I just dabble into it once in a while. Anyway, would you see a way how to handle scoped commands within your system? By “scoped” I mean things like glPushMatrix()/glPopMatrix() or glEnable(GL_BLEND)/glDisable(GL_BLEND) command pairs, anything that defines a scope of sorts, sets a state for the scope that anything rendered within the scope is affected by.

If I used the extension for commands you describe I’d still have to make sure that the draw calls generated within a scope (and no others) are still between the scope delimiting commands after sorting. That could be done by introducing the “scope” into the sorting key somehow, probably close to its MSB. However, some possible use cases I have in my head seem to indicate there could be clashes trying to determine the importance of the categories.

]]>By: christerhttp://realtimecollisiondetection.net/blog/?p=86#comment-3536
Thu, 04 Aug 2011 05:53:39 +0000http://realtimecollisiondetection.net/blog/?p=86#comment-3536Robin, things differ greatly between PCs (which you’re asking about) and consoles (which I work on). On PCs you have driver overhead, on consoles we don’t. On PS3 we pretty much don’t worry about small draw calls at all. So the VBO issues you ask about are pretty alien to me, so I cannot really provide reliable recommendations.

For the material and texture sorting question, the same applies. On PC you’ll have the driver doing things behind your back somewhat, whereas we explicitly upload textures, and vertex and fragment shaders. We also explicitly handle patching of parameters to the shaders etc. so we know exactly in what order things will be presented to the hardware and we can therefore sort things to account for that. There’s no uploading of textures or shaders “behind our back.”

Perhaps someone more familiar with the atrocities performed by PC drivers can comment directly on your questions!

]]>By: robindegenhttp://realtimecollisiondetection.net/blog/?p=86#comment-3534
Wed, 03 Aug 2011 13:06:52 +0000http://realtimecollisiondetection.net/blog/?p=86#comment-3534Thanks for this post! It helped me get a good idea of where to begin with my render queue (i’m currently not sorting at all, just rendering).

One thing i’m wondering though, at the lower level, do you optimize anything with your VBO’s? For example, if you have a few small models (chairs, tables, whatever), do you have an equal amount of VBO’s or do you combine them into a larger one somewhere and then just render parts? And if so, at what point do you do that? Or do you just have a whole bunch of smaller vbo’s, accepting the statechanges for those?

One idea i had was that whenever i load the world, it will determine the primitive count (triangles usually) of all the static objects and spread them over various VBO’s (i have yet to find the “magic” number of vbo size). When the vbo is “full” it will add the next model to a new vbo and so on. What is your view on this idea?

Another thing i was wondering; in most modern games you’d rarely see the same texture used twice, as about 90% of the rendered scene would be unique for materials (except maybe for the used shader). Would you then choose to only depth-sort and completely ignore materials if thats the case? In a typical scene i’ve seen theres barely any texture used twice, and if it is it’d be something used a lot, which would then be instanced anyway

]]>By: Growing Ginkgo Pt. 1: The Reading List » AltDevBlogADay (Staging Site)http://realtimecollisiondetection.net/blog/?p=86#comment-3393
Sun, 13 Feb 2011 01:07:45 +0000http://realtimecollisiondetection.net/blog/?p=86#comment-3393[…] rendering subsystem is following the guidelines outlined in Christer Ericson’s “Order Your Drawcalls”. We have buckets of arrays of faces that are sorted according to a render mask. More about that in […]
]]>