From c126dea7fb929ad53397ec616b22ec34a922089b Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Fri, 2 Sep 2022 02:27:40 +0900 Subject: [PATCH] Revert "internal/graphicsdriver/directx: bug fix: do not reset command allocators at Begin" This reverts commit 9d303e8dc515053a0f4183f4632ea3253543c45d. Reason: A GPU memory leak (#2292). Though this reverting reveals the error #2249 again, a memory leak is more critical. Then revert the change once, and then take time to investigate how to resolve #2249. Closes #2292 Updates #2249 --- .../directx/graphics_windows.go | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/internal/graphicsdriver/directx/graphics_windows.go b/internal/graphicsdriver/directx/graphics_windows.go index 119ec0c27..9cba3350e 100644 --- a/internal/graphicsdriver/directx/graphics_windows.go +++ b/internal/graphicsdriver/directx/graphics_windows.go @@ -684,12 +684,16 @@ func (g *Graphics) resizeSwapChainDesktop(width, height int) error { // TODO: Reset 0 on Xbox g.frameIndex = int(g.swapChain.GetCurrentBackBufferIndex()) - // Do not reset the command allocators here (#2249). - // The command allocators are reset at flushCommnadList. - + 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 err := g.copyCommandAllocators[g.frameIndex].Reset(); err != nil { + return err + } if err := g.copyCommandList.Reset(g.copyCommandAllocators[g.frameIndex], nil); err != nil { return err } @@ -737,12 +741,16 @@ func (g *Graphics) Begin() error { } g.frameStarted = true - // Do not reset the command allocators here (#2249). - // The command allocators are reset at flushCommnadList. - + 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 err := g.copyCommandAllocators[g.frameIndex].Reset(); err != nil { + return err + } if err := g.copyCommandList.Reset(g.copyCommandAllocators[g.frameIndex], nil); err != nil { return err }