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

[ll] Metal heaps and offsets/aliasing #1384

Open
JohnColanduoni opened this issue Jul 19, 2017 · 1 comment
Open

[ll] Metal heaps and offsets/aliasing #1384

JohnColanduoni opened this issue Jul 19, 2017 · 1 comment

Comments

@JohnColanduoni
Copy link
Contributor

Metal heaps do now allow us to specify offsets when performing allocations. This presents a few (related) problems:

  1. Aliasing is allowed on heaps, but only by specifying that an existing resource may now be freely aliased by future allocations. This limits our ability to translate aliasing in the user's (emulated) view of the memory space to aliasing on the device.
  2. Heaps require the user to query how much memory is available at a particular alignment, which may vary depending on how the driver decided to place the existing resources. There is no reason that this would match up with how the user has laid out memory from their perspective, and could result in an allocation failing exogenously.
  3. The complex aliasing interactions allowed in Vulkan (e.g. when writing to one host-accessible alias and reading the same data from another) have no native equivalent. Modifying a resource that is aliased with another leads to the second's content becoming undefined.

A possibility for dealing with (1) and (2) would be to simply fall back on allocation of resources off of the heap when the user's allocation pattern cannot be mapped properly; the user would simply be given a pass if they would have technically invoked undefined behavior by incompatible access of aliased resources.

I don't think there is any way to work around (3). In theory we could simulate such aliasing by allocating a buffer and making texture views of range within it, but such views have lots of restrictions in the API (2D textures only, alignment, etc.) and it would be difficult to detect when we needed to do that without inducing a lot of overhead.

For the purposes of #1226, IIRC Vulkan implementations are allowed to advertise that they do not support linear tiling for any formats, which would prevent a user from attempting to invoke (3) without violating the API.

@kvark
Copy link
Member

kvark commented Jul 20, 2017

This looks like one of the cases (in a series) where Metal puts poles in our wheels for being too high level.

It's tempting to just drop MTLHeap backing completely. Given no reasonable way to support resource aliasing on Metal, we should get a capability flag saying whether aliasing is supported in general. Given no aliasing, we can just ignore the user offsets and allocate wherever Metal wants on the heap.

@kvark kvark added this to the Vulkan Portability MVP milestone Sep 15, 2017
@msiglreith msiglreith added api: pre-ll old abstraction layer (pre-ll branch) api: ll and removed api: pre-ll old abstraction layer (pre-ll branch) labels Oct 28, 2017
@kvark kvark removed the api: hal label Jun 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants