internal/graphicsdriver/metal: do not call PresentDrawable when CommandBuffer is empty

Before this fix, PresentDrawable could be invoked even when the
CommandBuffer was empty. This might cause the flickering issue #3278.

This is an experimental (but seemingly valid) fix.

Updates #3278
This commit is contained in:
Hajime Hoshi
2025-08-25 18:12:54 +09:00
parent c3a43e057e
commit c830cf4c63

View File

@@ -229,7 +229,10 @@ func (g *Graphics) SetVertices(vertices []float32, indices []uint32) error {
}
func (g *Graphics) flushIfNeeded(present bool) {
if g.cb == (mtl.CommandBuffer{}) && !present {
if g.cb == (mtl.CommandBuffer{}) {
if g.rce != (mtl.RenderCommandEncoder{}) {
panic("metal: command buffer is empty but render command encoder is not empty")
}
return
}