Runtime: take resource option bit 20 as Metal takes it

Bit 20 (0x100000) is an option no Metal header names, of unstated meaning,
which programs pass with their buffers' options (0x100010 for a Managed
no-copy buffer). ResourceOptions::from_raw refused it as undefined, so such
a buffer could not be made at all.

Measured with probes/resource_option_bit20.m on an M3 Max (macOS 27.0.1)
and a Radeon Pro 5300M (macOS 26.7.1), plain and under API validation:
buffers of a length, of bytes and over the caller's pages are made with it,
of every storage mode, and report their options without it; so do a heap
and a heap's buffer (API validation stops the heap's buffer); a texture
descriptor with it ends Metal's process.

So from_raw takes it (ResourceOptions::BIT_20), every buffer and heap maker
drops it (own_memory_options, no_copy_options, take_options, a heap's
new_buffer), and texture_options refuses it as it refuses bit 24 there.
Nothing reads it. docs/API.md states both halves; api_signatures blessed.

Tests: values::bit_20_is_taken_and_dropped_apart, and the device test
option_bit_20 (buffers, no-copy, heaps and their buffers report without
it; a texture descriptor with it is Invalid). Not yet run.
This commit is contained in:
Anees Iqbal committed 2026-11-11 11:22:45 -08:00
1 parent c1ccb0b48d
commit d3ab77f844
10 files changed
+192 -20

No files matched your search

+14
View File
@@ -497,6 +497,20 @@ first submission acquires from `VK_QUEUE_FAMILY_FOREIGN_EXT`; a linear image ove
runtime's own memory starts `VK_IMAGE_LAYOUT_PREINITIALIZED`, and its move from there keeps its
bytes. FAST-PATHS.md's costs and known gaps state what this costs and differs from Metal in.
`MTLResourceOptions` bit 20 (0x100000, `ResourceOptions::BIT_20`) is an option no Metal header
names, whose meaning Metal does not state; programs pass it with a buffer's options (0x100010 for
a `Managed` no-copy buffer). `ResourceOptions::from_raw` takes it, and nothing in the runtime
reads it. Measured on an M3 Max under macOS 27.0.1 and an AMD Radeon Pro 5300M under macOS 26.7.1,
plain and under API validation (`crates/metal2vulkan-conformance/probes/resource_option_bit20.m`),
the runtime following both halves:
- a buffer of a length, of bytes or over the caller's pages (`newBufferWithBytesNoCopy:`), of
every storage mode, is made with it and reports its options without it; so are a heap and a
heap's buffer (the M3 Max; Metal's API validation stops the heap's buffer, "unknown bits
0x100000"). The runtime makes each as without it;
- a texture descriptor with it ends Metal's process (its suballocator asserts, "Different
MTLResourceOptions used for the same heap index"): the runtime refuses it (`Invalid`,
`Problem::UndefinedValue`), as it refuses bit 24 there.
## 2. A library
`Library::parse` takes a metallib, a bitcode wrapper or a raw AIR module; `Library::from_air`