Skip to content

Shaders: skip f32 flushes in widened f16 comparisons - #3738

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

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

Conversation

@andrewpozdnakov7-jpg

Copy link
Copy Markdown
Contributor

The f32 comparisons used to implement unpacked f16 min, max and median can take their widened inputs directly. The smallest nonzero f16 magnitude is 2⁻²⁴, which is normal in f32. Widening and applying abs/neg cannot produce an f32 subnormal. The comparisons still use the existing signed-zero handling, and results still narrow through the existing f16 path. Microsoft's f16-to-f32 conversion documentation.

Generated compute shader DXIL instructions, main → change DXIL bytes, main → change
v_min_f16 107 → 95 2,904 → 2,840
v_min3_f16 or v_max3_f16 132 → 108 3,032 → 2,912
v_med3_f16 157 → 139 3,172 → 3,080

On Microsoft WARP 1.0.22 with Agility 1.620.2, the five encodings tested together returned the same 851,968 output words on both revisions. The generated inputs exercise every 16-bit pattern, both source and destination halves, abs/neg, clamp, and preservation of the other destination half. The existing f16 model and signed-zero regression passed. Strict all-feature shader Clippy and the asset policy passed.

#3733 addresses three-way f32 comparisons. #3365 handles output denormals according to MODE. This change removes f32 checks from comparisons whose source values were widened from f16. 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 6a4a505, including the workspace tests and both Clippy configurations. The same 851,968 output words also matched with #3365's f16 output-MODE changes. 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