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

feat: implement F16 support in shaders #5701

Open
wants to merge 1 commit into
base: trunk
Choose a base branch
from

Conversation

FL33TW00D
Copy link
Contributor

@FL33TW00D FL33TW00D commented May 13, 2024

Connections

Checklist for merge-ability

Additional context

F16 is available in >=SM6.2: https://github.com/microsoft/DirectXShaderCompiler/wiki/16-Bit-Scalar-Types

@FL33TW00D FL33TW00D mentioned this pull request May 14, 2024
@FL33TW00D FL33TW00D changed the title feature: Parse enable directives feature: Parse enable directives & SHADER-F16 support May 14, 2024
@FL33TW00D FL33TW00D marked this pull request as ready for review May 15, 2024 21:19
@FL33TW00D FL33TW00D requested a review from a team May 15, 2024 21:19
@FL33TW00D FL33TW00D requested a review from a team as a code owner May 15, 2024 21:19
@FL33TW00D
Copy link
Contributor Author

I've marked this as ready for review, as the wgpu specific logic is implemented and would be great to start iterating on it.

2 main blockers are:

  1. Merging of the PR on half-rs.
  2. hexf-parse improved implementation.

@FL33TW00D
Copy link
Contributor Author

FL33TW00D commented May 20, 2024

Dogfooding works! Fixed a few bugs in 30e12b5. Still waiting on upstream.

@teoxoy

This comment was marked as resolved.

@FL33TW00D

This comment was marked as resolved.

@teoxoy
Copy link
Member

teoxoy commented Jun 13, 2024

One thing I'm concerned is that the polyfills we have in some of the backends might not support f16. It would be worth adding more tests covering the built-in functions and operations that support f16. Execution tests would be great as well, they live in tests/tests/shader.

@teoxoy

This comment was marked as resolved.

@teoxoy teoxoy self-assigned this Jun 13, 2024
@FL33TW00D FL33TW00D force-pushed the feature/enable branch 2 times, most recently from 9c6a9b3 to 9f33e0e Compare June 14, 2024 14:20
@ErichDonGubler

This comment was marked as outdated.

@ErichDonGubler ErichDonGubler added type: enhancement New feature or request backend: webgpu Issues with direct interface with WebGPU labels Jun 14, 2024
@raphamorim
Copy link

You forgot to specify the branch in the cargo git dep!

You are indeed correct, thank you!

@ErichDonGubler

This comment was marked as outdated.

@cwfitzgerald
Copy link
Member

Getting this over the line is on my list, will probably be next week.

@ErichDonGubler
Copy link
Member

I've resolved conflicts with the latest examples/ changes (I think, spot check me @cwfitzgerald), and added a fixup! that tentatively consumes @raphamorim's half-2 crate.

@cwfitzgerald cwfitzgerald force-pushed the feature/enable branch 2 times, most recently from 8192315 to d4909a2 Compare February 1, 2025 04:27
@cwfitzgerald
Copy link
Member

I have split the hex parsing task into a different work item to follow this. See #7046.

@ErichDonGubler
Copy link
Member

Just realized that we didn't have the vec{2,3,4}h type aliases getting added to WGSL here. Pushed up 493e740 as a fixup! to remediate that.

@cwfitzgerald
Copy link
Member

Restored ownership of the commit, sorry about that :)

@raphamorim
Copy link

man it's happening, let's go! ❤️

@cwfitzgerald @ErichDonGubler please lemme know if i can help somehow

This was referenced Feb 20, 2025
@cwfitzgerald cwfitzgerald force-pushed the feature/enable branch 2 times, most recently from e6419c4 to 7b42714 Compare February 20, 2025 02:59
Comment on lines +262 to +266
pub(super) const fn check_width(
&self,
scalar: crate::Scalar,
) -> Result<PushConstantCompatibility, WidthError> {
let mut push_constant_compatibility = Ok(());
Copy link
Member

Choose a reason for hiding this comment

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

This is the one change I wasn't sure about, but this solution does end up working fine.


/// Runs through all example shaders and ensures they are valid wgsl.
#[test]
pub fn parse_example_wgsl() {
let read_dir = match PathBuf::from(env!("CARGO_MANIFEST_DIR"))
Copy link
Member

Choose a reason for hiding this comment

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

This needs to be factored out.

Copy link
Member

Choose a reason for hiding this comment

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

Split out as #7191

@@ -1,17 +1,17 @@
; SPIR-V
; Version: 1.0
; Generator: rspirv
; Bound: 125
; Bound: 123
Copy link
Member

Choose a reason for hiding this comment

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

Why did this change?

Copy link
Member

Choose a reason for hiding this comment

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

Oh I remember why - the old As code ended up allocating an id that it never used. The new code does not have this property, so there's some small renumberings in the other spvasm files.

Co-authored-by: FL33TW00D <[email protected]>
Co-authored-by: ErichDonGubler <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: cts Issues stemming from the WebGPU Conformance Test Suite area: naga back-end Outputs of naga shader conversion area: naga front-end area: naga processing Passes over IR in the middle backend: webgpu Issues with direct interface with WebGPU lang: WGSL WebGPU Shading Language naga Shader Translator type: enhancement New feature or request
Projects
Status: In Progress
Development

Successfully merging this pull request may close these issues.

[meta] f16 support WGSL: Support the enable directive
8 participants