Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pico: Delcare screen_fb as uint16_t #756

Merged
merged 1 commit into from
Mar 10, 2022

Conversation

Daft-Freak
Copy link
Collaborator

Everything that isn't blit::Surface wants that and we assume 2-byte alignment in the blending code.

Seems to fix #755, which was hardfaulting in the blending code.

Everything that isn't blit::Surface wants that and we assume 2-byte alignment
@ali1234
Copy link
Contributor

ali1234 commented Feb 17, 2022

This fixes it for me. Is declaring the framebuffer uint16 guaranteed to align it or should we take further measures eg alignas?

I think this fix is correct because adding another static bool to the example also makes the crash go away, due to bringing everything back into alignment. It also explains why both C and CXX flags must be Os in order for the bug to happen, because any aligned variables between the static bool and the framebuffer will push everything after back into alignment.

@Daft-Freak
Copy link
Collaborator Author

I think it should be enough, any attempt to access an unaligned uint16 causes a fault... so I'd hope the compiler is smart enough to not do that.

Though forcing it to be aligned to 4 bytes may be (slightly) more optimal...

@Gadgetoid Gadgetoid merged commit 2ae242f into 32blit:master Mar 10, 2022
@Gadgetoid
Copy link
Contributor

Thank you all! This actually reads better, too, albeit the number of uint8 casts seems to have balanced it out 😆

@Daft-Freak Daft-Freak deleted the pico-fb-align branch March 10, 2022 16:51
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.

Crash on Picosystem with MinSizeRel only
3 participants