Repository navigation
simple_renderer: Fix release build, decouple debug macros - #131
Merged
Merged
Conversation
…nnel
Fix simple_renderer so release builds compile and the library no longer
depends on agdktunnel headers:
- Release builds failed to compile. Under NDEBUG, RENDERER_CHECK_VK was
defined with one parameter, but every call site passes two
(result, message), so `./gradlew assembleRelease` failed at every
Vulkan result check. Release (RelWithDebInfo) builds do get
-O2 -DNDEBUG, but release had simply never been built.
- renderer_debug.h included agdktunnel's common.hpp for ALOGE/ALOGI and
MY_ASSERT, so simple_renderer could not be built without agdktunnel's
headers. The macros now only use base_game_framework's DebugManager
(tag "SimpleRenderer") and the C++ library:
- RENDERER_ERROR / RENDERER_LOG log through DebugManager.
- RENDERER_ASSERT logs the condition, file and line, then aborts.
Under NDEBUG it is compiled out: the condition is type checked as a
bool but not evaluated.
- RENDERER_CHECK_VK and RENDERER_CHECK_GLES are bool expressions in
all builds (true if there was no error), so they behave the same in
debug and release when used in conditions. Vulkan results are checked
and logged in all builds, which only costs a comparison. GLES errors
are only checked in debug builds, since glGetError can stall the
pipeline; in release RENDERER_CHECK_GLES is always true.
- RENDERER_ERROR, RENDERER_LOG and RENDERER_ASSERT are single
statements that need a trailing ';'. Call sites that relied on
ALOGE/MY_ASSERT supplying their own ';' or braces now have one.
- renderer_render_pass_gles.cpp got the GLES headers only through
common.hpp. It now includes <GLES3/gl3.h> itself.
- IndexBufferVk and VertexBufferVk checked staging_alloc_result a second
time instead of buffer_alloc_result, so a failed index/vertex buffer
allocation went unnoticed. Now that release builds run, where a failed
check logs instead of aborting, both also stop on allocation failure
instead of copying into a null mapping or recording a copy into a null
buffer. Their buffer handles start as VK_NULL_HANDLE, and the
destructors skip buffers that were never created.
- RendererCheckVk / RendererCheckGLES handle a null message. Two positive
VkResult cases that could never be reached in the negative-result
switch are removed. The shader info log buffers are zero-initialized
before glGet*InfoLog fills them.
Tested on a Pixel 10 Pro with agdktunnel:
- assembleDebug and assembleRelease both build (release failed before).
- A test file using the macros compiles with -Wall -Wextra -Werror
-Wunused-variable in debug and release: as conditions, on a bit-field,
and in an unbraced if/else.
- Debug Vulkan, debug forced GLES, and release (signed with the debug
key, non-debuggable): launch, play, background and resume work, and
renderer logs appear under the SimpleRenderer tag. There are no
assertion failures, API errors or crashes.
Not exercised: the buffer allocation failure paths (no allocation failure
could be forced).
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.
Fix simple_renderer so release builds compile and the library no longer depends on agdktunnel headers:
./gradlew assembleReleasefailed at every Vulkan result check. Release (RelWithDebInfo) builds do get -O2 -DNDEBUG, but release had simply never been built.