- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
运行有区别吗
glFinish()
正在运行
glFenceSync(...)
glClientWaitSync(...)
超时时间长吗?
我正在尝试做的事情:我运行一个 OpenGL 命令管道,我想计算每个命令需要多长时间。如果没有上述任何命令,所有内容都将被流水线化/缓冲,看起来好像最后一条命令占用了所有处理时间。
timer start
Run Opengl part 1
sync / glFinish
timer measure
Run Opengl part 2
sync / glFinish
timer measure
...
所以我想弄清楚如何最好地衡量各个部分的“速度”,同时又不会对整体运行时间产生太大影响。
最佳答案
您提到的所有选项都会影响应用程序的性能,因为它们会使管道停止。在 OpenGL 中测量时间的现代方法是使用计时器查询:您告诉 OpenGL 它应该在 GPU 上执行查询时保存时间戳,因此不需要 GPU 和 CPU 之间的同步。例如,代码可能如下所示:
GLuint64 startTime, stopTime;
unsigned int queryID[2];
// generate two queries
glGenQueries(2, queryID);
...
// issue the first query
// Records the time only after all previous
// commands have been completed
glQueryCounter(queryID[0], GL_TIMESTAMP);
// call a sequence of OpenGL commands
...
// issue the second query
// records the time when the sequence of OpenGL
// commands has been fully executed
glQueryCounter(queryID[1], GL_TIMESTAMP);
...
// get query results
// (automatically blocks until results are available)
glGetQueryObjectui64v(queryID[0], GL_QUERY_RESULT, &startTime);
glGetQueryObjectui64v(queryID[1], GL_QUERY_RESULT, &stopTime);
printf("Time spent on the GPU: %f ms\n", (stopTime - startTime) / 1000000.0);
(代码取自 Lighthouse3d.com )。
另一种选择是将 glBeginQuery
与 GL_TIME_ELAPSED
参数一起使用,链接文章中也对此进行了描述。
关于c++ - glFinish() 与 glFenceSync() + glClientWaitSync(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34265366/
我在我的应用程序中使用了两个 OpenGL 上下文。 第一个用于渲染数据,第二个用于后台加载和生成 VBO 和纹理。 当我的加载上下文生成一个 VBO 并将其发送到我的渲染线程时,除非我调用 glFl
以下代码在 Nvidia 驱动程序 361.91(及更早版本)中运行良好(Windows 7、Nvidia GTX 750 Ti),但在 364.72 和 368.69 等较新版本中挂起。现在,只有在
上下文:我正在测量 Qt 测试应用程序图形渲染期间的 cpu 使用情况。渲染是通过 Qt Quick 模块完成的,该模块使用基于 OpenGL 的专用场景图。 环境:我在运行 Windows CE 的
运行有区别吗 glFinish() 正在运行 glFenceSync(...) glClientWaitSync(...) 超时时间长吗? 我正在尝试做的事情:我运行一个 OpenGL 命令管道,我想
我无法区分调用 glFlush() 和 glFinish() 之间的实际区别。 文档说 glFlush() 和 glFinish() 会将所有缓冲的操作推送到 OpenGL,这样就可以确保它们都会被执
我使用的是 FBO+RBO,并且不是在默认帧缓冲区上进行常规双缓冲,而是绘制到 RBO,然后直接在单个缓冲 OpenGL 上下文中的默认 FBO (0) 的 GL_FRONT 缓冲区上进行 blit。
我最近将我的旧 Galaxy S2 手机升级到全新的 Galaxy S7,并且非常惊讶地发现我编写的旧游戏在新手机上的表现似乎更差。将所有内容简化为一个简单的项目后,我发现了问题 - 我在每个 onD
在OpenGL ES Programming Guide他们说: To summarize, your app needs to call the glFinish function to ensur
使用 NSOpenGLView 时有几个类似的 OpenGL 操作: glFlush() [[self openGLContext]flushBuffer] glFinish() glSwapAPPL
我是一名优秀的程序员,十分优秀!