(转载请注明出处)
正如上节末尾所说, 出现了运行时错误:
D3D12 ERROR: ID3D12CommandAllocator::Reset: A command allocator is being reset before previous executions associated with the allocator have completed. [ EXECUTION ERROR #548: COMMAND_ALLOCATOR_SYNC]
就是说要在相关执行完成后才能重置, 在自己的第一印象中, 认为提交呈现(Present)后, 所有的操纵就完成了, 但这样似乎不是这样的, 微软在这里有提到:
Waiting for frame rendering is probably the coarsest way to be certain that the GPU has finished. At a finer grain, you can again use fences
就是说, 等待帧渲染完毕就认为GPU工作完毕了, 这种做法不够好, 最好使用Fence:
好了, 篱笆来了, 路障来了, 微软你不再来个钉刺带?╮( ̄▽ ̄)╭
Fence对应的接口就是