Write a console that does not flush gfx buffers #57
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.
@Meziu @AzureMarker
The default libctru console calls
gfxFlushBuffers
whenever it prints a\n
or\r
character, which is normally useful since its output will be visible immediately.However, I have a use case where I'd like to print concurrently from multiple threads, and manage flushing of the graphics buffer myself at the end of the frame. I noticed that the
gfxFlushBuffers
seemed to cause a deadlock when run concurrently from multiple threads – perhaps a bug in the underlying implementation?In any case, this PR hacks together a variation on
Console
that works basically the same as the default one, but does not flush the buffers. Even without fully understanding the deadlock issue I mentioned, I think this could be useful as most programs should probably only flush once per frame anyway: https://libctru.devkitpro.org/gfx_8h.html#aea1808bd74fe0c00f9794e455fc8499bI'm hoping this will make the console usable as a debug tool on one screen while rendering / doing other stuff with the other one.
The implementation does feel a bit hacky, though, so if you have suggestions or think we shouldn't merge this, please let me know. I thought this seemed a bit easier than writing a full-blown console from scratch, anyway.