graphicsdriver/metal, graphicsdriver/opengl: Reland: Remove the thread usages for performance

Instead, graphicscommand package has a thread.

Updates #1367
This commit is contained in:
Hajime Hoshi
2020-10-13 00:39:45 +09:00
parent 713eee1117
commit eed619ad0f
12 changed files with 548 additions and 739 deletions

View File

@@ -200,10 +200,19 @@ func (q *commandQueue) Enqueue(command command) {
// Flush flushes the command queue.
func (q *commandQueue) Flush() error {
return RunOnMainThread(func() error {
return q.flush()
})
}
// flush must be called the main thread.
func (q *commandQueue) flush() error {
if len(q.commands) == 0 {
return nil
}
// TODO: Use thread.Call here!
es := q.indices
vs := q.vertices
if recordLog() {
@@ -716,10 +725,17 @@ func (c *newShaderCommand) CanMergeWithDrawTrianglesCommand(dst *Image, src [gra
// ResetGraphicsDriverState resets or initializes the current graphics driver state.
func ResetGraphicsDriverState() error {
return theGraphicsDriver.Reset()
return RunOnMainThread(func() error {
return theGraphicsDriver.Reset()
})
}
// MaxImageSize returns the maximum size of an image.
func MaxImageSize() int {
return theGraphicsDriver.MaxImageSize()
var size int
_ = RunOnMainThread(func() error {
size = theGraphicsDriver.MaxImageSize()
return nil
})
return size
}