internal/graphicsdriver/directx: smooth rendering when resizing the window with DirectX 12

Updates #2615
This commit is contained in:
Hajime Hoshi 2023-04-09 16:38:24 +09:00
parent 2423733598
commit 4473557e23

View File

@ -710,6 +710,8 @@ func (g *graphics12) End(present bool) error {
if err := g.resizeSwapChainDesktop(g.newScreenWidth, g.newScreenHeight); err != nil {
return err
}
g.screenImage.width = g.newScreenWidth
g.screenImage.height = g.newScreenHeight
g.newScreenWidth = 0
g.newScreenHeight = 0
}
@ -988,9 +990,14 @@ func (g *graphics12) NewImage(width, height int) (graphicsdriver.Image, error) {
}
func (g *graphics12) NewScreenFramebufferImage(width, height int) (graphicsdriver.Image, error) {
var imageWidth, imageHeight int
if g.screenImage != nil {
imageWidth, imageHeight = g.screenImage.width, g.screenImage.height
g.screenImage.Dispose()
g.screenImage = nil
} else {
imageWidth = width
imageHeight = height
}
if err := g.updateSwapChain(width, height); err != nil {
@ -1000,8 +1007,8 @@ func (g *graphics12) NewScreenFramebufferImage(width, height int) (graphicsdrive
i := &image12{
graphics: g,
id: g.genNextImageID(),
width: width,
height: height,
width: imageWidth,
height: imageHeight,
screen: true,
states: [frameCount]_D3D12_RESOURCE_STATES{0, 0},
}