Skip to content

Conversation

@jamienicol
Copy link
Contributor

Connections
Follow up from #7437

Description
DXC and FXC currently can parse the most negative value integer literals fine (unlike the metal compiler). However, we have been informed on the DX discord that this is not guaranteed. So let's avoid them on HLSL too just to be safe.

Additionally we need to update the workarounds for signed integer division and modulo to avoid using them.

Testing
Snapshots cover it well

Squash or Rebase?

Rebase plz

Checklist

  • Run cargo fmt.
  • Run cargo clippy --tests. If applicable, add:
  • Run cargo xtask test to run tests.

…-negative value minus one

As we did for MSL in gfx-rs#7437. eg `-2147483648` becomes `-2147483647 - 1`.

Neither FXC nor DXC currently have any issues parsing the most negative
value literals. However, we have been informed this is not guaranteed to
always be the case, so are making this change as a precaution.
… and modulo avoid using minimum value literals

As we know that minimum value integer literals can cause problems for
some compilers. (See gfx-rs#7437)

Make the code which generates these functions call
msl::Writer::put_literal() and hlsl::Writer::write_literal()
respectively to output the minimum value integer literals instead of
just writing them directly, ensuring we only have to handle this
workaround in a single location (per backend).
@ErichDonGubler ErichDonGubler merged commit 08d3bb5 into gfx-rs:trunk Apr 10, 2025
37 checks passed
@jamienicol jamienicol deleted the more-min-int-literal-fun branch April 10, 2025 14:45
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.

2 participants