Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tracking: Collection of issues found when porting HLSL to rust-gpu #744

Open
5 of 10 tasks
hrydgard opened this issue Sep 2, 2021 · 0 comments
Open
5 of 10 tasks
Labels
a: documentation Improvements or additions to documentation t: tracking issue An issue tracking the progress of a specific feature or change.

Comments

@hrydgard
Copy link
Contributor

hrydgard commented Sep 2, 2021

I and some others have been porting a body of HLSL code to rust-gpu. Here's some notes about unexpected differences, pitfalls, and hard-to-port things.

Fixable issues (doesn't mean they're easy!)

  • For loops compile to a mess that spirv-cross can't quite handle, so we're sticking to while loops
  • .abs() and .sign() don't work (cause 64-bit int code gen). See .abs() and .signum() cause 64-bit integer instruction generation #468
  • .saturate doesn't behave like HLSL's saturate with regards to NaNs. (glam issue?)
  • #derive(Debug) on a struct really weirds the compiler out, no way to see what you did wrong
  • Need to use #[rustfmt::skip] on shader entry points, since rustfmt eats long attributes!
    For example, this line gets mangled from:
    #[spirv(storage_buffer, descriptor_set = 0, binding = 1)] instance_constants_dyn: &[InstanceDynamicParameters],

into:

    instance_constants_dyn: &[InstanceDynamicParameters],

Unintuitive behavior mismatches

Inconveniences that may not be fixable

  • The mix of uint3 for global_invocation_id and int2/int3 for texture fetches is a lot more painful in rust than in HLSL.
    • This currently seems to just work? ~@oisyn
  • a.max(b) instead of max(a, b) is sometimes kinda laborious. though rust-style.
  • Sometimes need to do a lot more parameter passing since inputs are not global. Not necessarily a bad thing though.

Documentation issues

@hrydgard hrydgard added the a: documentation Improvements or additions to documentation label Sep 2, 2021
@repi repi added the t: tracking issue An issue tracking the progress of a specific feature or change. label Nov 3, 2021
@hrydgard hrydgard changed the title Collection of issues porting HLSL to rust-gpu Tracking: Collection of issues found when porting HLSL to rust-gpu Nov 3, 2021
@oisyn oisyn removed their assignment Mar 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a: documentation Improvements or additions to documentation t: tracking issue An issue tracking the progress of a specific feature or change.
Projects
None yet
Development

No branches or pull requests

4 participants
@hrydgard @repi @oisyn and others