Skip to content

Commit

Permalink
Fix mac
Browse files Browse the repository at this point in the history
  • Loading branch information
sergystepanov committed Apr 25, 2024
1 parent d1c71c4 commit 3b65dd8
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 4 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
3 changes: 3 additions & 0 deletions pkg/worker/caged/libretro/nanoarch/nanoarch.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,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")

Expand Down Expand Up @@ -934,6 +936,7 @@ func deinitVideo() {
Nan0.Video.gl.enabled = false
Nan0.Video.gl.autoCtx = false
Nan0.hackSkipHwContextDestroy = false
thread.SwitchGraphics(false)
}

type limit struct {
Expand Down
11 changes: 11 additions & 0 deletions pkg/worker/thread/mainthread_darwin.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand All @@ -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
}
5 changes: 3 additions & 2 deletions pkg/worker/thread/thread.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {}
2 changes: 2 additions & 0 deletions pkg/worker/thread/thread_darwin.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) }

0 comments on commit 3b65dd8

Please sign in to comment.