Skip to content

simple_renderer: Fix release build, decouple debug macros - #131

Merged
natetrost merged 1 commit into
android:mainfrom
natetrost:main
Nov 17, 2026
Merged

natetrost merged 1 commit into
android:mainfrom
natetrost:main

Conversation

@natetrost

Copy link
Copy Markdown
Contributor

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.

…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).
@natetrost
natetrost merged commit ca5a4fa into android:main Nov 17, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant