更具体地说,我有两个线程。
第一个:
ev_wait_vsync = CreateEvent(NULL, FALSE, FALSE, "wait_vsync");
...
printf("paint\n");
sync = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
SetEvent(ev_wait_vsync);
第二个,由第一个创建:
WaitForSingleObject(ev_wait_vsync, INFINITE);
printf("start vsync\n");
glClientWaitSync(sync, GL_SYNC_FLUSH_COMMANDS_BIT, UINT64_MAX);
printf("end sync\n");
这会导致段错误。输出是:
paint
start vsync
所以问题出在glClientWaitSync
,但为什么呢?