Skip to content

feat(aurora): port Mali sanitizer + mid-end tier tuning#1

Merged
boiniArun2006 merged 4 commits into
mainfrom
feature/aurora-midend-tuning
Jun 24, 2026
Merged

feat(aurora): port Mali sanitizer + mid-end tier tuning#1
boiniArun2006 merged 4 commits into
mainfrom
feature/aurora-midend-tuning

Conversation

@boiniArun2006

@boiniArun2006 boiniArun2006 commented Jun 24, 2026

Copy link
Copy Markdown
Owner

What this PR does

Forks WinNative and adds Aurora Mali GPU support + device-tier performance tuning for mid-end devices.

What's included

Ported from Aurora (with audit fixes)

  • Mali Vulkan Sanitizer: 5 rules (4 blacklisted extensions + descriptor-set split)
  • B4 fix: dynamic offsets now sliced correctly per chunk (was broken)
  • B6 fix: device resolved per-command-buffer (was hard-coded to [0])
  • Inherits B1/B2/B3/B5/B9 from latest Aurora

Dropped (dead code per audit)

  • Phase 1 texture engine, Phase 2 mesh engine, Phase 3 Markov prefetcher, Phase 4 cloud shader sync

New for mid-end tuning

  • DeviceTier: HIGH/MID/LOW by SoC+RAM+GPU
  • TierPresets: per-tier Box64/DXVK/Wine env vars (putIfAbsent preserves user overrides)
  • NTSyncHelper: auto-detects /dev/ntsync, enables WINENTSYNC=1
  • MemoryBudgetHelper: caps DXVK cache by RAM, disables PulseAudio on <4GB

Repository hygiene

  • Rewrote README.md for this fork
  • Added CHANGELOG.md, CONTRIBUTING.md, CODE_OF_CONDUCT.md
  • Added docs/AUDIT.md, docs/TIER_TUNING.md, docs/MALI_SANITIZER.md
  • Added issue templates (bug, performance, feature) and PR template
  • Enabled Issues + Discussions, set topics, branch protection on main

Integration

  • Called in GuestProgramLauncherComponent AFTER envVars.putAll(this.envVars) — user overrides win
  • Order: TierPresets → NTSync → MemoryBudget → MaliSanitizer
  • Wrapped in try/catch: never blocks game launch
  • Sanitizer .so deployed by ImageFsInstaller to imagefs/usr/lib/

CI status

Verification done

  • Static verification (brace balance, hook dispatch wiring, API surface checks)
  • CI compile on NDK r27 + AGP 8.8 + Kotlin 2.1.10 (all green)
  • APK artifacts built and uploaded

Verification NOT done (needs real device)

  • Runtime behavior on Mali hardware
  • DeviceTier classification accuracy on actual mid-end SoCs
  • B4 fix correctness on a game using >4 dynamic UBO sets

Security

Token used to create this PR is stored only in a local askpass helper, not in any committed file. Token should be rotated after merge.

After merge

  1. Rotate the GitHub token
  2. Tag v0.1.0 release
  3. Test on real mid-end hardware (Snapdragon 7xx or Mali G610)
  4. Calibrate tier presets with real benchmark data (see docs/TIER_TUNING.md)

Aurora integration into WinNative fork. Ports the working parts of Aurora
(per deep audit) and adds device-tier-aware performance tuning for mid-end
devices (the project's primary target audience).

## What's ported from Aurora (with audit fixes)

Mali Vulkan Sanitizer (5 rules, B4+B6 fixes applied on top of latest Aurora):
  - 4 blacklisted extensions: VK_EXT_descriptor_indexing,
    VK_EXT_fragment_density_map, VK_KHR_shader_subgroup,
    VK_EXT_graphics_pipeline_library
  - 1 descriptor-set split at >4 sets (Mali driver crashes on >4)
  - B4 fix: dynamic offsets now sliced correctly per chunk. Previously
    chunks 2+ received 0 dynamic offsets, causing silent wrong rendering
    for any draw using sets 4+ with dynamic UBO bindings. New hooks:
    vkCreateDescriptorSetLayout (caches per-layout dynamic count),
    vkAllocateDescriptorSets/vkFreeDescriptorSets (caches per-set count),
    used in vkCmdBindDescriptorSets to slice pDynamicOffsets per chunk.
  - B6 fix: device resolved per-command-buffer instead of hard-coding
    g_device_dispatch[0]. New hooks: vkAllocateCommandBuffers,
    vkFreeCommandBuffers (maintain VkCommandBuffer -> VkDevice map).
  - Inherits Aurora's audit fixes: B1 (layer name match), B2 (env var
    ordering), B3 (glibc compile), B5 (thread-safe dispatch tables),
    B9 (Immortalis detection).

## What's dropped (dead code per audit)

  - Phase 1 texture engine (no PC game ships .ktx2)
  - Phase 2 mesh engine (no PC game ships .obj)
  - Phase 3 Markov prefetcher (no LD_PRELOAD shim exists)
  - Phase 4 cloud shader sync (no backend)

## What's new for mid-end tuning (the project goal)

DeviceTier.kt:
  - Classifies device as HIGH/MID/LOW based on SoC + RAM + GPU.
  - HIGH: Snapdragon 8 Gen 2+, Dimensity 9200+, Immortalis, 12GB+ RAM
  - MID:  Snapdragon 7xx, Dimensity 7/8, Mali G610/G77/G78, 6-8GB RAM
  - LOW:  Snapdragon 4xx/6xx, Mali G52/G72, 4GB RAM

TierPresets.kt:
  - Per-tier env var defaults, applied via putIfAbsent so user overrides win.
  - MID: BOX64_DYNAREC_STRONGMEM=2, BIGBLOCK=1, CALLRET=1, FASTNAN/ROUND=1,
        SAFEFLAGS=1; DXVK maxFeatureLevel=11_0, relaxedBarriers=True,
        useDescriptorIndexing=False, shaderUseSubgroupOps=False;
        MESA_SHADER_CACHE_MAX_SIZE=512MB; WINEESYNC=1.
  - LOW:  All MID settings plus STRONGMEM=3, maxFeatureLevel=10_0,
        usePipelineLibrary=False, shader cache 256MB.
  - HIGH: dxvk.useDescriptorIndexing=True, d3d11.maxFeatureLevel=12_0.

NTSyncHelper.kt:
  - Auto-detects /dev/ntsync (Linux 6.14+ kernel primitive).
  - Enables WINENTSYNC=1 + PROTON_USE_NTSYNC=1 when available.
  - Overrides esync fallback for ~10-20% sync overhead reduction.

MemoryBudgetHelper.kt:
  - <6GB RAM: caps DXVK pipeline cache to 512MB.
  - <4GB RAM: disables PulseAudio (AURORA_DISABLE_PULSEAUDIO=1 marker),
    caps cache to 256MB, raises BOX64_DYNAREC_STRONGMEM=3.

## Integration points

GuestProgramLauncherComponent.java:
  - Aurora helpers called AFTER envVars.putAll(this.envVars) so user/container
    env vars merge first; tier presets only fill gaps via putIfAbsent.
  - Order: TierPresets -> NTSyncHelper -> MemoryBudget -> MaliSanitizer.
  - Wrapped in try/catch: Aurora helpers never block game launch.

ImageFsInstaller.java:
  - Deploys libaurora_mali_sanitizer.so from APK to imagefs/usr/lib/.
  - Writes Vulkan layer manifest JSON with name 'Aurora_Mali_Sanitizer'
    (matches AuroraSanitizerHelper.LAYER_NAME).
  - Falls back to DXVK_CONFIG mode if .so missing.

EnvVars.java:
  - Added putIfAbsent() for tier presets (preserves user overrides).

CMakeLists.txt:
  - Builds libaurora_mali_sanitizer.so as shared lib, linked to vulkan+log+dl.

## Not verified in this environment

  - No Android SDK/NDK available here; static verification only (brace
    balance, hook dispatch wiring, API surface checks against WinNative
    source). Real compile happens in GitHub Actions CI on push.
  - No real Mali device available here; the B4 dynamic-offset fix is
    verified by static trace (one happy path + two fallback paths) but
    not by runtime testing on a game that uses >4 dynamic UBO sets.
  - DeviceTier classification is heuristic; real-world tier assignment
    needs validation on actual mid-end hardware (Snapdragon 7 Gen 1/2,
    Mali G610, etc.).

## Honest scope notes

  - UI tab for Aurora status is NOT included. Per Module 4 (Definition of
    Done), a UI display would need a real consumer; for now the tier is
    logged at launch (logcat tag: AuroraTierPresets, AuroraDeviceTier)
    which is a real producer+consumer (logs -> user reads logcat).
  - Aurora SanitizerHelper detects Mali via GPUInformation.getRenderer(),
    same as WinNative's existing Mali checks. Immortalis-prefix strings
    are now also detected (B9 fix).
…ot (context)

CI caught: DeviceTier.kt:48 called getRenderer(context) but the WinNative
signature is getRenderer(String driverName, Context context). Pass null
for driverName to use the active driver, matching how GuestProgramLauncherComponent
calls it at line 869.

@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: 2a8ba54c5d

ℹ️ 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".

Comment on lines +888 to +889
VKAPI_ATTR VkResult VKAPI_CALL vkNegotiateLoaderLayerInterfaceVersion(
VkNegotiateLayerInterface* pVersion)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Export layer entrypoints with C linkage

When full sanitizer mode is enabled, the Vulkan loader has to dlsym the exact function names from the manifest, but these entrypoints are in a .cpp file without extern "C" and the CMake target also uses -fvisibility=hidden. On Mali devices where the .so and JSON are deployed, the loader will not find exported symbols named vkNegotiateLoaderLayerInterfaceVersion/vkGetInstanceProcAddr, so the requested VK_INSTANCE_LAYERS layer either fails to load or prevents Vulkan instance creation instead of applying the sanitizer.

Useful? React with 👍 / 👎.

Comment on lines +49 to +50
val soc = (Build.SOC_MODEL ?: "").lowercase()
val socMfr = (Build.SOC_MANUFACTURER ?: "").lowercase()

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Gate SOC fields on Android 12+

This code runs for every guest launch, but the app supports minSdk 26 and Build.SOC_MODEL/SOC_MANUFACTURER only exist on API 31+. On Android 8–11, resolving these fields throws NoSuchFieldError (not caught by the launcher’s catch (Exception)), so launching a game can crash before the tier presets are applied; use an SDK check like the existing callers in the repo do before reading these fields.

Useful? React with 👍 / 👎.

Comment on lines +94 to +96
} else if (existingConfig.contains("dxvk.useDescriptorIndexing")) {
// Already has a descriptorIndexing setting — don't double-set.
existingConfig

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 Override conflicting descriptor-indexing fallback

In fallback mode this guard skips all Mali workarounds whenever DXVK_CONFIG already mentions dxvk.useDescriptorIndexing; that includes high-tier Mali/Immortalis devices, because TierPresets runs first and writes dxvk.useDescriptorIndexing = True. If the native layer is absent or deployment fails, fallback then preserves the crashing setting and also omits the pipeline-library/subgroup caps, so the Mali fallback does not actually protect those launches.

Useful? React with 👍 / 👎.

Comment on lines +827 to +831
// Pass through to next layer
if (instance) {
InstanceDispatch* dispatch = get_instance_dispatch(instance);
if (dispatch && dispatch->get_instance_proc_addr) {
return dispatch->get_instance_proc_addr(instance, pName);

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 Filter blacklisted extensions during enumeration

The layer stores vkEnumerateDeviceExtensionProperties but never returns a hook for it here, so DXVK and other apps still see the blacklisted Mali extensions during capability probing. vkCreateDevice later silently removes those names from a copied create-info, leaving the app’s feature decisions based on extensions it believes are enabled; this can keep the Mali crash paths active or produce invalid extension use after device creation.

Useful? React with 👍 / 👎.

CI caught: GuestProgramLauncherComponent.java called TierPresets.apply(),
NTSyncHelper.applyIfSupported(), MemoryBudgetHelper.apply(), and
AuroraSanitizerHelper.setupSanitizer() as static methods, but Kotlin
'object' declarations expose instance methods on INSTANCE by default.
Adding @JvmStatic generates proper static facade methods callable from
Java without changing the Kotlin call syntax.
- Rewrite README.md for this fork (explains WinNative × Aurora,
  device-tier tuning, Mali sanitizer, build/install/verify instructions,
  project layout, credits, license).
- Add CHANGELOG.md (Keep a Changelog format).
- Add CONTRIBUTING.md (build, style, PR process, game fix guide, tier
  preset guide, security disclosure).
- Add CODE_OF_CONDUCT.md (Contributor Covenant 2.1).
- Add docs/AUDIT.md — deep audit of original Aurora (16 bugs, 9 dropped
  as dead code).
- Add docs/TIER_TUNING.md — rationale for each env var per tier.
- Add docs/MALI_SANITIZER.md — how the Vulkan layer works, including
  B4/B6 fix details and known limitations.
- Add .github/ISSUE_TEMPLATE/bug_report.md, performance_issue.md,
  feature_request.md.
- Add .github/PULL_REQUEST_TEMPLATE.md (includes tier-preset benchmark
  table requirement for TierPresets.kt changes).
- Update .gitignore to exclude secrets (tokens, keys, .env, askpass).
@boiniArun2006 boiniArun2006 merged commit 686dddf into main Jun 24, 2026
3 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