OpenGL : 看完glWaitSync函数描述后产生的一点疑问

OpenGL : 看完glWaitSync函数描述后产生的一点疑问?

根据OpenGL的WIKi文档:Sync Object - OpenGL.org

glWaitSync会阻止GPU向commandQueue中issue新的command,直到sync object被signal为止。
所以调用这个函数之前要调用glflush,保证sync object 在command queue中执行,避免sync object不在command queue中,而glWaitSync又阻止GPU向command queue中提交新command这样一种死循环。

我的问题是:那为什么不让使用GLbitfield flags参数,把这个参数像glClientWaitSync一样设置为GL_SYNC_FLUSH_COMMANDS_BIT不就行了吗?而这里必须要手动的去调用glflush。


这个函数的描述如下:
void glWaitSync?(GLsync sync, GLbitfield flags, GLuint64 timeout)
 

Recall the discussion in the article on Synchronization about the difference between the GPU's command queue and the driver's internal command buffer. WhatglWaitSync? does is prevent the driver from adding any commands to the GPU's command queue until this sync object is signaled. This function does not wait for this to happen.

The driver will still put commands in its internal buffer. But none of them will be seen by the GPU until this sync object is signaled.

You need to perform a glFlush? before calling this, to ensure that the sync object is in the GPU's command queue. If you don't, then you may create an infinite loop. Since glWaitSync? prevents the driver from adding any commands to the GPU command queue, this would include the sync object itself if it has not yet been added to the queue. This function does not take the GL_SYNC_FLUSH_COMMANDS_BIT, so you have to do it manually.

关注者

6

被浏览

569

关注问题写回答

?邀请回答

?添加评论

?分享

?

收起

1 个回答

默认排序?

知乎用户

1 人赞同了该回答

其实你写的描述当中已经有了问题的答案:

This function does not take the GL_SYNC_FLUSH_COMMANDS_BIT, so you have to do it with a manual glFlush call;

glWaitSync()函数本身的参数是没有GL_SYNC_FLUSH_COMMANDS_BIT的,你又怎么能够调用它呢?

猜你喜欢

转载自blog.csdn.net/qq_21743659/article/details/107530847