Skip to content

asahi: share negative-zero operands for G16 uniform clamps - #48

Open
IronsideXXVI wants to merge 2 commits into
omacom:integration/aurorafrom
IronsideXXVI:fix/g16-shared-negative-zero
Open

IronsideXXVI wants to merge 2 commits into
omacom:integration/aurorafrom
IronsideXXVI:fix/g16-shared-negative-zero

Conversation

@IronsideXXVI

@IronsideXXVI IronsideXXVI commented Nov 17, 2026 •

Copy link
Copy Markdown

G16 uniform clamps currently copy each uniform into a GPR before a saturated float32 add. Reuse one negative-zero GPR per block instead, retaining the same add, operand order, saturation and precision. This is restricted to eligible G16G operands. ASAHI_G16_SHARED_NZ=0 restores the previous path; the compiler-cache key includes the choice.

On an M4 MacBook Pro, a balanced same-boot old/off/on/on/off/old test of 1080p RGBA8 blended fill (depth 64, three samples per window) measured 371.494 → 348.73585 µs per submit, a 6.126% latency reduction. Every enabled sample was below every disabled sample. The selected shader changed from 178 bytes/25 compiler instructions to 170 bytes/22, with GPR/spill counts unchanged. Across all three arms, a finite 64-frame, 16-layer blend readback matched byte-for-byte and each arm had zero GPU faults. Diagnostic timings were excluded.

Validation: the experimental compiler suite passed 977 tests in both modes (one skipped and one disabled). Added tests cover materialization, captured blend expression compilation, signed zero, finite clamp boundaries and host bit-pattern cases. Production Mesa/Vulkan 1.8145 packages have now passed the official 188 Meson tests with zero failures; default and explicit opt-out compiler cases pass 3/3 each. The integration/aurora port also builds and passes those cases in both modes. Gallium and Vulkan cache keys both separate the opt-out. These are finite differential correctness results, not a full graphics conformance or macOS-parity claim; no constant-program protocol is changed.

Hardware testing used the installed 8f013bf-based Mesa plus three distribution patches. This PR ports only the optimization and its tests onto integration/aurora; it does not import that entire source branch. No Apple binaries or captures are included.

Preserve f32 saturated-add semantics while materializing one negative-zero GPR per block rather than copying every uniform source. Qualified on an M4 with matching finite blend readbacks and 6.126% lower fill submission time. Retain ASAHI_G16_SHARED_NZ=0 opt-out and include the choice in the Vulkan compiler cache key.

Assisted-by: LLM
Retain a reliable opt-out for OpenGL as well as Vulkan when process flags change.

Assisted-by: LLM
@greptile-apps

greptile-apps Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge.

Summary

Shares one negative-zero register per block for eligible G16G uniform clamps while keeping the saturated float32 add.

  • G16G clamp adds share one negative-zero register per block.
  • Shader caches distinguish whether G16G clamp sharing is enabled.

Reviews (1) · Last reviewed commit: "asahi: separate G16 materialization choi..." · Reviewed by Greptile

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