Skip to content

Shaders: skip f32 flushes in packed f16 min and max - #3739

Open
andrewpozdnakov7-jpg wants to merge 1 commit into
Marvisak:mainfrom
andrewpozdnakov7-jpg:codex2/packed-half-minmax
Open

andrewpozdnakov7-jpg wants to merge 1 commit into
Marvisak:mainfrom
andrewpozdnakov7-jpg:codex2/packed-half-minmax

Conversation

@andrewpozdnakov7-jpg

Copy link
Copy Markdown
Contributor

Use the existing min/max helper for values already free of f32 subnormals in v_pk_min_f16 and v_pk_max_f16. Both halves widen their f16 inputs before the comparison. Even the smallest f16 subnormal is normal in f32, so the f32 subnormal checks are redundant. f16-to-f32 conversion.

For one packed min or max in a generated compute shader, DXIL went from 178 to 154 instructions and from 3,268 to 3,144 bytes. With per-half negation, it went from 180 to 156 instructions and from 3,288 to 3,168 bytes.

Microsoft WARP 1.0.22 with Agility 1.620.2 produced the same 524,288 output words on both revisions. The generated inputs cover every half bit pattern, both result halves, cross-selected source halves, per-half negation and clamp. The existing f16 model and packed input selector tests passed. Strict all-feature shader Clippy and the asset policy passed.

#3738 applies the same reasoning in the separate unpacked lowering. This change covers packed min/max. Game performance was unmeasured.

Please retain the Git author on cherry-pick or rebase, or add Co-authored-by: andrewpozdnakov7-jpg <andrewpozdnakov7-jpg@users.noreply.github.com> if folding the change into another commit.

AI-assisted with OpenAI Codex.

@andrewpozdnakov7-jpg

Copy link
Copy Markdown
Contributor Author

Windows CI passed on 6e47acf, including the workspace tests and both Clippy configurations. The integration with #2825 also verified that the widened f16 path gives identical WARP results and that the native modules are byte-identical. Combined result.

The next step is maintainer review. Please retain the Git author on cherry-pick or rebase, or add Co-authored-by: andrewpozdnakov7-jpg <andrewpozdnakov7-jpg@users.noreply.github.com> if folding the change into another commit.

AI-assisted with OpenAI Codex.

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