Note that there are some explanatory texts on larger screens.

plurals
  1. POAsynchronous glReadPixels with PBO
    text
    copied!<p>I want to use two PBOs to read pixel in alternative way. I thought the PBO way will much faster, because glReadPixels returns immediately when using PBO, and a lot of time can be overlapped.</p> <p>Strangely there seems to be not much benefit. Considering some code like:</p> <pre><code> glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, 0); Timer t; t.start(); glReadPixels(0,0,1024,1024,GL_RGBA, GL_UNSIGNED_BYTE, buf); t.stop(); std::cout &lt;&lt; t.getElapsedTimeInMilliSec() &lt;&lt; " "; glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, pbo); t.start(); glReadPixels(0,0,1024,1024,GL_RGBA, GL_UNSIGNED_BYTE, 0); t.stop(); std::cout &lt;&lt; t.getElapsedTimeInMilliSec() &lt;&lt; std::endl; </code></pre> <p>The result is </p> <pre><code>1.301 1.185 1.294 1.19 1.28 1.191 1.341 1.254 1.327 1.201 1.304 1.19 1.352 1.235 </code></pre> <p>The PBO way is a little faster, but not a satisfactory <strong>immediate-return</strong>。</p> <p>My question is:</p> <ul> <li>What is the factor affecting glReadPixels' performance? Somethimes, the cost of it reaches 10ms, but 1.3ms here.</li> <li><del>Why <strong>immediate-return</strong> costs as much as 1.2ms? Is it too big or just normal?</del></li> </ul> <p>===========================================================================</p> <p>According to comparison with a demo, I found two factors:</p> <ul> <li>GL_BGRA is better than GL_RGBA, 1.3ms=>1.0ms(no PBO), 1.2ms=>0.9ms(with pbo)</li> <li>glutInitDisplayMode(GLUT_RGB|GLUT_ALPHA) rather than GLUT_RGBA, 0.9ms=>0.01ms。That's the performance I want. In my system, GLUT_RGBA=GLUT_RGB=0. GLUT_ALPHA=8</li> </ul> <p>Then another two questions:</p> <ul> <li>Why GL_BGRA is better than GL_RGBA? Is it the case for just specific platform or for all platforms? </li> <li>Why GLUT_ALPHA is so important that it affects PBO performance hugely?</li> </ul>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload