opengl - Best method to copy texture to texture -


what best method copy pixels texture texture?

i've found ways accomplish this. instance, there's method glcopyimagesubdata() target version opengl 2.1, cannot use it. also, because performance important, glgetteximage2d() not option. since i'm handling video frames texture, have make copies 30~60 times per second.

available options found next:

  1. create fbo source texture , copy destination texture using glcopytexsubimage2d().
  2. create fbos source , destination textures , blit fbos.
  3. create fbo destination texture , render source texture fbo.

you can ignore cost of creation of fbo because fbo created once.

please don't post 'it depends. benchmark.'. i'm not targeting 1 gpu. if depends, please, please let me know how depends on what.

furthermore, because difficult measure timing of opengl calls, want know not quantitative result. need advices method should avoid.

if know better method copy textures, please let me know too.

thank reading.

since didn't know timer query, didn't think of benchmarking. now, can own benchmarks. i've measured tming each 100 operations , repeated 5 times. cost create fbos not included.

- s=source texture, d=destination texture, sf=fbo of s, df=fbo of d - operation=copying texture texture - op/s = how many operations 1 second(average), larger better 
  1. create df , render s df using simple passthrough shader

    • 945.656op/s (105.747ms 100 operations)
    • 947.293op/s (105.564ms 100 operations)
    • 949.099op/s (105.363ms 100 operations)
    • 949.324op/s (105.338ms 100 operations)
    • 948.215op/s (105.461ms 100 operations)
  2. create sf , use glcopytexsubimage2d() d

    • 937.263op/s (106.694ms 100 operations)
    • 940.941op/s (106.277ms 100 operations)
    • 941.722op/s (106.188ms 100 operations)
    • 941.145op/s (106.254ms 100 operations)
    • 940.997op/s (106.270ms 100 operations)
  3. create df , sf , use glblitframebuffer()

    • 828.172op/s (120.748ms 100 operations)
    • 843.612op/s (118.538ms 100 operations)
    • 845.377op/s (118.290ms 100 operations)
    • 847.024op/s (118.060ms 100 operations)
    • 843.303op/s (118.581ms 100 operations)
  4. create df , sf , use glcopypixels()

    • 525.711op/s (190.219ms 100 operations)
    • 523.396op/s (191.060ms 100 operations)
    • 537.605op/s (186.010ms 100 operations)
    • 538.560op/s (185.680ms 100 operations)
    • 553.059op/s (180.813ms 100 operations)

performance comparision

passthrough shader ~ glcopytexsubimage2d > glblitframebuffer >> glcopypixels 

so, simple passthrough shader shows best performance copy textures. glcopytexsubimage2d slower passthrough shader. fbo-blitting fast enough worse shader , glcopytexsubimage2d. glcopypixels, didn't expected result, shows worst performance expectation.


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -