shader: emit binary32 float literals in graphics HLSL #3568

Merged
tedin7 merged 4 commits from upstream-pr/3568 into main 2026-11-30 09:36:05 +00:00
tedin7 commented 2026-11-30 09:10:34 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-30T09:10:34Z.


Problem

  1. tools/startup/gfx2hlsl.py emitted unsuffixed floating-point literals (such as 1.0, 0.0, 255.0, 0.0625, 6.283185307), which DXC/HLSL can treat as double-precision literals or trigger implicit conversion issues in graphics HLSL.
  2. tests/startup_gfx2hlsl_f16_alu_check.py evaluated lowered HLSL expressions in Python without stripping the f suffix from float literals.

Fix

  • Add the f suffix to binary32 floating-point literals emitted by tools/startup/gfx2hlsl.py.
  • Update tests/startup_gfx2hlsl_vcvt_omod_check.py, tests/startup_gfx2hlsl_cvt_off_f32_i4_check.py, and tests/startup_gfx2hlsl_f16_alu_check.py (plus tests/checks/python-linux/gfx2hlsl-vcvt-omod.txt) to expect and parse binary32 f-suffixed float literals.

Verification

  • python3 -B tests/startup_gfx2hlsl_vcvt_omod_check.py (passed)
  • python3 -B tests/startup_gfx2hlsl_f16_alu_check.py (passed)
  • python3 -B tests/startup_gfx2hlsl_cvt_off_f32_i4_check.py (passed)
  • python3 -B tests/bidi_controls_check.py (passed)
  • python3 -B tests/docs_links_check.py (passed)
  • git diff --check origin/main..HEAD (passed)
<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:5562294834 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3568). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-30T09:10:34Z. --- ### Problem 1. `tools/startup/gfx2hlsl.py` emitted unsuffixed floating-point literals (such as `1.0`, `0.0`, `255.0`, `0.0625`, `6.283185307`), which DXC/HLSL can treat as double-precision literals or trigger implicit conversion issues in graphics HLSL. 2. `tests/startup_gfx2hlsl_f16_alu_check.py` evaluated lowered HLSL expressions in Python without stripping the `f` suffix from float literals. ### Fix - Add the `f` suffix to binary32 floating-point literals emitted by `tools/startup/gfx2hlsl.py`. - Update `tests/startup_gfx2hlsl_vcvt_omod_check.py`, `tests/startup_gfx2hlsl_cvt_off_f32_i4_check.py`, and `tests/startup_gfx2hlsl_f16_alu_check.py` (plus `tests/checks/python-linux/gfx2hlsl-vcvt-omod.txt`) to expect and parse binary32 `f`-suffixed float literals. ### Verification - `python3 -B tests/startup_gfx2hlsl_vcvt_omod_check.py` (passed) - `python3 -B tests/startup_gfx2hlsl_f16_alu_check.py` (passed) - `python3 -B tests/startup_gfx2hlsl_cvt_off_f32_i4_check.py` (passed) - `python3 -B tests/bidi_controls_check.py` (passed) - `python3 -B tests/docs_links_check.py` (passed) - `git diff --check origin/main..HEAD` (passed)
chatgpt-codex-connector[bot] commented 2026-11-30 09:10:47 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-30T09:10:47Z.


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-30T09:24:25.986615Z 78fe2be 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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7273846333 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3568#issuecomment-7273846333). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/apps/chatgpt-codex-connector) on 2026-11-30T09:10:47Z. --- <!-- codex-pull-request-review-summary --> <!-- codex-review-state:v1 {"code_review":{"commit_sha":"78fe2bec9a5beec74c12a8893bb115597e894740","has_any_findings":true,"has_unresolved_findings":true,"status":"completed"},"security_review":{"commit_sha":null,"has_any_findings":null,"has_unresolved_findings":null,"status":null}} --> <details> <summary><strong>Codex Review Summary</strong>: ✅ Completed</summary> This comment shows the latest Codex review activity on this pull request. | Review | Status | Commit | Review trigger | | --- | --- | --- | --- | | 📝 **Code Review** | ✅ **Completed** <relative-time datetime="2026-11-30T09:24:25.986615Z">2026-11-30T09:24:25.986615Z</relative-time> | `78fe2be` | PR opened | <details> <summary>ℹ️ About Codex in GitHub</summary> <br/> [Your team has set up Codex to review pull requests in this repo](https://chatgpt.com/codex/cloud/settings/general). 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. </details> </details>
chatgpt-codex-connector[bot] commented 2026-11-30 09:24:23 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-30T09:24:23Z.

Review: COMMENTED


💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 78fe2bec9a

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

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6109593316 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3568#pullrequestreview-6109593316). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/apps/chatgpt-codex-connector) on 2026-11-30T09:24:23Z. **Review:** COMMENTED --- <!-- codex-review-receipt:v1 --> ### 💡 Codex Review Here are some automated review suggestions for this pull request. **Reviewed commit:** `78fe2bec9a` <details> <summary>ℹ️ About Codex in GitHub</summary> <br/> [Your team has set up Codex to review pull requests in this repo](https://chatgpt.com/codex/cloud/settings/general). 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". </details>
chatgpt-codex-connector[bot] commented 2026-11-30 09:24:23 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-30T09:24:23Z.

Code review location: tools/startup/gfx2hlsl.py; line 3017

@@ -3014,7 +3014,7 @@ def f_mods(self, expr, mods=()):
                 raise Unsupported('modifier %s' % m)
         if scale != 1.0:
             factor = ('%d.0' % int(scale)) if scale == int(scale) else ('%g' % scale)
-            expr = '(%s) * %s' % (expr, factor)
+            expr = '(%s) * %sf' % (expr, factor)

P1 Badge Update the remaining literal-sensitive shader checks

The python-linux job in .github/workflows/windows.yml still runs several checks that were not adapted to these suffixes. In particular, tests/startup_gfx2hlsl_sdwa_cvt_check.py::eval_emitted_v0 sends the generated * 0.5f expression directly to Python eval, raising SyntaxError: invalid decimal literal; startup_gfx2hlsl_fma_mix_check.py and startup_gfx2hlsl_float_transcendental_check.py also fail because their golden strings and mutation patterns still require unsuffixed literals. All three checks pass on the parent revision. Update the remaining evaluators and literal-sensitive expectations alongside the emission change so the standard CI regression suite continues to pass.

Useful? React with 👍 / 👎.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4737110517 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3568#discussion_r4737110517). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/apps/chatgpt-codex-connector) on 2026-11-30T09:24:23Z. **Code review location:** `tools/startup/gfx2hlsl.py`; line 3017 ~~~~diff @@ -3014,7 +3014,7 @@ def f_mods(self, expr, mods=()): raise Unsupported('modifier %s' % m) if scale != 1.0: factor = ('%d.0' % int(scale)) if scale == int(scale) else ('%g' % scale) - expr = '(%s) * %s' % (expr, factor) + expr = '(%s) * %sf' % (expr, factor) ~~~~ --- **<sub><sub>![P1 Badge](https://img.shields.io/badge/P1-orange?style=flat)</sub></sub> Update the remaining literal-sensitive shader checks** The `python-linux` job in `.github/workflows/windows.yml` still runs several checks that were not adapted to these suffixes. In particular, `tests/startup_gfx2hlsl_sdwa_cvt_check.py::eval_emitted_v0` sends the generated `* 0.5f` expression directly to Python `eval`, raising `SyntaxError: invalid decimal literal`; `startup_gfx2hlsl_fma_mix_check.py` and `startup_gfx2hlsl_float_transcendental_check.py` also fail because their golden strings and mutation patterns still require unsuffixed literals. All three checks pass on the parent revision. Update the remaining evaluators and literal-sensitive expectations alongside the emission change so the standard CI regression suite continues to pass. Useful? React with 👍 / 👎. <!-- codex-code-review-finding:v1 -->
tedin7 commented 2026-11-30 09:30:28 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-30T09:30:28Z.

Code review location: tools/startup/gfx2hlsl.py; line 3017

@@ -3014,7 +3014,7 @@ def f_mods(self, expr, mods=()):
                 raise Unsupported('modifier %s' % m)
         if scale != 1.0:
             factor = ('%d.0' % int(scale)) if scale == int(scale) else ('%g' % scale)
-            expr = '(%s) * %s' % (expr, factor)
+            expr = '(%s) * %sf' % (expr, factor)

Fixed in 831b7e612 and 96c1506ed.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4737173585 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3568#discussion_r4737173585). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-30T09:30:28Z. **Code review location:** `tools/startup/gfx2hlsl.py`; line 3017 ~~~~diff @@ -3014,7 +3014,7 @@ def f_mods(self, expr, mods=()): raise Unsupported('modifier %s' % m) if scale != 1.0: factor = ('%d.0' % int(scale)) if scale == int(scale) else ('%g' % scale) - expr = '(%s) * %s' % (expr, factor) + expr = '(%s) * %sf' % (expr, factor) ~~~~ --- Fixed in 831b7e612 and 96c1506ed.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
R0Y00/Xbox2Windows!3568
No description provided.