diff --git a/internal/graphicsdriver/directx/graphics_windows.go b/internal/graphicsdriver/directx/graphics_windows.go index c952874b1..93522566c 100644 --- a/internal/graphicsdriver/directx/graphics_windows.go +++ b/internal/graphicsdriver/directx/graphics_windows.go @@ -134,7 +134,8 @@ type Graphics struct { window windows.HWND - frameIndex int + frameIndex int + prevBeginFrameIndex int // frameStarted is true since Begin until End with present frameStarted bool @@ -694,6 +695,8 @@ func (g *Graphics) resizeSwapChainDesktop(width, height int) error { // TODO: Reset 0 on Xbox g.frameIndex = int(g.swapChain.GetCurrentBackBufferIndex()) + // TODO: Are these resetting necessary? + if err := g.drawCommandAllocators[g.frameIndex].Reset(); err != nil { return err } @@ -751,14 +754,17 @@ func (g *Graphics) Begin() error { } g.frameStarted = true - if err := g.drawCommandAllocators[g.frameIndex].Reset(); err != nil { - return err - } - if err := g.drawCommandList.Reset(g.drawCommandAllocators[g.frameIndex], nil); err != nil { - return err + if g.prevBeginFrameIndex != g.frameIndex { + if err := g.drawCommandAllocators[g.frameIndex].Reset(); err != nil { + return err + } + if err := g.copyCommandAllocators[g.frameIndex].Reset(); err != nil { + return err + } } + g.prevBeginFrameIndex = g.frameIndex - if err := g.copyCommandAllocators[g.frameIndex].Reset(); err != nil { + if err := g.drawCommandList.Reset(g.drawCommandAllocators[g.frameIndex], nil); err != nil { return err } if err := g.copyCommandList.Reset(g.copyCommandAllocators[g.frameIndex], nil); err != nil {