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

modf unavailable on WGSL #112

Open
Duckonaut opened this issue Nov 15, 2023 · 0 comments
Open

modf unavailable on WGSL #112

Duckonaut opened this issue Nov 15, 2023 · 0 comments

Comments

@Duckonaut
Copy link

When compiling a GLSL shader to WGSL, if the shader is using the modf function, the error unhandled GLSL.std.450 instruction 35 is thrown.

As far as I understand, this is because the modf in GLSL gets compiled to the SPIR-V instruction Modf, (which apparently is deprecated? https://registry.khronos.org/SPIR-V/specs/unified1/GLSL.std.450.html) and is an instruction that returns a single value, while the modf in WGSL returns the fractional and whole parts (https://www.w3.org/TR/WGSL/#modf-builtin) which I would assume is the ModfStruct instruction in SPIR-V.

I don't know if this is on sokol-shdc to handle, or an odd incompatibility with the SPIR-V tools, because I'd imagine it isn't impossible to just use that struct-returning function on wgsl and add a .fract .

Attached is the shader that causes trouble.

modf.txt

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

No branches or pull requests

1 participant