Files
metal2vulkan/docs
Anees Iqbal 21a01acb33 rt textures: device images at the consumer's index, their bytes in and out
Device::new_texture is newTextureWithDescriptor: at an index of a live grant: an optimal image
in device-local memory of its own (the first memoryTypeBits type that is DEVICE_LOCAL), usage
the descriptor's plus transfer source and destination, so any texture can be replaced, read
back or blitted as in Metal. Its home layout is GENERAL where it has a storage element,
SHADER_READ_ONLY_OPTIMAL for shader read alone, the attachment layout for render target alone,
GENERAL otherwise; the first move from UNDEFINED goes through core's Work::upload, ahead of
every command buffer committed after the call. The sampled view's components are Metal's
swizzle composed over the format mapping; a depth or stencil format's view takes depth, else
stencil. The storage element exists where the format's emulation is Direct and the device
stores it through a storage image without a format. Size, layer and sample limits come from
vkGetPhysicalDeviceImageFormatProperties2. Admitted emulations: Direct, SwizzledView,
AlphaInRed, RotatedView, XChannel, DepthInCombined, StencilInCombined; any other format is
Gap::TextureFormat.

Texture::gpu_resource_id is the index and the translator's TextureWord, so the guest computes
it. replace_region and get_bytes copy through a staging buffer per call (Shared memory type,
counted in Metrics::bytes_copied); get_bytes submits at once (Work::flush, carried in the
commit before this one and landing with it) and waits (Done::wait). get_bytes's read of the
staging buffer is in readback.rs with its bound, under the readback rule test.

An upload into a 32-bit float depth is Gap::FloatDepthUpload (the planner's ruling): Metal keeps
any float there, Vulkan copies no depth outside [0, 1] without VK_EXT_depth_range_unrestricted,
which the Intel captures lack so the floor cannot take it, and no recorded stream uploads one.
get_bytes still reads such a texture.

The index frees at the last Texture handle's drop (its elements written null, the index
vacated), and grants now track occupancy: Refusal::IndexInUse and Refusal::IndicesInUse. The
Vulkan objects are an Image the uploads hold, freed by the reaper (Free::Texture) once the last
upload that moves or copies it retires. Gauges::textures and Gauges::descriptor_slots count
them, back to zero at drop.

Refusals carry Basis lines; docs/REFUSALS.md regenerated; api_signatures blessed. The README's
"Textures" section and its known gaps say the contract.

Verified:
- m3-max-42550 (msi), this tree: clippy of metal2vulkan-rt plain, --cfg m2v_gpu and --cfg
  m2v_cpu_icd green; rustdoc -D warnings green; nextest 36 of 36; the device tests on lavapipe
  under the validation layer 76 of 76, 0 validation errors.
- m3-max-42601 (780M, radv) and m3-max-42602 (3090), this tree's archive under the validation
  layer: 73 of 73 each (the three source-reading tests skipped off the building machine), 0
  validation errors; every gauge zero at drop.
- Not yet run on Intel: the UHD 630 (Windows) build, m3-max-42551, is running without the GPU
  lease; its run follows.
- `python3 scripts/api-signatures/signatures.py --check` and
  `python3 scripts/refusal-surface/refusal_surface.py --check` clean.
2026-11-17 14:22:16 -08:00
..