PDA

View Full Version : batching draw calls



Kinski
03-23-2010, 06:12 PM
Hello everyone.

I have just been starting to use GLSL and my minimum hardware requirements are DirectX9 level GPUs.

I am wondering if it is feasible or even possible to batch draw calls with several different materials and textures efficiently.
What I was thinking about is to use vertex attributes to select material parameters which are defined by uniforms and to use vertex attributes to select between several texture samplers that are defined for individual draw calls.

I understand that are things like EXT_texture_array, but I can't use it due to the hardware I have to support.
Also how do I can find out with certainty what OpenGL- and GSLS version is being supported by the many different GPU generations on the market?

Thanks for your help!

Alfonse Reinheart
03-23-2010, 06:16 PM
Unless you're doing instancing, I don't think you're going to get that much of a performance benefit from trying to compact things that much. OpenGL's drawing overhead isn't nearly as bad as D3D9's, so you don't need to go through such efforts.

As to your question, the most you can do with GLSL 1.2 is sample from all of the textures and pick one based on a value.

Kinski
03-24-2010, 03:49 AM
The OpenGL command buffer is the primary bottleneck in my application, so I do have to optimize it as much as possible.

I already tried instancing using ARB_draw_instanced and did not notice a very significant improvement. However I don't know if this is something to expect when uploading the transform matrices using a uniform array for every instanced draw call. The average batch size is ~20 of instances per batch, with a few hundred of these in total per frame.

Isn't it feasible to replace gl_FrontMaterial with a uniform array and to select the appropiate one for every instances by a vertex attribute?

Sorry that I repeat the question: Also how do I can find out with certainty what OpenGL- and GLSL version is being supported by the many different GPU generations on the market with current drivers? I think that this is very important to know, but I simply can't find these data.

V-man
03-24-2010, 07:56 AM
Isn't it feasible to replace gl_FrontMaterial with a uniform array and to select the appropiate one for every instances by a vertex attribute?
Is the driver giving you an error message when you compile the shader? Or perhaps it is running to slow?

If you will use the texture method of sampling, it is best to do it from the FS because some DX9 GPUs don't have any VS samplers.

The version is obtained with glGetString.

Alfonse Reinheart
03-24-2010, 12:50 PM
The OpenGL command buffer is the primary bottleneck in my application, so I do have to optimize it as much as possible.

Are you sure that's your bottleneck? How did you determine this?

Maybe you should increase the size of your meshes/textures to compensate? Or maybe make your shaders higher quality?

GL 2.1-class hardware (or D3D 9 hardware, if you prefer) doesn't give you much leeway to optimize around batch or state-change overhead.


The average batch size is ~20 of instances per batch, with a few hundred of these in total per frame.

OpenGL has lower batch overhead (glDraw* overhead) than D3D. Because of this, instancing only is a win when you get more than 1000 or so instances. You may as well just draw them regularly if you only have 20 instances per batch.