glFlush()在带有透明背景的窗口上花费很长时间 [英] glFlush() takes very long time on window with transparent background

查看:91
本文介绍了glFlush()在带有透明背景的窗口上花费很长时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用了​​中的代码制作具有透明背景的OpenGL渲染上下文?以创建具有透明背景的窗口.我的问题是帧速率非常低-即使我画出一个四边形(由2个三角形组成),我也有大约20帧/秒.我试图找出原因,而glFlush()大约需要0.047秒.你知道为什么吗在不具有6000 fps透明背景的窗口中渲染相同的内容(当我删除60 fps限制时).它也需要一个核心达到100%.我使用Win7在带有ATI Radeon 4800的Q9450@2.66GHz上进行了测试.

I used the code from How to make an OpenGL rendering context with transparent background? to create a window with transparent background. My problem is that the frame rate is very low - I have around 20 frames/sec even when I draw one quad(made from 2 triangles). I tried to find out why and glFlush() takes around 0.047 seconds. Do you have any idea why? Same thing is rendered in a window that does not have transparent background at 6000 fps(when I remove 60 fps limitation). It also takes one core to 100%. I test it on a Q9450@2.66GHz with ATI Radeon 4800 using Win7.

推荐答案

我认为您无法通过这种方式获得良好的性能,在链接的示例中,有以下代码

I think you can't get good performances this way, In the example linked there is the following code

void draw(HDC pdcDest)
{
    assert(pdcDIB);
    verify(BitBlt(pdcDest, 0, 0, w, h, pdcDIB, 0, 0, SRCCOPY));
}

BitBlt是在处理器上执行的功能,而OpenGL功能则由GPU执行.因此,从GPU渲染的数据将爬回主内存,并有效地限制了从GPU到CPU的带宽(甚至更多,因为一旦BitBlt被使用,数据就将返回到主内存).

BitBlt is a function executed on the processor, whereas the OpenGL functions are executed by the GPU. So the rendered data from the GPU as to crawl back to the main memory, and effectively the bandwidth from the GPU to the CPU is somewhat limited (even more because data as to go back there once BitBlt'ed).

如果您确实想要带有渲染内容的透明窗口,则可能需要查看Direct2D和/或Direct3D,也许可以通过某些方法来实现,而不会影响数据移动的性能.

If you really want transparent window with rendered content, you might want to look at Direct2D and/or Direct3D, maybe there is some way to do that without the performance penalty of data moving.

这篇关于glFlush()在带有透明背景的窗口上花费很长时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆