基本上,我正在使用由两个三角形和一个片段着色器组成的屏幕大小的矩形进行某种图像处理,它正在完成整个处理工作。实际效果类似于动画,因为它依赖于一个统一变量,称为current_frame
.
我对用“MPix/s”来衡量性能非常感兴趣。我所做的是这样的:
/* Setup all necessary stuff, including: */
/* - getting the location of the `current_frame` uniform */
/* - creating an FBO, adding a color attachment */
/* and setting it as the current one */
double current_frame = 0;
double step = 1.0f / NUMBER_OF_ITERATIONS;
tic(); /* Start counting the time */
for (i = 0; i < NUMBER_OF_ITERATIONS; i++)
{
glUniform1f(current_frame_handle, current_frame);
current_frame += step;
glDrawArrays(GL_TRIANGLES, 0, NUMBER_OF_INDICES);
glFinish();
}
double elapsed_time = tac(); /* Get elapsed time in seconds */
/* Calculate achieved pixels per second */
double pps = (OUT_WIDTH * OUT_HEIGHT * NUMBER_OF_ITERATIONS) / elapsed_time;
/* Sanity check by using reading the output into a buffer */
/* using glReadPixels and saving this buffer into a file */
就理论而言,我的概念有什么问题吗?
此外,我的印象是,glFinish()
在移动硬件上不一定要等待先前的渲染调用,并且可能会进行一些优化。
当然,我总是可以在每次抽签后强制执行glReadPixels()
,但这会很慢,所以这并没有真正的帮助。
你能否告诉我我的测试场景是否合理以及是否还有更多可以做的事情。