Skip to content
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

Merged
merged 4 commits into from
Feb 20, 2025
Merged

Conversation

squidbus
Copy link
Contributor

Continuation of #2332 as it has not been active for a few months now, completing support for the imageView2DOn3DImage portability feature and VK_EXT_image_2d_view_of_3d.

Differences from that PR:

  • Remaining review comments have been addressed.
  • Support for 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.
  • Support for 2D array views has been fixed. Instead of depth, arrayLength needs to be set to the layer count.
  • Minor formatting fixes.

Ran CTS with MVK_CONFIG_USE_MTLHEAP=1 as it is required for this.

Passes dEQP-VK.pipeline.monolithic.image_2d_view_3d_image.*:

Test run totals:
  Passed:        24/48 (50.0%)
  Failed:        0/48 (0.0%)
  Not supported: 24/48 (50.0%)
  Warnings:      0/48 (0.0%)
  Waived:        0/48 (0.0%)

And now supports more tests from dEQP-VK.pipeline.monolithic.render_to_image.*, to demonstrate imageView2DOn3DImage portability feature support:

  • Before:
Test run totals:
  Passed:        840/1245 (67.5%)
  Failed:        0/1245 (0.0%)
  Not supported: 405/1245 (32.5%)
  Warnings:      0/1245 (0.0%)
  Waived:        0/1245 (0.0%)
  • After:
Test run totals:
  Passed:        927/1245 (74.5%)
  Failed:        0/1245 (0.0%)
  Not supported: 318/1245 (25.5%)
  Warnings:      0/1245 (0.0%)
  Waived:        0/1245 (0.0%)

Additionally, I modified the CTS tests for image_2d_view_3d_image to use 2D arrays, and verified they are working as expected.

ncesario-lunarg and others added 2 commits February 10, 2025 00:27
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.
@CLAassistant
Copy link

CLAassistant commented Feb 11, 2025

CLA assistant check
All committers have signed the CLA.

@K0bin
Copy link

K0bin commented Feb 14, 2025

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?

@squidbus
Copy link
Contributor Author

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.

Copy link
Contributor

@billhollings billhollings left a 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.

@squidbus
Copy link
Contributor Author

squidbus commented Feb 18, 2025

Comments have been addressed. Regarding switching MVK_CONFIG_USE_MTLHEAP on by default, I personally have not had any issues with it on M-series GPUs. Related to that, I believe there are some places where heap usage is always disabled (e.g. depth-stencil images) that were disabled back on Intel GPUs, which may be worth re-testing on newer drivers / M-series GPUs.

Copy link
Contributor

@billhollings billhollings left a 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>
@billhollings billhollings merged commit e379740 into KhronosGroup:main Feb 20, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants