-
Notifications
You must be signed in to change notification settings - Fork 433
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
WIP: Add: KHR_maintenance4 #2116
base: main
Are you sure you want to change the base?
Conversation
3fb74dc
to
232a125
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for submitting this.
A couple of changes needed, and some clarification of some of the changes.
VkDeviceSize getBytesPerLayer(uint8_t planeIndex, uint32_t mipLevel); | ||
VkDeviceSize getBytesPerLayer(uint8_t planeIndex, VkExtent3D mipExtent); | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the need for making the changes to getBytesPerRow()
and getBytesPerLayer()
?
I might be missing something, but I don't see how it changes the use of these functions in the code in this PR.
If the change is required, neither of these functions are connected to MIP levels now, so the function documentation should be changed, at the very least.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried explaining it at the bottom of the PR message. When I originally transformed the code to be all in MVKDevice I came across these functions and it just bugged me that it would call getExtent3D 3 times and getBytesPerRow 2 times, when every caller of getBytesPerLayer would need the values themselves and could instead just pass them as a parameter. So I decided to refactor this a bit just to remove some wasted function calls.
Not entirely related to the current state of the PR, but it was relevant to the original change where I re-implemented the memory requirement functions in the MVKDevice object.
I don't like it either, considering that the whole point of the new memory requirements functions is that you don't have to create a resource just to figure how much memory it needs. I think it should be possible to refactor |
I originally had it setup this way but it required a lot of code to be duplicated (especially on images with computing usage, formats, atomics, mips, layers, ...), and I wasn't sure I had everything setup correctly. The only thing I came up with that I would like is having a separate MVKBufferInfo/MVKImageInfo struct which contains basic information used to compute the memory requirements which gets created in every MVKBuffer/MVKImage but also the memory requirement functions on MVKDevice. Those structs would then have the getMemoryRequirement functions. I originally decided to just open the PR like this and then talk a bit about a possible better implementation. Though I will definitely look into shifting the functions into MVKDevice again. |
Full CTS testing of this PR caused at least one CTS crash, because This exposed the fragility of how we were mapping plane indexes to memory bindings. PR #2125 fixes that fragility, and we should rebase this PR to after #2125, once it's merged (note that PR has been pushed to a temporary branch In particular, any references in this PR to
|
Interesting. I only ever tested some parts of the CTS test because I couldn't figure out if there is any |
It's complicated. Sometimes an extension will include a large number of CTS test that have part of the extension name embedded in the test name. In this case, AFAICT there are only 3 CTS tests that have If the extension has decent CTS coverage, I don't always run full CTS tests on every extension addition, but since we were close to SDK release, I was doing that, in case we could squeeze this PR into the current SDK release. BTW...that full CTS run also exposed a couple of hundred new test failures along the lines of:
becomes:
From the error text, it doesn't look like it's related to In such a case, it might be good to pull the |
Yes this should probably be a WIP PR. I didn't fully test it and the implementation of the memory requirements functions wasnt yet "finished". But thanks, I'll look into the CTS tests more and see where the issues are coming from. |
The important thing when adding any new extension is to try to avoid CTS regressions (ie. For In this case, the |
I just want to put some of this information here for tracking. I've tried to find all CTS tests related to the extension, and ran them. There's a few things that fail with the currently pushed code:
Firstly, I will refactor the memory requirement code and then look at SPIRV-Cross. I currently have a concept which adds a |
To fix this properly, you need to implement input attachments as shader framebuffer fetch. SPIRV-Cross is already done; you just need to wire it up in MoltenVK. The hard part is mapping Vulkan input attachments to Metal render target indices. |
Any updates on this? |
Are there any plans to move forward with this? It seems to be one of the few remaining pieces for Vulkan 1.3, and now even 1.4 is available. |
I'm also hoping for an update on this. Until this works do we have an alternative for fetching the memory requirements for a buffer by size/usage without already having a buffer? |
This adds support for KHR_maintenance4:
this was already possible with the current code, as the layout defining data gets copied into MVKPipeline when creating.
SPIRV-Cross already handles this.
This took me a bit to implement, as I initially wanted separate code for evaluating the memory requirements. However, this would duplicate a lot of code and it's hard to directly unify it because of static contexts, so I decided to go with this simple approach of just creating an implicit MVKBuffer or MVKImage object. Not sure I like this that much but it does pass CTS. I want to hear what others have to say how this could be done in the MVK codebase.
I think this is fine with Metal, as the buffers in the argument table are initially nullptr afaik. So its valid to not set the buffers if they're not used (which is what my interpretation of this sentence is).
SPIRV-Cross already handles this case as far as I can tell. I used an example Vulkan application where the vertex outputs a vec4 and the fragment accepts a vec2 or vec3, and it is handled correctly in the conversion process. It correctly replaces the float2/float3 with a float4 and then uses vector swizzling to discard the unused values.
Unrelated, but I did some maintenance in the MVKImage and MVKDevice files in code related to this change. Mainly around the getExtent3D, getBytesPerRow, and getBytesPerLayer functions as they were repeating function calls multiple times. getBytesPerLayer would call getExtent3D and getBytesPerRow, which also calls getExtent3D. Additionally, the caller of getBytesPerLayer would also call getExtent3D. My changes drastically reduce the amount of unnecessary function calls made in that area.