Skip to content

Hotfix: OSX ARM colors#200

Merged
200sc merged 3 commits intomasterfrom
hotfix/osx-arm-colors
Apr 9, 2022
Merged

Hotfix: OSX ARM colors#200
200sc merged 3 commits intomasterfrom
hotfix/osx-arm-colors

Conversation

@200sc
Copy link
Contributor

@200sc 200sc commented Apr 3, 2022

On my three OSX (one Intel, two ARM) machines, I've consistently observed that the Intel machine, no matter what we do within the OS driver, expects the pixel data drawn to windows to be RGBA. On ARM it expects BGRA.

I have been unable to find references to others experiencing this. I have also been unable to find anything within metal, glfw, or cocoa that would programmatically expose that the OS is doing this to us. So:

This PR changes mtldriver to use image.RGBA if on Intel, and a locally defined copy of image.RGBA with R and B flipped, BGRA when on ARM.

Re: help wanted:

Do you have a mac? Regardless of whether it is ARM or Intel, please try this branch out to confirm the above suspicion.
Run this command from the repository's root:
cd examples/top-down-shooter-tutorial/6-performance && go run performance.go

And you should see colors like this:
Screen Shot 2022-04-03 at 1 07 19 PM

200sc added 3 commits April 3, 2022 17:59
It appears that newer macs have deprecated the ability to render metal windows as rgba, which was the default behavior on older macs even when bgra was requested

This is a confusing statement and is not backed up by anything I can find online, but this patch on m1 fixes the display such that the r and b channels are flipped.

Candidate for backporting to v3.
@200sc 200sc self-assigned this Apr 3, 2022
@codecov-commenter
Copy link

codecov-commenter commented Apr 3, 2022

Codecov Report

Merging #200 (679b2d0) into master (135b087) will decrease coverage by 0.18%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##           master     #200      +/-   ##
==========================================
- Coverage   92.39%   92.20%   -0.19%     
==========================================
  Files         141      141              
  Lines        6456     6456              
==========================================
- Hits         5965     5953      -12     
- Misses        430      440      +10     
- Partials       61       63       +2     
Impacted Files Coverage Δ
drawLoop.go 39.75% <0.00%> (-7.23%) ⬇️
event/handler.go 96.66% <0.00%> (-3.34%) ⬇️
collision/rtree.go 97.90% <0.00%> (-1.40%) ⬇️

📣 Codecov can now indicate which changes are the most critical in Pull Requests. Learn more

@nfuden
Copy link

nfuden commented Apr 3, 2022

Have intel mac. Between master and new branch no change in coloration per expectations. Do not have arm cannot confirm behavior there.

@200sc 200sc merged commit ece3195 into master Apr 9, 2022
@200sc 200sc deleted the hotfix/osx-arm-colors branch April 9, 2022 17:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants