Skip to content

feat(macos): software backend blit #163#187

Merged
kolkov merged 9 commits into
gogpu:mainfrom
k-chimi:feat/macos-software-backend-blit-163
May 20, 2026
Merged

feat(macos): software backend blit #163#187
kolkov merged 9 commits into
gogpu:mainfrom
k-chimi:feat/macos-software-backend-blit-163

Conversation

@k-chimi
Copy link
Copy Markdown
Contributor

@k-chimi k-chimi commented May 20, 2026

resolve #163

Rebased onto origin/main by git rebase origin/main.

I confirmed renders triangle correctly in gogpu/examples/triangle (GOGPU_GRAPHICS_API=software)

image

@k-chimi k-chimi requested a review from kolkov as a code owner May 20, 2026 03:02
@codecov
Copy link
Copy Markdown

codecov Bot commented May 20, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@kolkov
Copy link
Copy Markdown
Contributor

kolkov commented May 20, 2026

Code Review: PR #187

Thank you for applying all review fixes and rebasing onto main! Triangle rendering on macOS confirmed — great work.

All review fixes applied ✅

Fix Status Verified
isIinitializedisInitialized Fixed lines 30, 66, 78
TODO comment Removed grep returns empty
Commented slog.Warn Removed grep returns empty
Debug slog.Debug("width ret") Removed grep returns empty
Commented RegionMake2D Removed grep returns empty
Naming blitFramebufferToWindow Consistent lowercase lines 88, 114, 248, 260
CAMetalLayer damage rects Full blit fallback lines 141-146

CI: macOS test crash (only blocker)

signal arrived during cgo execution
fault   0x1
FAIL    github.com/gogpu/wgpu/hal/software    3.515s

The macOS CI runner is headless (no display, no Metal GPU). platformBlit.init() loads Metal framework and calls MTLCreateSystemDefaultDevice() via ffi.CallFunction — the FFI call itself segfaults before returning an error on the headless runner.

Windows and Ubuntu tests were cancelled (not failed) — CI auto-cancels remaining jobs when one fails. Those platforms are unaffected.

Suggested fix: Check if the Metal framework file exists on disk before calling ffi.LoadLibrary:

func (m *metal) Open(objc *objcReflect) (err error) {
    // Skip Metal on headless CI / environments without GPU
    if _, err := os.Stat(metalLibraryLocation); err != nil {
        return fmt.Errorf("software.metal: framework not found: %w", err)
    }
    // ... existing code
}

Or, if the framework exists but MTLCreateSystemDefaultDevice returns nil (no GPU), ensure the nil check in init() (line 55-58) is reached before the segfault. The crash may happen inside ffi.CallFunction itself when Metal runtime initializes on a headless system.

Code quality — verified claims

Claim Evidence
1302 LOC wc -l = 1302 ✅
--- BEGIN/END OBJC BINDING --- sections lines 322, 1302 ✅
Selector caching sync.Map selCaches/clsCaches at lines 1051-1052 ✅
objc_msgSend_stret/_fpret dispatch lines 1044-1046, 1121-1128 ✅
runtime.KeepAlive(args) line 1114 ✅
BGRA format ByteOrder32Little | PremultipliedFirst lines 162-163, 735, 742 ✅
runtime import used lines 1114, 1121, 1127 (KeepAlive, GOARCH checks) ✅

Action needed

Fix the headless macOS CI crash — this is the only blocker. Once hal/software tests pass on macOS CI, we merge.

@k-chimi
Copy link
Copy Markdown
Contributor Author

k-chimi commented May 20, 2026

thanks for your review! I've fixed my code.

Please check it when you have a moment. 🙏

Copy link
Copy Markdown
Contributor

@kolkov kolkov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! All review fixes applied, CI 11/11 green. Great contribution.

@kolkov kolkov merged commit 642bd44 into gogpu:main May 20, 2026
11 checks passed
@k-chimi k-chimi deleted the feat/macos-software-backend-blit-163 branch May 20, 2026 11:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

macOS software backend: windowed presentation (CGImage + CALayer)

2 participants