Skip to content
This repository was archived by the owner on Oct 10, 2023. It is now read-only.

Stop using packed structs #15

@CryZe

Description

@CryZe

I've seen that we use lots of packed structs across both libtww and the debug menu. PowerPC is one of those architectures that can't handle misaligned accesses (especially on the real console), so they can't be using any packed structs. So this is not only unsafe in Rust, but also unsafe on the real console. In fact most things that are close to the hardware (such as stuff stored on the DVD and buffers that the GPU uses) need to even be 32 byte aligned, which I assume is a full cache line.

Actually it seems like that's wrong. The manual states that it can do unaligned loads and stores just fine, it only degrades performance. I think where we ran into the problem (other than the two 32 byte alignments shown above) was that our instructions weren't aligned to 4 bytes, which is another requirement. So I guess normal loads and stores that don't get DMA'd onto some hardware and aren't instructions can theoretically be misaligned. But I still highly doubt that they were using packed structs in Wind Waker. Everything I've seen so far has been aligned properly.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions