-
Notifications
You must be signed in to change notification settings - Fork 448
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
Add VK_EXT_image_2d_view_of_3d support #2442
Conversation
Given a 3D texture that is backed by a placement heap in MoltenVK, the approach taken here is to create a 2D texture that is backed by memory pointing into a 3D texture's memory. While ideal compared to alternative implementation solutions for this extension, this approach is sensitive to how Apple lays out the memory for 3D textures. The solution here uses heapTextureSizeAndAlignWithDescriptor to determine the overall size of a given 3D texture and index into the beginning of each "slice" of the 3D texture. So far this is good enough for storage images in CTS.
So you implement this by aliasing a 3D texture with a 2D one. Does Metal actually guarantee that this works or is it more in the realm of UB that just happens to work? |
As I understand aliasing image memory is valid in Metal but this relies on the underlying memory layout which is not defined in spec. Please refer to the original PR as I did not author the basic approach. |
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 taking up the mantle and getting this done!
LGTM.
Please add VK_EXT_image_2d_view_of_3d
to MoltenVK_Runtime_UserGuide.md
with a note (see other entries) that MVK_CONFIG_USE_MTLHEAP
must be enabled.
Other than that, just a couple of minor nits.
Does this addition now make it time to enable MVK_CONFIG_USE_MTLHEAP
by default? Once this is pulled in, I'll run a full CTS to see if there are any obvious issues with that, but I wanted to get your input from the experience of working with this.
Comments have been addressed. Regarding switching |
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! LGTM now.
Co-authored-by: Chip Davis <cdavis5x@gmail.com>
Continuation of #2332 as it has not been active for a few months now, completing support for the
imageView2DOn3DImage
portability feature andVK_EXT_image_2d_view_of_3d
.Differences from that PR:
sampler2DViewOf3D
has been fixed. It seems aliased 2D texture does not synchronize properly with changes to 3D texture without write usage, which is why only storage tests were passing.depth
,arrayLength
needs to be set to the layer count.Ran CTS with
MVK_CONFIG_USE_MTLHEAP=1
as it is required for this.Passes
dEQP-VK.pipeline.monolithic.image_2d_view_3d_image.*
:And now supports more tests from
dEQP-VK.pipeline.monolithic.render_to_image.*
, to demonstrateimageView2DOn3DImage
portability feature support:Additionally, I modified the CTS tests for
image_2d_view_3d_image
to use 2D arrays, and verified they are working as expected.