Balance of vertex shader and fragment shader

General question:
(1) Usually how many vertices/triangles can have a good balance when using shaders? ( don’t want fragment shader is busying but vertex is idle there )

(2) For opengl, what is the texture size which gives us best performance? ( 256256, 512512, or … doesn’t matter)


  1. if you have 1000 vertices all occupying 2 pixels on the screen your vertex shader will process 1000 vertices and pixel shader 2 pixels. hope that gives you the hint.

  2. the bigger the more time it takes to move it around and bigger once occupy even more space when using mipmapping or ripmapping. so the smaller the better but this needs to be confirmed if this a very big performance loss or something. benchmark? make sure you check the highest supported texture size when GL is initialized.

(1) Why do you want that vertex and fragment processing loads are well balanced? An extreme case that often occurs, is one triangle that fill all the screen. In this case, vertex processor will have to process only 3 vertices whereas as fragment process will work on all the window pixels.

(2) This is a good question. I would say that with mipmapping enabled, texture size does not matter very much since opengl should choose the appropriate texture. I mean, even if a big texture which size is 1024x1024, is displayed on one pixel, opengl will use the last mipmap level and not process the big source texture.
But the problem with that is that video memory space is not infinite.

  1. way to many, but then again the vertex shader should be a little at idle compared to the fragment shader.
    However this depends on your hardware, newer hardware have so called unified shader units which means that the same processors does both fragment and vertex processing, in which case nothing is ever at idle.
    However the number your asking of is probably over 100k depending a little of how much shading your doing.

2.i would say doesn’t matter, that is if you use textures wisely (ie. no 4k texture on something that will never be more than 32*32), but i guess some would disagree with me then.
But really the biggest problem is probably how many textures you are using, not how large they are.
So if you can fit a bunch of textures on a single large one then you will save more than you loose.

thank you all for the very valuable response!
(1), for some case,like raycasting, we can increase the geometry complicity and reduce the load to fragment shader. Therefore we gain some performance.

(2), for a huge image (for example 4096*8192 ), we have to divide it into some small pieces for display purpose, then what kind of segmentation is the best?

  1. I always thought that since the introduction of unified shaders (ATI 2000 series and up,NVidia 8000 series and up) the balance between vertex processing and fragment processing is much less important than the previous cards because newer cards can do “load balancing” between “all purpose” processors which older cards cannot (fixed number of vertex and fragment processor).

  2. dletozeun is absolutely right. On my video card, a Nvidia TnT2, a “big” mipmap texture say 1024x1024, can be a lot faster in general than a single no mipmapped 256x256 for the reason dletozeun write above.

sorry for the misleading!
(1) for the GPU raycasting, the vertex shader is very simple, but the fragment shader is very complicated and time consuming epically when we are adding lighting there. So reducing the fragment execution will really help.

(2) I heard that some size ( maybe 256* 256 ) is optimized most.

(1) rasterizing is the most heavy, time consuming operation thus reducing the window size from 1024x768 to say 640x480 is already a performance gain but you trade picture quality for that.

(2) never heard that. if so, it probably depends on the vendor or a special card series. you must check some specs then.

(2.1) btw. i heard that mipmapping IS a performance gain true, but more memory gets consumed.
(2.2) packing many textures into one big texture is ok but will produce artifacts due to mipmap filtering if tightly packed.

only if you do it the wrong way, if you pack them in PoT squares in the correct way, the textures won’t bleed until the last few mipmaplevels, and by then it will only be noticed if those textures are of an dissimilar enough color.

dont know. something i read once. i do it the single texture way. the texture bleeding artifacts might depend on what size the 0 mipmap level is.

Just for completeness, it costs 33% of original texture size more. This is quite few.

dletozeun: This is quite few

true. just in general depending on how big the scene is (how many textures are in use) and how large the textures are f.e 8192x8192.
like always, it all depends on what someone tries to accomplish.

Yes but that is very vague. The FS might do 2 pixels but if your FS is very long, it will be quite busy.

Instead of thinking in terms of balancing between VS and FS, it is better to have a LOD scheme. Load a simpler shader and a simpler geometry when object is far from the viewer.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.