internal/graphicsdriver/directx: refactoring

This commit is contained in:
Hajime Hoshi 2022-10-15 12:16:41 +09:00
parent e796646abd
commit 35e9f26681
2 changed files with 3 additions and 7 deletions

View File

@ -179,7 +179,6 @@ func (q *commandQueue) flush(graphicsDriver graphicsdriver.Graphics, endFrame bo
if err := graphicsDriver.Begin(); err != nil {
return err
}
var screenRendered bool
cs := q.commands
for len(cs) > 0 {
nv := 0
@ -195,9 +194,6 @@ func (q *commandQueue) flush(graphicsDriver graphicsdriver.Graphics, endFrame bo
}
nv += dtc.numVertices()
ne += dtc.numIndices()
if dtc.dst.screen {
screenRendered = true
}
}
nc++
}
@ -223,8 +219,7 @@ func (q *commandQueue) flush(graphicsDriver graphicsdriver.Graphics, endFrame bo
}
cs = cs[nc:]
}
// TODO: Without checking screenRendered, the tests fail on Windows. Investigate this issue.
if err := graphicsDriver.End(endFrame && screenRendered); err != nil {
if err := graphicsDriver.End(endFrame); err != nil {
return err
}

View File

@ -774,7 +774,8 @@ func (g *Graphics) End(present bool) error {
return err
}
if present {
// screenImage can be nil in tests.
if present && g.screenImage != nil {
if rb, ok := g.screenImage.transiteState(_D3D12_RESOURCE_STATE_PRESENT); ok {
g.drawCommandList.ResourceBarrier([]_D3D12_RESOURCE_BARRIER_Transition{rb})
}