Skip to content

feat: Xendroid Plus Ultra Unified (Tracks A-D + PRs #134-#139) - #142

Open
phforner0 wants to merge 39 commits into
mainfrom
feat/plus-ultra-unified
Open

phforner0 wants to merge 39 commits into
mainfrom
feat/plus-ultra-unified

Conversation

@phforner0

Copy link
Copy Markdown
Owner

Xendroid Plus Ultra — Unified Integration (Tracks A–D + PRs #134, #135, #137, #138, #139)

Consolidação completa das melhorias de arquitetura e desempenho (Tracks A–D de feat/plus-ultra-integration até 10a0f330c) sobre o main atualizado com os PRs #134, #135, #137, #138 e #139 (a4caad676).

Principais entregas integradas

  • Track A (GPU / Vulkan / Mali / Xclipse): EDRAM 4x-as-2x2 preservando AFBC, render_targets.vk.bin persistente, mistura ordenada (EXT/ARM_rasterization_order_attachment_access), tabela de erratas Arm Mali, bcenabler Adreno 6xx, transcodificação compute BCn/CTX1 → ASTC 4x4 & EAC RG11, liberação de clock KGSL, resolução de mips encadeados + guard Adreno >= 750 para vulkan_texture_load_to_image.
  • Track B (SPIR-V / CP / Pipeline): VK_EXT_shader_object, VK_EXT_graphics_pipeline_library, BDA em VulkanSharedMemory, memexport compute em lote (vulkan_memexport_batch), análise estática ±Inf/NaN (spirv_nonfinite_safe_fmul), especialização iscale, promoção GPR → SSA, combinado com os guards Vulkan 1.0–1.2 (Adreno 610), cache SPIR-V multi-driver, RTZ 4-bit por componente e aliasing EDRAM (aliased_depth_read_only) do PR #135.
  • Track C (CPU / JIT / Memória / Kernel): baseline ARMv8.2-A + LSE + DotProd + FP16 + RCPC + CRC + ThinLTO, alocação de GPRs voláteis call-aware (16 GPRs), EmitReservedStoreHelper com guarda runtime kA64EmitLSE, SIGSEGV zero-copy via esr_context, alinhamento ELF 16 KB, coalescência writewatch 64 KB, correções Dekker + WaitMultiple, AttachPendingModules (#134) e parque de subsistemas antes de travar o guest clock na pausa (10a0f330c).
  • Track D (VFS / Áudio / HID / App): streaming ISO pread64 + LRU cache, árvores SAF multi-arquivo, .zar paralelo, AAudio lock-free SPSC + AudioBlockRenderer NEON, jit_frame_start, DriverProbeActivity multi-vendor, Dual-Screen, BT companion, Pastas de jogos (#138), loop 0 Hz + ADPF por quadro, e GetCapabilities rumble/buttons (#118).

Correções da unificação

  • 1efd011df — xenia/base/memory.h: const_cast<__m128i*> em _mm_stream_load_si128 (ReadLineNT) para GCC 13 nos testes de host.
  • f6ff8ccde — lote16_upstream_test.cc: inspeção de A64HelperEmitter::EmitReservedStoreHelper e escopo {} de kA64EmitLSE/if (lse).
  • 7f33951b7 — vulkan_device.cc: alinhamento para device->extensions_.ext_1_3_KHR_dynamic_rendering preservando ambos os guards (Vulkan >= 1.2 + !mali_block_dynamic_rendering).
  • e6f649c8d — sync final com main (a4caad676, árvore byte-a-byte idêntica ao 7f33951b7 validado no Colab e no aparelho).

Verificação remota (Google Colab xendroid-unified-gate, 9/9 PASS)

  • Estático & JNI: check-jni.py (98 Java natives, 97 registrations, 2 exported symbols), test_server.py (13/13 OK), bash -n.
  • SPIR-V estrito: gen_android_spirv.py --strict — 375 shaders, 0 falhas.
  • Testes nativos de host + Lavapipe: PASS (193,28 s — inclui lote16_upstream_test, gpu_compat_perf_test, xam_live_signin_test, vfs_save_cache_test, threading_apc_test, frame generation e filtros).
  • JVM & Lint: 138 suítes, 675 testes, 0 falhas/erros (:app:testDebugUnitTest :app:lintDebug).
  • APK Release (XenDroid_Plus_Ultra_Unified_7f33951b.apk): 44,9 MB (sha256: ecc6694c…b43f), check-apk.py 1.034 entradas OK, LOAD alinhado em 0x4000 (16 KB), 3.046 instruções LSE em libe.so.
  • Corpus Forza (4D5309C9.xsh): 624 pares de shaders (284 VS + 340 PS), 0 falhas spirv-val, −3,67% bytecode.

Medições em aparelho real (POCO F7 25053PC47G, Adreno 825, Turnip Gen8 V39)

  • Gears of War 3 (0x4D5308AB, cena da fonte, ~2520 draws): 28,91 FPS (HUD 30 FPS · 33,7 ms), GPU 30,14 ms (f:7266..7412, mesmo a 41,7 °C / SoC 85 °C), vs 21,2–22,0 FPS / 44,5–45,2 ms no baseline e4003ba66; pausa e saída in-game sem ANR (0 erros).
  • Red Dead Redemption (0x5454082B, Armadillo Station, ~7720 draws): 15,33–16,30 FPS, GPU 50,57 ms, 117 render passes (−26% passes vs 149–161 do baseline; antes do thermal throttling a 43 °C).

phforner0 and others added 30 commits November 17, 2026 22:58
…h merge, game-patches sync & parallel multi-format .zar
…l analysis, iscale spec, SSA GPRs, BDA, point-snap & centroid fixes
…ide/multi-XEX UX, Dual-Screen, BT companion & Plus Ultra schema/i18n
…32, link mip resolves

- Port BSD-3-Clause GPU compute transcoders from DEGROUCHO/xendroid-mali and
  extend with DXT2_3 -> ASTC_4x4 (CEM 12 explicit 4-bit alpha plane 2) and
  universal CTX1 -> EAC_R11G11 across all mobile GPUs with ETC2/EAC.
- Add vulkan_xclipse_bc_transcode (default true) auto-transcoding BC1..BC5 on
  Samsung Xclipse to work around BC4/BC5 zero-texel driver bugs.
- Expand Xenos k_16*_EXPAND (s1e5m10 [0,131008] without Inf/NaN) to IEEE-754
  R32*_SFLOAT via compute load shaders, fixing NaN mesh explosions (AC Rogue).
- Dynamically scale soft/hard texture cache limits from physical RAM when RGBA8
  BCn fallback is active.
- Link 1x EDRAM resolves directly into resident mip chains and macro-tile
  offsets, fix WatchHandle leak in MakeUpToDateAndWatch, and clean batched load
  state.
…ease, bcenabler & universal GPU busy

- Enable textureCompressionETC2, textureCompressionASTC_LDR,
  textureCompressionBC, and maxDrawIndirectCount in VulkanDevice.
- Parse Arm Mali r<M>p<N> driver versions (SDEN-3735689): gate dynamicRendering
  (<r52), extendedDynamicState (<r44p1, r44, and Job Manager r46..r50), and
  SPIR-V 1.3 / scalar OpSelect rewrite (<r47); enforce HOST_COHERENT on Mali
  readback/UMA allocations.
- Query, enable, and bind Stage-0 entry points for VK_KHR_buffer_device_address,
  VK_EXT/ARM_rasterization_order_attachment_access, VK_EXT_depth_bias_control,
  VK_EXT_graphics_pipeline_library, and VK_EXT_shader_object.
- Add ReleaseGpuPowerControl on startup fallback, surface disconnect, and
  teardown; support multi-vendor custom Vulkan driver loading and stock Adreno
  6xx bcenabler (vulkan_adreno_bcenabler).
- Extend QueryGpuBusyPermille with /sys/kernel/gpu/gpu_busy and Mali utilization
  sysfs fallbacks, and add optional swapchain preTransform & scRGB HDR CVars.
…vk.bin & ordered blending

- Port BSD-3-Clause vulkan_msaa_4x_as_2x2, 43 Direct Host Resolve _2x2_cs color
  variants, and spirv_single_sample_patch.h from DEGROUCHO/xendroid-mali so
  Mali, PanVK, and Xclipse keep 4x MSAA EDRAM surfaces in 1x AFBC-compressed
  render targets.
- Normalize mixed LOAD_OP_DONT_CARE + LOAD_OP_LOAD attachments on Mali < r38p1.
- Wire 1x EDRAM direct resolve copy linking with 32x32 macro-tile offset support
  in TryDirectHostResolveCopy.
- Enable VK_EXT_rasterization_order_attachment_access ordered SNORM16 in-pass
  resolve blending without per-resolve barriers.
- Persist internal render target cache pipelines to shaders/local/render_targets.vk.bin.
… title quirks

- Restrict vulkan_texture_load_to_image in Forza Horizon 1 & 2 to custom Turnip
  drivers on Adreno >= 750 so AFBC/UBWC remains active on Mali, PanVK, Xclipse,
  Adreno < 750, and stock Qualcomm drivers.
- Add compatibility quirks for Fable II, Spider-Man (Web of Shadows, Shattered
  Dimensions, Edge of Time), Peter Jackson's King Kong, Halo: Reach, WWE 2K14,
  Battlefield 2: Modern Combat, Dead or Alive Xtreme 2, and FIFA 16.
… f32->i16, guard OpenForUnixFd & request BLUETOOTH_CONNECT
… threads, and port xenia-edge P0 kernel fixes
…o-spill VMX/DotProd, and xenia-edge CPU P0 fixes
…RECTLIST VS & Turnip

- Guard pipeline storage persistence with storage_write_pending so keys are written to disk
  only after vkCreateGraphicsPipelines returns VK_SUCCESS, plus fillModeNonSolid safe fallback
  and WaitForPipeline bounded wait on color-writing draws (XDroid360 33623e916, BSD-3-Clause).
- Implement clean-room VK_EXT_graphics_pipeline_library 4-part fast-link + async LTO upgrade
  (vulkan_graphics_pipeline_library) and VK_EXT_shader_object path (vulkan_shader_object).
- Wire 32-bit kSpecIdTextureIntegerScaleUsed specialization and vulkan_fable2_float24_depth.
- Unlock kRectangleListAsTriangleStrip VS expansion on GPUs without geometryShader / Mali / PanVK,
  add 8192-entry (2048x4-way) LRU 16-bit index preswap cache (DEGROUCHO, BSD-3-Clause), and fix
  builtin_index_buffer_upload_memory_ non-coherent flush.
- Add non-precise VIZ_QUERY BeginQuery flag and batched FSI counter clears in VulkanZPDQueryPool
  (xenia-edge 3d233a5b2/692cd59cf, BSD-3-Clause) + Mesa Turnip A7xx patches/docs in tools/turnip/.
… depth bias & CP upgrades

- Implement kMemExportCompute + vulkan_memexport_batch multi-draw compute batching outside render
  passes for GPUs without vertexPipelineStoresAndAtomics (DEGROUCHO, BSD-3-Clause), plus non-blocking
  HeldGuestSignal fence/interrupt ordering behind memexport submissions (xenia-edge 31a696a9a/409ca81a3).
- Unlock VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC for all drivers except VK_DRIVER_ID_QUALCOMM_PROPRIETARY
  (enabling Dynamic UBOs on Mali, PanVK, Xclipse, Turnip, RADV, desktop).
- Implement vulkan_tight_render_area (viewport-clipped dirty renderArea shrink), VK_EXT_depth_bias_control
  with 0.5x kD24FS8 UNORM scaling (xenia-edge a8d034c00), pre-pass splice segment guard (XDroid360 6e54a1f6f),
  readback_resolve_uma_skip_cpu_written 4 KB page filtering, point-sampled texture_point_snap bit 26,
  VK_KHR_buffer_device_address shared memory pointer population, and 64-ID VIZ_QUERY + 4-counter ZPD.
…across SPIR-V, cache & CP

- Finding 1 (`vulkan_msaa_4x_as_2x2` end-to-end):
  - `vulkan_command_processor.cc`: match Track A `non_turnip_mobile_tiler` gate in `RewriteMsaa4xSurfaceInfoForDraw` so all 4x MSAA scene color/depth draws rewrite to 1x double-pitch host RTs alongside 4x clears, with 2x2 VRS (`draw_shading_rate_ = 3`) governed by `SpirvShaderTranslator::IsSamplesAsPixelsCoarseAllowed`.
  - `guest_spirv_shader_cache.cc`: set `modification.pixel.resolution_scale_native` unconditionally from `draw_samples_as_pixels()` when unscaled so foliage/textured shaders not reading `vPos` enter `IsDrawSamplesAsPixels()`.
  - `spirv_shader_translator_rb.cc`: evaluate 2x2 quadrant 4x A2C threshold (`{0.75, 0.25, 0.5, 1.0} - offset/16`) and `OpKill` on failure before `LoadMsaaSamplesFromFlags()` (which sees `k1X`).
  - `spirv_shader_translator_fetch.cc` & `spirv_shader_translator.{h,cc}`: implement `ScaleDerivativeToGuestPixels` (`* 2.0f` when `IsDrawSamplesAsPixels() && !IsDrawSamplesAsPixelsCoarse()`) and `+1.0f` LOD bias in `QueryTextureLod` and `use_lod_bias`.
- Finding 2 (`texture_integer_scale_used` 32-bit mask):
  - `vulkan_pipeline_cache.cc`: preserve all 32 `tf0..tf31` bits in `GetCurrentStateDescription` and widen GPL `fs_spec_bits` to `uint64_t` (`has_fs` at bit 49).
- Finding 3 (`vulkan_shared_memory_bda` SPIR-V & `route_to_host`):
  - `spirv_shader_translator.cc`: remove invalid `AliasedPointer` (`5356`) decoration on `OpBitcast` SSA IDs and `DecorationRestrict` on `XeBdaSharedMemoryWord` member 0 (`spirv-val` clean), and use `spirv.hpp11` scoped `spv::Capability::PhysicalStorageBufferAddresses`, `spv::AddressingModel::PhysicalStorageBuffer64`, `spv::StorageClass::PhysicalStorageBuffer`, and `spv::MemoryAccessMask::Aligned`.
  - `vulkan_command_processor.cc`: force `route_to_host = false` when BDA is active and guard `vkGetBufferDeviceAddress` with `!shared_memory_->is_zero_copy()`.
- Finding 4 (`VK_EXT_shader_object` dynamic rendering & EDS1/EDS3 gates):
  - `vulkan_pipeline_cache.cc` & `vulkan_command_processor.cc`: require `vulkan_dynamic_rendering && dynamicRendering` and full EDS1/EDS3 capabilities in `CanUseShaderObjects`, and pass explicit `(0, nullptr, 0, nullptr)` to `CmdVkSetVertexInputEXT`.
- Finding 5 (memexport compute barrier stages/access, intra-batch hazard check & submission flush):
  - `vulkan_command_processor.{h,cc}`: add `VK_PIPELINE_STAGE_VERTEX_INPUT_BIT` + `VK_ACCESS_INDEX_READ_BIT | VK_ACCESS_VERTEX_ATTRIBUTE_READ_BIT` to memexport barriers, rename `memexport_compute_batch_` to avoid colliding with `DrawExportTracker`'s `uint64_t memexport_batch_`, flush on WAW/RAW overlap across `exported_ranges` / `vfetch` / DMA index ranges, and flush at `EndSubmission`.
- Finding 6 (wire `HeldGuestSignal`, `VIZ_QUERY`, and `PrePassSplice`):
  - `pm4_command_processor_implement.h`, `command_processor.{h,cc}`, `command_processor_memexport.inc`, `vulkan_command_processor.cc`: wire `HeldGuestSignal`, 32-bit `ReportHandle`-clean `VIZ_QUERY` (`BeginVIZQuery`, `EndVIZQuery`, `PrepareVIZDraw`, host non-precise occlusion survey segments + `VizSurveyGuard`), and open-pass upload barrier splicing (`CanSpliceBeforeActivePass` + `BeginPrePassSplice`/`EndPrePassSplice`).
- `spirv_builder.cc` & `spirv_shader_translator.h`: use `getSpvVersion()` and `spv::StorageClass::Output` (`aarch64-linux-android29-clang++ -fsyntax-only` verified across all 17 TUs).
…receiver

`runCatching { }` inside a constructor delegation resolves to the
extension overload, whose implicit receiver is the not-yet-initialized
instance, so Kotlin 2.0 rejects it. Use an explicit try/catch instead.
The test called HudMetric.encode/decode/FRAME_TIME, an API that never
existed in any branch: the HUD metric selection is persisted as a
StringSet of enum names in EmulatorHostActivity. Keep the
parseDirectGpuPercent coverage the test also carried.
… server contract

The 21:9 preset divided 21/9 (2.3333) while 2560x1080 ultrawide panels
are 64:27 (2.3704), the constant the helper's documentation, the tests
and the real patches use. Also add the 21 settings introduced by Tracks
A-D to tools/community-server/contract.json, so the app and the
reference server accept the same keys again.
The Android release build configures RelWithDebInfo, so the Release-only
glob in tools/ir3_offline/gen.py missed the header and the Forza corpus
validation could not start.
spirv_shader_translator.cc and its ALU part call into
spirv_nonfinite_analysis, so the corpus tool needs it in its source
list. gpu_flags.cc stays out: its cvars are already stubbed in
stubs.cc and it would pull RenderDoc into the host link.
spirv_shader_translator_alu and _fetch read alu_round_toward_zero and
texture_point_snap, which live in gpu_flags.cc. Stub them with the real
defaults instead of linking gpu_flags.cc, whose other cvars are already
stubbed and which pulls RenderDoc.
corpus_tool accepts cvar overrides by name, and the gate passes
spirv_specialize_no_alpha. The cvar is defined by the guest shader cache,
which is not part of the offline link, so register it with its real
default in stubs.cc.
The tool always used the no-alpha-test pixel shader variant, so the
generic and opaque runs produced identical bytecode and the gate's
comparison was meaningless. Gate the specialisation on the cvar, which
is what the command line already sets for each run.
Emulator::Pause called Clock::HoldGuestTime(true) before parking audio and
graphics. On Android the vblank pacer derives its deadlines from
QueryGuestTickCount(), so holding the clock froze vblanks. A command
processor inside a WAIT_REG_MEM on the vblank counter then never matched,
CommandProcessor::Pause never parked, and the caller (the UI thread, when
the in-game menu pauses the game) blocked on the pause fence until the
system reported an ANR.

Park audio and graphics while the clock still runs, then hold it.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-18T21:07:09.490769Z e6f649c PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e6f649c8df

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

onClosed: (reason: String) -> Unit = {},
) : this(
openStream = streamOpener,
abortPendingConnect = {},

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Make pending Bluetooth connects cancellable

When the user cancels while RFCOMM connect() is still blocked, this is the stream client's abort hook and it does nothing; activeConn is assigned only after the Bluetooth socket connects. If the connection later succeeds, the client continues pairing and starts its read/send threads even though CompanionPadLink has dropped it, leaving an invisible phone occupying a player slot. Expose the pending socket to the abort hook so leaving can close it.

Useful? React with 👍 / 👎.

Comment on lines +41 to +42
fun configureHandshakeTimeout(ms: Int) {}
fun clearTimeout() {}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Enforce a timeout for Bluetooth handshakes

When the host is using Bluetooth, BluetoothConn inherits this no-op and never times out the handshake read in CompanionHost.serve. A paired device can connect and withhold HELLO; four such connections exhaust MAX_HANDSHAKES, so legitimate phones are rejected until those connections close. Enforce a deadline for Bluetooth handshakes and close stalled sockets.

Useful? React with 👍 / 👎.

This branch has not been deployed

No deployments
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