(reproduced please specify the source)
As stated at the end of the previous section, a run-time error occurred:
d3d12 error:id3d12commandallocator::reset:a Command allocator is being Reset before previous executions associated W ITH the allocator has completed. [Execution ERROR #548: Command_allocator_sync]
That is, after the implementation of the relevant execution can not be reset, in their first impression that the submission of the presentation (Present), all the manipulation is done, but this does not seem to be the case, Microsoft has mentioned here:
Waiting for frame rendering is probably the coarsest-on-the-be certain, the GPU has finished. At a finer grain, you can again use fences
That is, it is not good enough to wait for the frame to finish rendering and assume that the GPU is done, preferably using fence:
All right, the fence is coming, the barricade is coming, Microsoft, you're not going to have a spike? ╮ ( ̄▽ ̄) ╭
Fence corresponding interface is id3d12fence, you can use Id3d12device::createfence to create this interface, the specific code is not tired, very simple.
This fence is in frames and can wait for all commands against this frame. Use id3d12fence::seteventoncompletion and id3d12commandqueue::signal for signal operation, then wait after the end, In frames.
However, there is a id3d12fence::signal, it seems possible that id3d12commandqueue::signal will call this method, otherwise this fence can not be bound with the command method.
so the approximate rendering process is:
- Fence-Seteventoncompletion
- Execute command
- Submit Rendering
- Queue--Signal
- Waitforxxxxxxxobject
The last time, this time is very simple. And I tried to put 3 on the back of 5 , too (looks like ?) No problem, but according to Microsoft's statement, still put in front of signal.
Download the accompanying code:
Click here
Direct3D 12 Early Adopters (ii): Fence