Stale GL_UNPACK state in gl4es and a missing pre-release GPU sync caused diagonal-banded corruption in the 3D view. Synthetic key press/release must track the real controller button or touch down/up edges, not fire together in one call - fixes a typed movement key sticking forever, then a follow-up that had silently broken A-button jump and on-screen keyboard arrow keys. Also adds force-rebuild.sh for the known stageEngine stale-cache issue.
This commit is contained in:
@@ -347,6 +347,13 @@ the same as any other Android Studio project:
|
||||
this automatically otherwise, so plain Java/C++ edits under
|
||||
`android/app/src/main/` just need another Run/Debug press.
|
||||
|
||||
**If a native change genuinely doesn't seem to take effect** even after a
|
||||
normal rebuild - `stageEngine` can wrongly report `UP-TO-DATE` for a
|
||||
newly-added file under `android/engine-patches/` - run
|
||||
`android/force-rebuild.sh` and rebuild. For more visibility than Android
|
||||
Studio's collapsed Build panel, run `./gradlew :app:assembleDebug
|
||||
--console=plain` from a terminal instead.
|
||||
|
||||
### 5.4. Engine/gl4es patch reference
|
||||
|
||||
`android/engine-patches/` (applied to a scratch copy of `engine/`) and
|
||||
@@ -397,7 +404,36 @@ each one does:
|
||||
hook: redirects `SDLDraw()`/`opengl_swap_and_restore()` to submit into
|
||||
the XR swapchain (via `xr_frame_begin()`/`xr_frame_end()`) instead of
|
||||
the normal window, for both the GL-rendered 3D path and the plain
|
||||
software-composited path (splash screen/cutscenes/menus).
|
||||
software-composited path (splash screen/cutscenes/menus). Also logs
|
||||
once per transition between the two (`INFO("Game rendering active:
|
||||
...")`) for on-device logcat diagnostics.
|
||||
- **`12-android-texture-row-length.patch`** - `OpenGL.cc`'s wall/floor
|
||||
texture upload (`opengl_cache_texture()`/`set_texture()`, only reachable
|
||||
when `gShockPrefs.doUseOpenGL` is true - it defaults `false` in
|
||||
`Prefs.c`, so this path is dormant on Quest by default) sets
|
||||
`GL_UNPACK_ROW_LENGTH` from the original 8-bit source bitmap's row
|
||||
stride (`bm->row`), but the buffer actually uploaded is a separately-
|
||||
allocated RGBA32 conversion of it with its own, unrelated stride. Fixed
|
||||
to use the converted buffer's own pitch instead.
|
||||
- **`13-android-swapchain-sync.patch`** - `android_draw_surface_as_quad()`
|
||||
used `glFlush()` after drawing into the swapchain's FBO, which queues
|
||||
the GPU work without waiting for it to finish before
|
||||
`xr_swapchain_release()` hands the image to the OpenXR runtime for
|
||||
cross-process consumption. Changed to `glFinish()`, which blocks until
|
||||
the write has landed. The same gap existed in `xr_overlay.c`'s
|
||||
`xr_overlay_render_and_build_layer()` (the keyboard/menu overlay blit
|
||||
path) and was fixed there directly, no patch needed since that file is
|
||||
first-party.
|
||||
- **`14-android-quad-unpack-state.patch`** - fixes the diagonal-banded/
|
||||
skewed corruption in the 3D game view during real gameplay (see README
|
||||
5.5.2). `android_draw_surface_as_quad()`'s `glTexImage2D` upload of the
|
||||
tightly-packed `uiRgba` buffer relied on GL's default unpack state
|
||||
(`GL_UNPACK_ROW_LENGTH`/`GL_UNPACK_ALIGNMENT` at 0/4) instead of setting
|
||||
it explicitly. gl4es implements both client-side and persists whatever
|
||||
was last set across draw calls in the same context, so this upload
|
||||
inherited non-default unpack state left behind elsewhere in the frame
|
||||
and misread every row. Fixed by resetting both to the packed defaults
|
||||
immediately before this upload.
|
||||
|
||||
`android/gl4es-patches/`:
|
||||
|
||||
@@ -459,6 +495,33 @@ trigger (a single always-nonzero struct field) sits well below the
|
||||
project's own layer boundary and doesn't show up in any of the local GL
|
||||
state that the menu's own code controls.
|
||||
|
||||
#### 5.5.2. Diagonal-banded corruption in the 3D game view
|
||||
|
||||
During real 3D gameplay (not menus/splash), the game quad rendered as
|
||||
diagonally-banded color noise. Every OpenXR overlay quad (menu, keyboard,
|
||||
laser-beam pointers) and the desktop build's software renderer were
|
||||
unaffected, narrowing the bug to the one present path gameplay uses that
|
||||
those don't: `android_draw_surface_as_quad()` in `engine/src/MacSrc/
|
||||
OpenGL.cc`.
|
||||
|
||||
**Root cause:** its `glTexImage2D` upload of the tightly-packed `uiRgba`
|
||||
conversion buffer relies on GL's default unpack state
|
||||
(`GL_UNPACK_ROW_LENGTH`/`GL_UNPACK_ALIGNMENT` at 0/4) instead of setting
|
||||
it explicitly. gl4es - the GLES/EGL translation layer this engine's
|
||||
desktop-style GL calls go through on Quest - implements both unpack
|
||||
parameters in software, manually repacking the source buffer row-by-row
|
||||
using whatever stride was last set via `glPixelStorei`, and that state
|
||||
persists across draw calls in the same GL context rather than resetting
|
||||
per call. During gameplay, this upload inherits non-default unpack state
|
||||
left behind elsewhere in the frame and misreads every row - a diagonal
|
||||
shear/banding pattern. Menus never trigger it because nothing in the
|
||||
menu-only code paths sets a custom unpack stride first.
|
||||
|
||||
**Fix** (`14-android-quad-unpack-state.patch`): explicitly reset both
|
||||
`GL_UNPACK_ROW_LENGTH` and `GL_UNPACK_ALIGNMENT` to their tightly-packed
|
||||
values immediately before this `glTexImage2D` call, removing the
|
||||
dependency on whatever GL state preceded it.
|
||||
|
||||
## 6. License
|
||||
|
||||
The original tooling in this repository (the Docker build image, build
|
||||
|
||||
Reference in New Issue
Block a user