You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Issue automatically imported from old repo: EmbarkStudios/rust-gpu#744 Old labels: a: documentation,t: tracking issue Originally creatd by hrydgard on 2021-09-02T11:14:16Z
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
The builtin #[spirv(global_invocation_id)] id: UVec3 needs to be declared as an UVec3, and then truncated if you want a Vec2. In HLSL and GLSL it's common to declare it as a 2-vector instead (UVec2) if you only care about x and y. #885
Unintuitive behavior mismatches
#895
const_mat3! is equivalent to the transpose of HLSL's float3x3. Same goes for the other matrix constructors, of course. Dangerous trap! But probably the right way around, really.const_mat3! is no longer supported in latest glam.
(macaw problem) step function is unintuitive: x.step(y) = step(y, x).
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.
Issue automatically imported from old repo: EmbarkStudios/rust-gpu#744
Old labels: a: documentation,t: tracking issue
Originally creatd by hrydgard on 2021-09-02T11:14:16Z
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!)
#derive(Debug)
on a struct really weirds the compiler out, no way to see what you did wrong#[rustfmt::skip]
on shader entry points, since rustfmt eats long attributes!For example, this line gets mangled from:
into:
Unintuitive behavior mismatches
const_mat3! is equivalent to the transpose of HLSL's float3x3. Same goes for the other matrix constructors, of course. Dangerous trap! But probably the right way around, really.const_mat3!
is no longer supported in latestglam
.Inconveniences that may not be fixable
Documentation issues
The text was updated successfully, but these errors were encountered: