opengl es - Multiple Shaders-Single Program or If-else conditions via a uniform variable? -


i want ask simple question opengl es 2.x (or think valid of recent opengl releases).

which 1 of following faster? :

  1. attaching/detaching multiple shaders depending on draw,
  2. having uniform variable checking rendering mode; result of going have bunch of if-else conditions(or i.e. switch-case block). know no gpu cores; may assume render same group of primitives subsequently; i.e. not switch 1 mode frequently.

if may explain pros/cons of each solution; appreciated. third solution welcome.

that depends on volume of data compute, whenever fragment processing bound , many more things.

as rule of thumb, changing states should avoided when possible trigger pipeline flush. make thinks worse, changing uniform may trigger pipeline flush. if not using shaders throughput try conditional.

edit: if reorder data there small amount of state changes should ok change shader , allow output more fragments. again, depends on bottleneck.

tip: measure.


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -