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

[naga hlsl-out] Handle array types for function return values and calls #6971

Merged
merged 1 commit into from
Jan 23, 2025

Conversation

jamienicol
Copy link
Contributor

Connections
Fixes #4393

Description
Currently the HLSL backend omits the array part of return types for functions and function call statements. This adds it in. Curiously it appears DXC allows the [n] part to follow the function name, like so:

float my_fun()[3] {...}

but FXC does not allow this. However, both FXC and DXC work if we use a typedef:

typedef float my_array[3];
my_array my_fun() {...}

Which is easy enough, so we do this.

Testing
Enabled the array-in-function-return-type test for the HLSL backend. Also extended it to use nested arrays to ensure those work as expected.

Checklist

  • Run cargo fmt.
  • Run taplo format.
  • Run cargo clippy. If applicable, add:
    • --target wasm32-unknown-unknown
    • --target wasm32-unknown-emscripten
  • Run cargo xtask test to run tests.
  • Add change to CHANGELOG.md. See simple instructions inside file.

@jamienicol jamienicol requested a review from a team January 22, 2025 14:27
Copy link
Member

@teoxoy teoxoy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@teoxoy teoxoy merged commit 0282d61 into gfx-rs:trunk Jan 23, 2025
31 checks passed
@jamienicol jamienicol deleted the hlsl-array-return-type branch January 29, 2025 09:29
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.

[hlsl-out] Invalid HLSL for function which returns an array
2 participants