-
-
Notifications
You must be signed in to change notification settings - Fork 124
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
Fixed size array support #125
Comments
This is something I want to add, but need support for fixed size arrays added to C# first. |
You can support only new T[constant] statements. Or Span variable= stackalloc T[constant]. |
Or use |
Could also permit [HlslArray(100)]
private struct Float4Len100 { public float4 element0; }
public float4 Execute()
{
Float4Len100 array = default;
for (int i = 0; i < 100; ++i) { array[i] = (float4)i; }
...
} It's kind of ugly, but this way we don't have to wait 5 years for whatever support might be hopefully added to C#. And if/when the right syntax does come along, just switch over to that and nuke the old syntax. This would unlock a lot of potential, the lack of this is currently limiting what I can do quite severely! |
I can see no reason not to support |
As @Sergio0694 explained it to me on Discord, it will still require an additional attribute so that the source generator knows when to kick in. So it would be [InlineArray(100)]
[HlslArray]
private struct Float4Len100 { public float4 element0; } And there is quite a bit of work in the generator that would be needed to enable all of this. Don't worry, I've been lobbying @Sergio0694 for this quite a bit -- he definitely knows how important this is :) There's also the matter of how to unify this across other arrays in other contexts, or other array-like-things such as |
Could you folks link any shaders here that do use fixed size arrays? I'm thinking about the implementation here, and I'd like to double check that against some real world code to make sure that it work work fine in those scenarios. Thank you! :) |
As far as I know, hlsl supports fixed-size arrays. Are there any plans to support the use of fixed-size arrays in shaders?
The text was updated successfully, but these errors were encountered: