mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-25 03:08:54 +01:00
internal/graphicsdriver/directx: adjust buffer count
Apparently the buffer count should be 1 with a non-flipping swap effect. Updates #2613
This commit is contained in:
parent
61ced5127b
commit
09250ff4f3
@ -156,6 +156,8 @@ type graphicsInfra struct {
|
|||||||
|
|
||||||
// lastTime is the last time for rendering.
|
// lastTime is the last time for rendering.
|
||||||
lastTime time.Time
|
lastTime time.Time
|
||||||
|
|
||||||
|
bufferCount int
|
||||||
}
|
}
|
||||||
|
|
||||||
func newGraphicsInfra() (*graphicsInfra, error) {
|
func newGraphicsInfra() (*graphicsInfra, error) {
|
||||||
@ -275,8 +277,11 @@ func (g *graphicsInfra) initSwapChain(width, height int, device unsafe.Pointer,
|
|||||||
// https://learn.microsoft.com/en-us/windows/win32/api/dxgi/ne-dxgi-dxgi_swap_effect
|
// https://learn.microsoft.com/en-us/windows/win32/api/dxgi/ne-dxgi-dxgi_swap_effect
|
||||||
if !isWindows10OrGreaterWin32() {
|
if !isWindows10OrGreaterWin32() {
|
||||||
desc.SwapEffect = _DXGI_SWAP_EFFECT_SEQUENTIAL
|
desc.SwapEffect = _DXGI_SWAP_EFFECT_SEQUENTIAL
|
||||||
|
desc.BufferCount = 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
g.bufferCount = int(desc.BufferCount)
|
||||||
|
|
||||||
if g.allowTearing {
|
if g.allowTearing {
|
||||||
desc.Flags |= uint32(_DXGI_SWAP_CHAIN_FLAG_ALLOW_TEARING)
|
desc.Flags |= uint32(_DXGI_SWAP_CHAIN_FLAG_ALLOW_TEARING)
|
||||||
}
|
}
|
||||||
@ -313,7 +318,7 @@ func (g *graphicsInfra) resizeSwapChain(width, height int) error {
|
|||||||
if g.allowTearing {
|
if g.allowTearing {
|
||||||
flag |= uint32(_DXGI_SWAP_CHAIN_FLAG_ALLOW_TEARING)
|
flag |= uint32(_DXGI_SWAP_CHAIN_FLAG_ALLOW_TEARING)
|
||||||
}
|
}
|
||||||
if err := g.swapChain.ResizeBuffers(frameCount, uint32(width), uint32(height), _DXGI_FORMAT_B8G8R8A8_UNORM, flag); err != nil {
|
if err := g.swapChain.ResizeBuffers(uint32(g.bufferCount), uint32(width), uint32(height), _DXGI_FORMAT_B8G8R8A8_UNORM, flag); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
Loading…
Reference in New Issue
Block a user