-
Notifications
You must be signed in to change notification settings - Fork 429
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
MoltenVK 1.2.11 breaks vkdoom #2374
Comments
However, to be fair, vkdoom at no point passes validation, so the fact it worked before was probably a lucky accident. The validation errors:
|
Please run vkDoom with the following environment variables set:
This will log the shaders, descriptor sets, and errors. Please ZIP up that log into a file, and post it here. Also, to try to replicate this here, we'll need help getting vkDoom set up here to test it. A Google search leads to the following repos: https://github.com/dpjudas/VkDoom Is this correct? Or is vkDoom found somewhere else? Is a macOS prebuilt app somewhere? The VkDoom repo mentions nightly builds, but there are no macOS binaries archived there. If these are the correct repos, we'll need some more detail on how to work with this:
|
|
Thanks. I've got it built now, but hitting:
Did I miss an install step? I can't find a WAD in the repo dir. Where can we get one? |
Oh, right forgot about that --- usually you can get them off of the Internet Archive, but they're down right now. I'm not at my computer right now, so I'll send the WAD to you when I'm in front of it. |
NM. I sourced on online. I'm able to replicate the error now. |
One thing I have noticed is that on 1.2.9, the structs in the converted MSL used |
Okay. I believe I see what the issue is now. The app is using the following descriptor set, containing a runtime array of up to 16,536 combined image samplers:
With With Until recently, MoltenVK allocated the entire maximum count, which in your case, effectively created two separate 16,536 arrays in the Metal argument buffer. This was changed in PR #2273, to reduce memory and avoid pool exhaustion, as identified in issue #2246. I'll investigate some options for dealing with this. |
I think I saw an issue like this earlier (I forgot whether it was filed with MoltenVK or SPIRV-Cross) where unless you actually access a vector in the SPIR-V code, the corresponding vector in the outputted MSL will have a length of 1. I'm not sure they are related though. |
MoltenVK deliberately sets the array length to 1 in MSL for any variable-length arrays. This is because the array length is not known at shader conversion and compile time. Setting it in MSL to the maximum size it can have, like your 16,536, results in a Metal validation error when the descriptor set only contains a smaller count. This is not the problem here. The problem here is that The likely solution is to change it from two arrays, to an array of two-member structures. This requires work both in SPIRV-Cross and MoltenVK. |
Could you have two member structs, each with 1 VLA? |
Each Metal argument buffer is just a set of resource slots. Basically just a large array, very similar to a Vulkan descriptor set. If we have fixed length arrays in a Metal Argument Buffer:
the shader knows where the offset is for the first sampler. If, instead, we have two variable length arrays:
the shader doesn't know how to offset into the first sampler, because it doesn't know how far the This is why there can be only be one variable length array in each descriptor set, and why it has to be at the end. This is true of both Metal and Vulkan. I believe you are suggesting that we wrap each of This is why I think the way around this is to declare an array of two-element structs:
The shader can then find any sampler (or texture) in the Metal arg buffer, by indexing into the array and then offsetting within the struct to get either member. |
Yeah, that makes sense. |
In the meantime, I worked around the issue by disabling variable descriptor sets (hopefully, this is only temporary). |
This used to be a comment under #2146, but I thought it would be better as its own issue:
1.2.11 (up to 78396b7) breaks vkdoom, regardless of whether Metal argument buffers are used or not --- the error messages are different though (vkdoom worked on 1.2.9 with
MVK_CONFIG_USE_METAL_ARGUMENT_BUFFERS=1
). From using Actions artifacts, I have determined that the problem existed since at least 96f9d89:MVK_CONFIG_USE_METAL_ARGUMENT_BUFFERS=0
:MVK_CONFIG_USE_METAL_ARGUMENT_BUFFERS=1
:The text was updated successfully, but these errors were encountered: