mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-10-28 10:21:42 +08:00
graphicsdriver/metal, graphicsdriver/opengl: Reland: Remove the thread usages for performance
Instead, graphicscommand package has a thread. Updates #1367
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user