internal/graphicsdriver/directx: update frameIndex at present

This follows the official GDK samples.
This commit is contained in:
Hajime Hoshi 2022-06-18 01:09:46 +09:00
parent b5bbebcccb
commit a16ffef499

View File

@ -612,13 +612,6 @@ func (g *Graphics) SetWindow(window uintptr) {
}
func (g *Graphics) Begin() error {
g.frameIndex = 0
// The swap chain is initialized when NewScreenFramebufferImage is called.
// This must be called at the first frame.
if g.swapChain != nil {
g.frameIndex = int(g.swapChain.GetCurrentBackBufferIndex())
}
if err := g.drawCommandList.Reset(g.drawCommandAllocators[g.frameIndex], nil); err != nil {
return err
}
@ -691,6 +684,9 @@ func (g *Graphics) End(present bool) error {
if err := g.releaseCommandAllocators(nextIndex); err != nil {
return err
}
// Move to the next frame.
g.frameIndex = int(g.swapChain.GetCurrentBackBufferIndex())
}
return nil
}