-
Notifications
You must be signed in to change notification settings - Fork 562
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
MSL: runtime array over argument buffers #2179
Conversation
Metal3-style bindless (ie- consistent 64-bit argbuff elements) seems to be working already. What Metal3 features are you adding here?
I guess this implies argument buffers can contain only homogeneous types? Is that the reason for excluding descriptor-set structures? A typical descriptor set use would be:
A runtime array would only be used for the last member, and should be usable by declaring that member as |
Hi, @billhollings ! Glad, that you jumping in discussion)
No, this is actually not a solution at all. Engine setup I'm working on requires multiple runtime arrays (not just one), where each array can be modified/resized at runtime. Also to be clear: I'm not using MoltenVK, proffering native Metal support on engine level.
Just don't need them :)
Yet, don't know if MoltenVK needs something, like this. |
I thought that didn't work, and you had to use a bare array for that instead: |
Oops! My bad. I was quoting from memory, based on the pattern of using a length-1 array, and clearly got the syntax wrong. Thanks for the correction. |
I've been on vacation for some time and I'm back from vacation on Aug 6th ish to look at this, so please excuse any inactivity. |
Can you explain what you mean here? |
Do we know if the 1-sized array trick will work for descriptors? (It's silly that there is no C99 unsized array). |
The spvBufferDescriptor feels awkward. I assume this forms an ABI that users must be aware of? I think we'd need an option to control the layout of array-of-SSBO to deal with this. Also, it seems useful to be able to use the array style even for non-runtime sized arrays. The current implementation of array-of-SSBO and UBO for discrete descriptors is extremely awkward, having to unroll them and reroll them back into a thread local array is pretty disgusting. |
I also wonder if it's possible to wrap the entire array into a type that deals with the
That should simplify a lot of things and we might be able to wrap most of this into the type declaration rather than special casing this everywhere. |
It's not legal in MSL to declare array of pointers/descriptors straight:
Yes, engine have to pass buffer size to shader, so
Yes, yet keep in mind that this feature is Metal3-Tier2 - quite high-end.
Can you provide some details, on how do you want it?
Almost. It' not legal in declaration of
|
I think that style would be preferable. Having a fixup hook to declare that object is easy, and all other code can consider the wrapped type, avoiding any special hooks.
I think we'd just want an option to either enable or disable the length field. Using OpArrayLength is somewhat esoteric and I can see the desire to just have a flat array of pointers. If ArrayLength is used without it enabled, it should throw an error. |
Addressed issues:
|
Merged on master with some nits applied + squash. Thanks! |
This PR adds support for Metal3-style bindless. This is last bit that is missing for my engine to enable ray-query on Metal3.
For now works only, if descriptor-set over argument-buffer emulation (flag
--msl-argument-buffers
) is disabled. It's possible to extend, if required in future.Translation example:
uniform texture2D textures[];
->const device spvDescriptor<texture2d<float>>* textures
uniform Ubo { uint val; } ubo[]
->const device spvDescriptor<constant Ubo*>* ubo
spvDescriptor<T>
is simple wrapper structure, unfortunately MSL doesn't allow to have flat declaration.const device
address space is only option here. While Metal3 now allows any(device/constant/managed) space, device is most flexible.related to #2112