使用 OpenGL 程序时会使用 GPU 的强大功能吗?
我有一个相当旧的 ATI HD 3400 显卡,它不支持 OpenCL,所以我想知道我是否可以真正使用 ATI Catalyst 驱动程序提供的 OpenGL 库?
如果我的算法在 glutDisplayFunc (displayFunc)
中运行,即在 displayFun ()
中运行,它实际上会消耗 CPU 功率还是 GPU 功率?
I've got a pretty old ATI HD 3400 video card , which have no support of OpenCL , so i'm wondering if i can actually play around with OpenGL libraries provided by ATI catalyst driver ?
If my algorithm is running in glutDisplayFunc ( displayFunc )
, that is in displayFun ()
, is it actually costing CPU power or GPU power ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
GLUT 只是一个管理特定于平台的窗口和 GL 上下文创建的库。您传递给 glutDisplayFunc 的函数只是由 GLUT 在适当的时间和您所运行的平台的上下文中调用;它不在 GPU 上执行。
不可能将您以正常方式编译的代码作为在 GPU 上运行的较大程序的一部分。
然而,在显示函数内部运行的各个图形操作当然会在 GPU 上执行渲染; CPU仍在计算要执行的图形操作,但并不实际渲染结果。每个
gl
函数都是普通的 CPU 函数,但它的作用是通过系统总线向显卡发送命令,然后由显卡进行实际渲染。此外,这些操作是异步的;
gl
函数不会等待 GPU 完成操作才让程序继续运行。这很有用,因为您的 CPU 和 GPU 可以同时工作 - GPU 绘制图形,而 CPU 则确定要绘制什么图形。另一方面,如果您确实需要另一个方向的通信(例如glReadPixels
),那么 CPU 必须等待 GPU 赶上。这也是glFlush
和glFinish
之间的区别。GLUT is just a library which manages platform-specific window and GL context creation. The function you pass to
glutDisplayFunc
is just called by GLUT at the appropriate time and context for the platform you're running on; it is not executed on the GPU.It is not possible to have code that you've compiled in the normal fashion as part of a larger program run on the GPU.
However, the individual graphics operations run inside of your display func do of course perform the rendering on the GPU; the CPU is still computing which graphics operation to execute, but not actually rendering the results. Each
gl
function is a normal CPU function, but what it does is send a command through your system bus to your graphics card, which then does the actual rendering.Furthermore, these operations are asynchronous; the
gl
functions don't wait for your GPU to finish the operation before letting your program continue. This is useful because your CPU and GPU can both be working simultaneously — the GPU draws graphics while the CPU figures out what graphics to draw. On the other hand, if you do need communication in the other direction — such asglReadPixels
— then the CPU has to wait for the GPU to catch up. This is also the difference betweenglFlush
andglFinish
.