Replies: 1 comment
-
|
It's cool, but nah. We get automatic caching if we do this outside of the shader function. +const geometricSeries32 = geometricSeries(32);
const foo = () => {
'use gpu';
- const almostTwo = geometricSeries(32)(1, 0.5);
+ const almostTwo = geometricSeries32(1, 0.5);
}; |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Languages like C++, C#, Java and many more have a way to define generic parameters in functions that abstract over types and constant parameters that the function uses. It's similar to a regular function parameter, except that it operates on values that are known at compile-time, not a runtime. The Zig language makes that delineation even thinner, treating generic parameters the same as regular parameters, except prefixed with the
comptimekeyword.We already have a way to do comptime specialization in TypeGPU via
tgpu.slotandtgpu.derived, but explaining how to use them properly and using them in practice for generic programming can be a bit cumbersome. This was somewhat solved for parameter types with shellless functions that are inherently generic, but being generic over resources used by a function, or comptime parametrization is still only viable via the slot mechanism.Beta Was this translation helpful? Give feedback.
All reactions