[rlsw] First batch of embedded optimizations and compiler requirements Pico 2#5994
Merged
raysan5 merged 10 commits intoJul 21, 2026
Merged
Conversation
Bigfoot71
suggested changes
Jul 19, 2026
Contributor
|
As for the changes to @raysan5 Please, if this PR is going to be merged, merge it before my other PR #5996 in case there are any conflicts to resolve. Especially since I asked a question there about the consistency of the configuration define prefixes, and |
Owner
|
@Bigfoot71 thanks for the review, it looks good to me. I can merge it before the following PR. @NighthowlerStudios Please, could you rename the flag to |
Contributor
Author
|
Owner
|
@NighthowlerStudios thanks for the improvement! Also answered on the issue. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Backbuffer for RLSW
This implements the backbuffer approach being talked about in #5993
The "secret option"
RLSW_BACKBUFFERhas been thoroughly tested and confirmed working, as well as confirmed a serious performance boost, similar findings to the ESP32's approach, though this one has less to it, and a bit more manual control needed by the embedded developer to take hold of the buffer and transmit it themselves at the right time.For example, the developer is still required to add in their own mutex methodology to prevent their video transmission from overlapping with the new buffer pointer submission.
Use pico_rand.h to get true random seed on startup, fixes compiler error
The Pico 2 does not include a hardware clock that measures real time. Because of this, the Pico SDK only includes an incomplete stub of
time.h. When compiling to Pico 2, if left alone,time(NULL)will actually throwunsupported relocationon GCC, as it cannot link everything inside oftime()needed.With the Pico 2 we have an alternate approach available. The RP2350 has a hardware "True Random Unit." This true random unit listens to electrical noise surrounding the chip (with Ring Oscillators) and uses that to seed itself. This would be much unlike getting "time since startup".
So this commit suggests using the hardware True Random Unit to get the first seed. Then we can let Raylib take control of the random maths from there, to inline the behaviour with how Raylib runs on other platforms by keeping Raylib's actual algorithm active.
Note that the first fetch costs about 20,000 cycles as the ring oscillators need time to spin up. But this is in trade-off for getting the seed completely randomized instead of predictable (start up time each reboot would be about the same give or take a few microseconds). It doesn't make sense for us to use the hardware randomizer to replace Raylib's Xoshiro implementation to fetch the actual values, because the hardware TRNG has a limitation where the seventh read will always trigger a recycle of the oscillators to refresh the values, the previously mentioned 20,000 cycle penalty. Way too heavy compared to Xoshiro's average of 10 to 20 cycles.
In short, TRNG once to seed, then existing Xoshiro for fastest random streaming.