Skip to content

Commit

Permalink
perf: Enable ebiten single thread mode
Browse files Browse the repository at this point in the history
  • Loading branch information
gabe565 committed May 13, 2024
1 parent dc110a7 commit c724005
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 20 deletions.
7 changes: 4 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ env:
libxinerama-dev
libxrandr-dev
libxxf86vm-dev
BUILD_TAGS: gzip,ebitenginesinglethread

jobs:
lint:
Expand Down Expand Up @@ -133,7 +134,7 @@ jobs:
- name: Build
env:
CGO_ENABLED: "1"
run: go build -ldflags='-w -s' -trimpath -tags gzip -o dist/gones
run: go build -ldflags='-w -s' -trimpath -tags "${{ env.BUILD_TAGS }}" -o dist/gones
- name: Compress
run: tar -cvf gones_linux_amd64.tar.gz -C dist .
- name: Upload Artifact
Expand Down Expand Up @@ -176,7 +177,7 @@ jobs:
-v "$(go env GOMODCACHE):/go/pkg/mod" \
-v "$PWD:/app" \
builder \
go build -ldflags='-w -s' -trimpath -tags gzip -o dist/gones
go build -ldflags='-w -s' -trimpath -tags "${{ env.BUILD_TAGS }}" -o dist/gones
- name: Compress
run: tar -cvf gones_linux_arm64.tar.gz -C dist .
- name: Upload Artifact
Expand All @@ -202,7 +203,7 @@ jobs:
env:
GOOS: js
GOARCH: wasm
run: go build -ldflags='-w -s' -trimpath -tags gzip -o web/src/assets/gones.wasm
run: go build -ldflags='-w -s' -trimpath -tags "${{ env.BUILD_TAGS }}" -o web/src/assets/gones.wasm
- name: Set up Node
uses: actions/setup-node@v4
with:
Expand Down
8 changes: 7 additions & 1 deletion cmd/gones/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"errors"
"os"
"os/signal"
"runtime"

"github.com/gabe565/gones/internal/config"
"github.com/gabe565/gones/internal/console"
Expand Down Expand Up @@ -67,12 +68,17 @@ func run(cmd *cobra.Command, args []string) error {
ebiten.SetFullscreen(conf.UI.Fullscreen)
ebiten.SetScreenClearedEveryFrame(false)
ebiten.SetRunnableOnUnfocused(!conf.UI.PauseUnfocused)
if runtime.GOOS != "darwin" {
ebiten.SetWindowIcon(getWindowIcons())
}

if name := c.Cartridge.Name(); name != "" {
ebiten.SetWindowTitle(name + " | GoNES")
}

if err := ebiten.RunGame(c); err != nil && !errors.Is(err, console.ErrExit) {
if err := ebiten.RunGameWithOptions(c, &ebiten.RunGameOptions{
SingleThread: true,
}); err != nil && !errors.Is(err, console.ErrExit) {
return err
}

Expand Down
5 changes: 2 additions & 3 deletions cmd/gones/get_icons.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
func getWindowIcons() []image.Image {
icons := make([]image.Image, 0, 3)

err := fs.WalkDir(assets.Icons, ".", func(path string, d fs.DirEntry, err error) error {
if err := fs.WalkDir(assets.Icons, ".", func(path string, d fs.DirEntry, err error) error {
if err != nil || d.IsDir() {
return err
}
Expand All @@ -34,8 +34,7 @@ func getWindowIcons() []image.Image {

icons = append(icons, icon)
return nil
})
if err != nil {
}); err != nil {
log.Err(err).Msg("Failed to load icons")
}

Expand Down
11 changes: 0 additions & 11 deletions cmd/gones/window_icon.go

This file was deleted.

2 changes: 1 addition & 1 deletion hack/build-darwin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ go generate
export GOOS=darwin CGO_ENABLED=1
for ARCH in amd64 arm64; do
echo Build "$BINARY_NAME-$ARCH"
GOARCH="$ARCH" go build -ldflags='-w -s' -trimpath -tags gzip -o "dist/$BINARY_NAME-$ARCH" .
GOARCH="$ARCH" go build -ldflags='-w -s' -trimpath -tags gzip,ebitenginesinglethread -o "dist/$BINARY_NAME-$ARCH" .
done

# Merge binaries
Expand Down
2 changes: 1 addition & 1 deletion hack/build-windows.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ go generate
export GOOS=windows CGO_ENABLED=1
for ARCH in amd64 arm64; do
echo Build "$BINARY_NAME-$ARCH.exe"
GOARCH="$ARCH" go build -ldflags='-w -s -H=windowsgui' -trimpath -tags gzip -o "dist/$BINARY_NAME-$ARCH.exe" .
GOARCH="$ARCH" go build -ldflags='-w -s -H=windowsgui' -trimpath -tags gzip,ebitenginesinglethread -o "dist/$BINARY_NAME-$ARCH.exe" .
done

0 comments on commit c724005

Please sign in to comment.