naga_oil icon indicating copy to clipboard operation
naga_oil copied to clipboard

Support wgsl diagnostic directives.

Open Elabajaba opened this issue 11 months ago • 3 comments

Wgpu added this in v24, but I didn't figure out how to get them working properly before we merged that PR so they're currently unsupported.

There's a basic test for them written. The test and the test input (though the expected output here is incorrect). The test currently panics due to the unwrap because the shader module creation is erroring for some reason.

Elabajaba avatar Feb 05 '25 21:02 Elabajaba

The error stems from the directive not being prior to all global declarations i.e. not all the way at the top. I'm running into the same issue trying to use an enable directive. (as of writing naga has the scaffolding for enable directive but there's none of them implemented, something I was about to change)

Wumpf avatar Feb 14 '25 22:02 Wumpf

Got a hack here to make it fly for myself. This is obviously nowhere close to a shippable solution. Prodded into doing something more cleaner but not having a great time navigating the codebase and tbh it's not something I want to invest time into right now. But maybe this helps illustrate the issue :) https://github.com/Wumpf/naga_oil/commit/fcfe28070c54bafab624c2ed6c6b11d953d7a066

Hit another snag though on the Naga side: the module -> wgsl writeout that is used when targeting WebGPU isn't emitting enable directives either right now :sigh:

Wumpf avatar Feb 14 '25 23:02 Wumpf

Hit another snag though on the Naga side: the module -> wgsl writeout that is used when targeting WebGPU isn't emitting enable directives either right now :sigh:

practically oftopic to this issue, but FYI got that part under control over on wgpu by now 🥳 (part of https://github.com/gfx-rs/wgpu/pull/7146)

Wumpf avatar Feb 15 '25 13:02 Wumpf