wgsl-tooling-wg / wesl-spec

A portable and modular superset of WGSL
BSD 3-Clause "New" or "Revised" License
41 stars 3 forks source link

@inline attribute #47

Open k2d222 opened 2 months ago

k2d222 commented 2 months ago

a @inline attribute would cause the function body to be copy-pasted in place of the function call.

Why would we want this? In my current understanding of driver's shader compilation, we don't. Because since shader code has very few side-effects, drivers already inline functions by themselves.

It would be nice to get some insider's confirmation of this, or study whether that is really the case and if there can be any performance implications when inlining manually.

mighdoll commented 2 months ago

fwiw slang suggests that it's generally unnecessary, but supports it: http://shader-slang.com/slang/user-guide/convenience-features.html#force-inlining