[rlsw] Fix axis aligned quad detection #5314
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
TL;DR The PR was mainly aimed at fixing the axis-aligned quad detection function, but also contains the fix for DRM and a review for the alignments.
The issue for the axis-aligned quad detection was that it should have relied on transformed screen coordinates. This could even cause crashes in some cases, I spotted it while trying to transform text with
rlRotatefI also made it a bit more readable and documented.
I also fixed the DRM and
swGetColorBufferissue. The function wasn't actually needed even to get the internal buffer dimensions,swBlitFramebuffershould handle everything automatically, and it now does.Regarding
alignasthe idea was to align both size and alignment (eg, 4-byte values aligned to 4). This allows, in theory for ARM, to use optimal load/store instructions instead of risking unaligned accesses that take extra cycles or require software emulation in worst case (old CPUs). On x86-64, it doesn't change much, but on ARM and RISC-V it should ensure predictable and optimal performance. Benchmarks are obviously needed to measure the real gain.That said, the
alignasoncolorwas just one of my tests. I got confused with my branches and noticed it only after making my 'typo' fix. I figured, well let's leave it and I'll revisit it in the next PR. Sorry about that, but it reminded me that it's C11!So, last PR ended up being a bit of a "mixed bag". From now on I'll try to make PRs more focused on specific issues.
Next on my list are handling cull face properly (culling is still happening even when disabled) and adding depth mask, since depth is currently always written.
I'm also working on a 3D example/mini game that runs quite well. It will help isolate real world issues, so expect more fixes coming from that.