Fix macOS tests

Main thread locking hangs OpenGL emulators.
This commit is contained in:
Sergey Stepanov 2024-04-25 10:19:51 +03:00
parent a4f0dbbca8
commit 9b56ffc87c
No known key found for this signature in database
GPG key ID: A56B4929BAA8556B
5 changed files with 21 additions and 4 deletions

View file

@ -18,7 +18,7 @@ jobs:
build:
strategy:
matrix:
os: [ ubuntu-latest, macos-13, windows-latest ]
os: [ ubuntu-latest, macos-12, windows-latest ]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
@ -42,7 +42,7 @@ jobs:
xvfb-run --auto-servernum make test verify-cores
- name: macOS
if: matrix.os == 'macos-13'
if: matrix.os == 'macos-12'
run: |
brew install pkg-config libvpx x264 opus sdl2 jpeg-turbo
make build test verify-cores

View file

@ -169,6 +169,8 @@ func (n *Nanoarch) CoreLoad(meta Metadata) {
n.Video.gl.autoCtx = meta.AutoGlContext
n.Video.gl.enabled = meta.IsGlAllowed
thread.SwitchGraphics(n.Video.gl.enabled)
// hacks
Nan0.hackSkipHwContextDestroy = meta.HasHack("skip_hw_context_destroy")
@ -868,6 +870,7 @@ func deinitVideo() {
Nan0.Video.gl.enabled = false
Nan0.Video.gl.autoCtx = false
Nan0.hackSkipHwContextDestroy = false
thread.SwitchGraphics(false)
}
type limit struct {

View file

@ -13,6 +13,8 @@ type fun struct {
var dPool = sync.Pool{New: func() any { return make(chan struct{}) }}
var fq = make(chan fun, runtime.GOMAXPROCS(0))
var isGraphics = false
func init() {
runtime.LockOSThread()
}
@ -38,8 +40,17 @@ func Run(run func()) {
// Call queues function f on the main thread and blocks until the function f finishes.
func Call(f func()) {
if !isGraphics {
f()
return
}
done := dPool.Get().(chan struct{})
defer dPool.Put(done)
fq <- fun{fn: f, done: done}
<-done
}
func Switch(s bool) {
isGraphics = s
}

View file

@ -2,5 +2,6 @@
package thread
func Wrap(f func()) { f() }
func Main(f func()) { f() }
func Wrap(f func()) { f() }
func Main(f func()) { f() }
func SwitchGraphics(s bool) {}

View file

@ -8,3 +8,5 @@ func Wrap(f func()) { Run(f) }
// Main calls a function on the main thread.
func Main(f func()) { Call(f) }
func SwitchGraphics(s bool) { Switch(s) }