rt: an exported block's BlockInfo states no device address, so its make hands none out

API change for the consumer: BlockInfo::gpu_address becomes Option<u64>. It is Some for every
taken, imported and sparse block, as before, and None for an exported block
(Device::new_exported_block). BlockInfo stays Clone + Copy. The only way to an address of an
exported block's memory is now Buffer::gpu_address of a buffer in it, which marks the block and
counts it in Metrics::exported_blocks_addressed as be1b2cfe46 built it. The consumer's reads of
the field fail to build until each one is reviewed. At reims-vgpu 095001ddc6,
`git grep -n -F '.gpu_address' 095001ddc6 -- 'crates/reims-vgpu-vulkan/src/rt_platform/*.rs'
'crates/reims-vgpu/src/pool/rt_blocks.rs' 'crates/reims-vgpu/src/platform/rt.rs' | grep -v
'gpu_address('` gives 39 lines. Some of them are the consumer's own structs; their types were not
checked one by one. The rt BlockInfo reads among them include:
- rt_platform/buffer.rs:793, the known-block map's key;
- pool/rt_blocks.rs:118 and :170;
- rt_platform/diag.rs:716;
- rt_platform/fault.rs:1405;
- platform/rt.rs:149.

Why: be1b2cfe46 counted the public make itself as handing the address out, because the Block
handle derefs to BlockInfo and BlockInfo's pub field stated the address. The consumer calls
new_exported_block for every buffer-form video cache (rt_platform/export.rs:208 at 095001ddc6). So
every such cache's textures stayed in the over-copy class from their make on. With no address in
the info there is nothing to read by accident. A bookkeeping read (a map keyed by address, a
diagnostics line) now fails to build instead of silently turning the bound off. The Option says
"this block has none", as contents: Option<NonNull<u8>> already does.

How:
- Memory::info() gives None where the memory is exported.
- new_exported_block no longer marks its block at the make. Its body was the crate's
  exported_block(), which only the copy form of new_exported_surface called, and the two are now
  the same; the wrapper is gone and the surface calls new_exported_block.
- No product code read the field. The runtime's tests and the validation crate's replay player
  read it only for taken and imported blocks, and now read the Option.

Docs: the field's doc and new_exported_block's doc, the exported_blocks_addressed doc, the
ExportedOvers doc, and the runtime README (Exported blocks, the address contract in Known gaps,
the exported block's rule in Textures over a buffer). The signatures table and docs/REFUSALS.md
(whose site column named exported_block) are regenerated.

Test: an_exported_blocks_texture_is_copied_in_once_a_change. The block's handle states no address
and the make counts 0. Then a new row on the block's own texture: three submissions that each read
it and then write through an address into another buffer copy it in [0, 0, 0], with 0 blocks
addressed. After Buffer::gpu_address on the buffer the texture is over, the count is 1, and three
more such submissions copy [0, 1, 1]. The surface row follows, with the store_through kernel's
state and buffers now made once for both rows.

Verified:
- Without the change: the base 015ece4929 product with this row printing instead of asserting, on
  lavapipe, job m3-max-66854. It printed "addressed at the make 1, rows [0, 1, 1] (addressed 1),
  then after the buffer's address [1, 1, 1] (addressed 1)". So the row fails without the change.
- Compile job m3-max-66851 (tree a9636bbcf8, the same tree as this commit): signatures and
  refusal-surface checks, fmt, clippy (plain, --cfg m2v_gpu, --cfg m2v_cpu_icd), workspace Rustdoc
  -D warnings and scripts/api-docs all exit 0. The runtime suite on lavapipe: 642 tests run, 642
  passed, 3 skipped.
- The m2v_gpu archive is from job m3-max-66852. Each card ran the test, then the runtime suite:
  - RX 550, job m3-max-66873: 644 passed, 3 skipped, peak 0.96 GiB.
  - Iris Xe, job m3-max-66874: 644 passed, 3 skipped, peak 3.72 GiB.
  - RTX 3090, job m3-max-66875: 644 passed (1 slow), 3 skipped, peak 2.44 GiB.
  Each card printed "OpaqueFd block: copies in a submission that writes through an address, the
  block's address not out: [0, 0, 0], then out: [0, 1, 1]; blocks addressed 0, then 1". Lavapipe
  printed the same line in m3-max-66851.
This commit is contained in:
Anees Iqbal committed 2026-11-22 02:29:05 -08:00
1 parent 6bcd2062db
commit 85aa6c8dee
15 files changed
+146 -105

No files matched your search

+4 -4
View File
@@ -340,8 +340,8 @@ Columns:
| `ImportType` | An import whose handle's memory type query offers no type the import takes, so nothing is imported | at the device's limit | `device`: the handle's memory type query and the buffer's or image's memory requirements | 4: `crates/metal2vulkan-runtime/src/d3d11.rs (d3d11_plane)`, `crates/metal2vulkan-runtime/src/import.rs (import_dma_buf)` (+2) | `-` |
| `ImportAlignment` | An import of no bytes, or one whose address or length is not a multiple of `alignment` | at the device's limit | `device`: `minImportedHostPointerAlignment` and the buffer's memory requirements | 4: `crates/metal2vulkan-runtime/src/import.rs (check_len)`, `crates/metal2vulkan-runtime/src/import.rs (check_size)` (+2) | `-` |
| `SparseAddressSpace` | An import over several dma-bufs (`Device::import_dma_bufs`, on Unix) whose sparse buffer would take the device's sparse address space past its... | at the device's limit | `device`: `sparseAddressSpaceSize` | 1: `crates/metal2vulkan-runtime/src/import.rs (reserve)` | `-` |
| `NoExport` | An export of a handle the device does not give (`Device::new_exported_block`) | at the device's limit | `device`: the device's extensions and its external buffer properties | 5: `crates/metal2vulkan-runtime/src/export.rs (exported_block)`, `crates/metal2vulkan-runtime/src/export.rs (handle, 2 sites)` (+2) | `-` |
| `ExportType` | An export of a handle the device gives, but not in the one form an export takes (`Device::new_exported_block`) | at the device's limit | `device`: its extensions and the buffer's memory requirements | 6: `crates/metal2vulkan-runtime/src/export.rs (exported_block)`, `crates/metal2vulkan-runtime/src/import.rs (surface_import)` (+4) | `-` |
| `NoExport` | An export of a handle the device does not give (`Device::new_exported_block`) | at the device's limit | `device`: the device's extensions and its external buffer properties | 5: `crates/metal2vulkan-runtime/src/export.rs (handle, 2 sites)`, `crates/metal2vulkan-runtime/src/export.rs (new_exported_block)` (+2) | `-` |
| `ExportType` | An export of a handle the device gives, but not in the one form an export takes (`Device::new_exported_block`) | at the device's limit | `device`: its extensions and the buffer's memory requirements | 6: `crates/metal2vulkan-runtime/src/export.rs (new_exported_block)`, `crates/metal2vulkan-runtime/src/import.rs (surface_import)` (+4) | `-` |
| `TextureSamples` | A multisample texture of a sample count the device does not make for its format, type and usage | at the device's limit | `device`: the image format query's `sampleCounts` | 1: `crates/metal2vulkan-runtime/src/texture.rs (plan)` | `-` |
## 9. The runtime's `Gap` (`Error::Unsupported(Gap)`)
@@ -636,8 +636,8 @@ Each refusal's sites, with the function that builds it.
- `rt:Limit::ImportType`: `crates/metal2vulkan-runtime/src/d3d11.rs (d3d11_plane)`; `crates/metal2vulkan-runtime/src/import.rs (import_dma_buf)`; `crates/metal2vulkan-runtime/src/import.rs (import_dma_bufs)`; `crates/metal2vulkan-runtime/src/import.rs (import_host_memory)`
- `rt:Limit::ImportAlignment`: `crates/metal2vulkan-runtime/src/import.rs (check_len)`; `crates/metal2vulkan-runtime/src/import.rs (check_size)`; `crates/metal2vulkan-runtime/src/import.rs (import_dma_bufs)`; `crates/metal2vulkan-runtime/src/import.rs (import_host_memory)`
- `rt:Limit::SparseAddressSpace`: `crates/metal2vulkan-runtime/src/import.rs (reserve)`
- `rt:Limit::NoExport`: `crates/metal2vulkan-runtime/src/export.rs (exported_block)`; `crates/metal2vulkan-runtime/src/export.rs (handle, 2 sites)`; `crates/metal2vulkan-runtime/src/surface.rs (dma_buf_in_place)`; `crates/metal2vulkan-runtime/src/surface.rs (new_exported_surface)`
- `rt:Limit::ExportType`: `crates/metal2vulkan-runtime/src/export.rs (exported_block)`; `crates/metal2vulkan-runtime/src/import.rs (surface_import)`; `crates/metal2vulkan-runtime/src/memory.rs (export)`; `crates/metal2vulkan-runtime/src/memory.rs (surface_view)`; `crates/metal2vulkan-runtime/src/surface.rs (dma_buf_in_place)`; `crates/metal2vulkan-runtime/src/surface.rs (new_exported_surface)`
- `rt:Limit::NoExport`: `crates/metal2vulkan-runtime/src/export.rs (handle, 2 sites)`; `crates/metal2vulkan-runtime/src/export.rs (new_exported_block)`; `crates/metal2vulkan-runtime/src/surface.rs (dma_buf_in_place)`; `crates/metal2vulkan-runtime/src/surface.rs (new_exported_surface)`
- `rt:Limit::ExportType`: `crates/metal2vulkan-runtime/src/export.rs (new_exported_block)`; `crates/metal2vulkan-runtime/src/import.rs (surface_import)`; `crates/metal2vulkan-runtime/src/memory.rs (export)`; `crates/metal2vulkan-runtime/src/memory.rs (surface_view)`; `crates/metal2vulkan-runtime/src/surface.rs (dma_buf_in_place)`; `crates/metal2vulkan-runtime/src/surface.rs (new_exported_surface)`
- `rt:Limit::TextureSamples`: `crates/metal2vulkan-runtime/src/texture.rs (plan)`
- `rt:Gap::IndirectCommandBuffers`: `crates/metal2vulkan-runtime/src/indirect.rs (new_indirect_command_buffer)`; `crates/metal2vulkan-runtime/src/indirect.rs (shape)`; `crates/metal2vulkan-runtime/src/pipeline.rs (compute_pipeline_state)`; `crates/metal2vulkan-runtime/src/render_encoder.rs (draw)`; `crates/metal2vulkan-runtime/src/render_encoder.rs (execution_part)`
- `rt:Gap::KernelInput`: `crates/metal2vulkan-runtime/src/pipeline.rs (gap)`