From a16ffef499488f7c37cfbd5bfc3d8f7ef1ba7e22 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Sat, 18 Jun 2022 01:09:46 +0900 Subject: [PATCH] internal/graphicsdriver/directx: update frameIndex at present This follows the official GDK samples. --- internal/graphicsdriver/directx/graphics_windows.go | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/internal/graphicsdriver/directx/graphics_windows.go b/internal/graphicsdriver/directx/graphics_windows.go index 8b46c088a..efb8ae403 100644 --- a/internal/graphicsdriver/directx/graphics_windows.go +++ b/internal/graphicsdriver/directx/graphics_windows.go @@ -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 }