8e39e812e580e62efc88be1ff8ca824e11c81fbb
322
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
8e39e812e5 |
rt: a blit encoder copies between a buffer and a texture, one copy command an image of the region
copy_from_buffer (copyFromBuffer:sourceOffset:sourceBytesPerRow:sourceBytesPerImage:sourceSize: toTexture:destinationSlice:destinationLevel:destinationOrigin:) and copy_from_texture_to_buffer (copyFromTexture:sourceSlice:sourceLevel:sourceOrigin:sourceSize:toBuffer:destinationOffset: destinationBytesPerRow:destinationBytesPerImage:) record vkCmdCopyBufferToImage or vkCmdCopyImageToBuffer against the buffer's own range of its block, nothing staged, between the two barriers a texture copy records. One region per image of the region, each at its own offset (offset + image x bytesPerImage), so an image stride of no whole number of rows copies too; bufferRowLength is bytesPerRow in texels, 0 for one row. The second barrier also makes a buffer write visible to every later command, and a write into a Shared buffer marks the segment, whose end barrier reaches the host. BufferLayout carries the offset and the two strides. Refusals follow probe blit_buffer_copy_rules.m on an Apple M3 Max, macOS 27.0.1 (jobs m3-max-43541, m3-max-43545): Metal's validation stops an offset or a row stride of no whole texels, rows or images closer than the region's and a region past the buffer's end (Refusal::BufferCopyLayout); it takes an R8Unorm offset of 2, a row stride of 0 for one row, image strides of no whole rows, and bytesPerImage on 2D and 1D-array copies. Where Metal takes bytes a copy command cannot address (a depth or stencil offset not a multiple of 4, as a 16-bit depth at 2; a compressed offset or row stride of no whole blocks, as BC1 rows 20 apart, which Metal takes) it is Gap::BufferCopyAlignment. TextureBytes and FloatDepthUpload now name the blit copies too. Tests: pure checks of the regions (padded rows, one row, a 3D region's images at their own offsets, a 1D array slice, BC1 blocks) and of each refusal and gap; a device test copying into a mipmap level, out of an array slice and a 3D region at padded strides, into a 1D array slice and BC1 blocks, each result held to plain Metal's FNV-1a 64 (probe blit_copy_layouts.m, job m3-max-43555, plain and under the validation layer), and one copy into a Shared buffer alone at one submission, three barriers, no byte of the runtime's own. |
||
|
|
2105fa114e |
rt: heap textures, bound at the consumer's offsets in a heap's range of a Private block
A heap is a range of a Private block the consumer took at the heap's creation (HeapRange: block, offset, length), as the plan decided: one Private range per heap, resources at the offsets the guest's first-fit allocator picks. Device::heap_texture_size_and_align answers heapTextureSizeAndAlignWithDescriptor: with this device's image requirements (vkGetDeviceImageMemoryRequirements of the same create info new_texture uses), never Metal's: the size rounded up to and the alignment raised to bufferImageGranularity, so a buffer placed by the same answers never shares a granularity page with the image. Replay showed why: one vendor's image for a recorded heap texture is larger than the recording device's (7.47 MB in a 5.9 MB heap), so the guest places by this answer. Device::new_heap_texture binds the image at the heap offset: no allocation and no texture block, bytes not zeroed (as Metal's heap textures), aliasing allowed. A placement past the heap's end, an offset in the block off the image's alignment, or a heap range past its block is Refusal::HeapTexturePlace at creation; the image is never bound outside its heap. A Shared block, or an image that requires an allocation of its own or does not take the Private type, is Gap::HeapTexture (every optimal image measured takes the Private type). The image holds the block, so a released block returns to the pool only once its heap textures' images are gone. new_texture's checks move into Device::prepare, shared with the size query, and the image's create info into image_info. README: heap textures leave the not-built line; REFUSALS.md and the signatures table updated. Test: tests::heap::every_device_places_heap_textures_at_the_consumer_s_offsets (answer equals the image's own size rounded to granularity; first-fit placements allocate nothing and keep their own bytes; an alias; refusals for past the end, off the alignment, a heap past its block, and a Shared block). |
||
|
|
8fc4064da5 |
rt: Managed textures, an image and the consumer's named bytes, uploaded by a device copy
A Managed texture is a Private image plus a range the consumer names, on every device. Device::new_managed_texture takes a Shared buffer and, per level and slice, a BytesPlace (offset, bytes per row, bytes per image) laid out as the consumer chooses; rt never picks the layout. Places that a buffer-to-image copy cannot read in place (rows not whole texel blocks apart, images not whole rows apart, a first byte off the block's bytes or off 4 for depth/stencil, a level leaving the buffer, a wrong count, a buffer the host does not reach) are refused with Refusal::ManagedTextureBytes. Texture::upload_region(region, level, slice) records one vkCmdCopyBufferToImage from the named place into the image in the upload, ahead of every command buffer committed after the call on every queue, as did_modify_range copies a Managed buffer: no CPU copy, no staging. On such a texture replace_region writes the named bytes (Metal's CPU copy) and uploads them; get_bytes reads the named bytes with no submission. The texture copy's record() now takes a buffer and region, so staging and named copies share it. README, the API.md accepted difference (the copy reads the bytes when the GPU reaches it), REFUSALS.md and the signatures table updated. Test: tests::managed::every_device_copies_a_managed_texture_s_named_regions (whole-level uploads, a sub-region upload with an unmarked change outside it, get_bytes reading the named bytes, replace_region writing them, six refusals). |
||
|
|
60fe8aacaf |
rt: TextureCopyMismatch quotes Metal's messages as code
Rustdoc read "[destinationTexture sampleCount](1)" as a link and failed -D warnings (job m3-max-43474). |
||
|
|
f10ed213a0 |
rt: the blit device test holds each copy's expected bytes to plain Metal's
Each expected result's FNV-1a 64 is the hash probe blit_copy_layouts.m printed on an Apple M3 Max, macOS 27.0.1 (job m3-max-43464, at 31f5a93c4b), plain and under the validation layer alike: a level into an array slice, a cube face into a 3D slice, a 3D slice into 2D, slice to slice and BC1 blocks. The format-pair probe's sample-count case ran too (job m3-max-43465): Metal's validation stops four samples into one with "[sourceTexture sampleCount](4) must equal [destinationTexture sampleCount](1)", which Refusal::TextureCopyMismatch's basis now cites. |
||
|
|
42d274f91a |
rt: a blit texture copy takes one pixel format and one sample count, as Metal's validation does
Metal's validation layer stops copyFromTexture between any two pixel formats (Apple M3 Max, macOS 27.0.1, probe blit_copy_format_pairs.m, job m3-max-43433): RGBA8Unorm into sRGB, Uint, R32Uint and BGRA8Unorm, R32Uint into R32Float, Depth32Float into R32Float and BC1 into RG32Uint all fail with "[sourceTexture pixelFormat] must equal [destinationTexture pixelFormat]"; the same format is taken. So Refusal::TextureCopyMismatch is now every pair of two formats (basis metal-measured, was metal-takes), and the rules for copying between formats of one unit's bytes are gone: no alpha special case, no block, aspect or unit comparison. What stays a gap: a multisample texture, depth and stencil both, a 1D texture with another type, one subresource into itself, and, new, one pixel format held in two Vulkan formats by the textures' usages, whose texels may sit in two layouts. The device test's array is RGBA8Unorm now (the copy into it was RGBA8Unorm into R32Uint), and the slice-past-the-array check copies into a texture of its format: on 7f2a3c5cb1 it met the format check first on every device (legs m3-max-43406, 43407, 43408: RX 550, 780M HawkPoint, 3090, XTX, 2080, 780M Phoenix, lavapipe; every assertion before it passed, validation errors 0). The probes add the sample-count case and make the layout probe's array RGBA8Unorm; their runs follow. |
||
|
|
247ed69da0 |
rt: a blit encoder copies a region of one texture into another, one vkCmdCopyImage between two barriers
CommandBuffer::blit_command_encoder (blitCommandEncoder) and BlitCommandEncoder::copy_from_texture (copyFromTexture:sourceSlice:sourceLevel:sourceOrigin:sourceSize:toTexture:destinationSlice: destinationLevel:destinationOrigin:, the only texture-to-texture selector the compute recordings use: 2,736 copies in one, 3 in the other, none multisample, compressed or within one texture). The copy is recorded at once into the current segment: no staging and no byte beyond the region. The first barrier moves each texture's level and slice from home to its transfer layout and carries the global barrier (every earlier write visible to every later command), so it pays what an encoder owed and the hazard sets start again; the second moves them home with the copy's writes visible to every later command. A command buffer of one copy is one submission and three barriers (the segment's end among them), and Metrics::bytes_copied does not move. Bytes move as they are between formats whose units have the same bytes; a compressed region is whole blocks or reaches the level's edge on both sides; a 3D image copies to and from a 2D slice. Refusal::TextureCopyMismatch for units of different bytes or different sample counts (Metal stores its GPU's own layout there); Gap::TextureCopy for what one vkCmdCopyImage in the floor does not make (multisample, depth and stencil both, depth or stencil with another format, compressed with another block extent, A8_UNORM with another format, 1D with another type, one level and slice into itself). The texture's region check is shared with replace_region and get_bytes (texture::place). Tests: tests::blit (the rules, no device) and on every device of the cfg's kind tests::blit::on_device::every_device_copies_between_textures (bytes of a level into an array slice of another format, a cube face into a 3D image, a 3D image into a 2D texture, one array slice into another, BC1 blocks where made; 1 submission, 3 barriers, 0 bytes copied, 1 pass for one copy; an owed barrier paid by the copy: 3 barriers, 4 without the fold). |
||
|
|
4732ce6cd7 |
rt: a buffer bound off its argument's alignment runs at the address rounded down to it
The binder (ComputeCommandEncoder::fill_parameters) pushes each bound buffer's address, its gpuAddress plus the bind offset, rounded down to a multiple of the alignment the kernel takes it to have (FieldValue::BufferAddress's mask, from RuntimeFact::AddressAlignment: the argument's air.arg_type_align_size, at most 16), for every slot. Refusal::MisalignedBuffer and the dispatch it skipped are deleted, so fill_parameters cannot fail. Why: Metal's API validation refuses such a bind offset, and without validation an Apple M3 Max (macOS 27.0.1) reaches each element at its address rounded down to the smaller of the element's alignment and 4, for loads, stores and pointers stored in a buffer alike. The probe that measured it is committed as crates/metal2vulkan-conformance/probes/misaligned_buffer_binds.m. The two agree at alignments 2 and 4 and for 8- and 16-byte arguments bound 1 to 3 bytes off a multiple of 4; an 8- or 16-byte argument bound at a multiple of 4 that is not a multiple of its alignment is reached at the rounded address where the M3 reaches it exactly there, a bind Metal's validation rejects. docs/API.md section 10 lists that as an accepted difference. Tests: rt's every_device_rounds_a_bound_address_down_to_its_alignment steps a buffer bound off each alignment (2, 4, 8 and 16; 15 binds) through the step kernel with the mask set, and checks the words stepped start at the rounded address; at the 8- and 16-byte binds 4, 8 or 12 bytes off, an unrounded bind would step other words on any device. an_argument_bound_off_its_alignment_runs_at_the_address_rounded_down binds vector_word_phases' vwp_words 1 and 3 bytes and vwp_vec16 4 and 12 bytes off their alignment and expects Metal's words for the rounded binds. They replace an_argument_bound_off_its_alignment_is_refused and a_misaligned_dispatch_refused_leaves_its_encoder_and_command_buffer_usable. Docs: REFUSALS.md and api_signatures.tsv regenerated (the variant's row goes), the rt README's compute encoders say what the binder pushes, the translator's RuntimeFact::AddressAlignment doc and the mechanism comment say the binder rounds. |
||
|
|
ee7c4a5173 |
rt: Managed buffers, a device copy where Shared memory is not device-local
newBufferWithLength:options: and newBufferWithBytes:length:options: with Managed storage over a range of a Shared block the consumer names: Device::new_managed_buffer(block, offset, length, copied). The device's memory-type query picks the form. Where the Shared type is device-local the buffer is its bytes, as a Shared buffer is, and didModifyRange does nothing. Elsewhere shaders reach a device copy in Private memory, as Metal keeps one on a Mac with a discrete GPU. The device copy is a place in a copy block: a Private block of the pool, or a dedicated one past BLOCK_LEN, in a set apart from the texture blocks, so no buffer lies beside an optimal image. Its first `copied` bytes are copied from the consumer's and the rest zero-filled, in the upload. Buffer::did_modify_range(start, length) marks a range changed: the upload, which goes ahead of every command buffer committed after the call on every queue, copies it from the consumer's bytes into the device copy as it is submitted, one vkCmdCopyBuffer per buffer with its ranges merged where they overlap or touch, after a counted barrier that puts the upload's earlier fills first. No CPU copy, no staging, nothing sized by the call. Each change is one of the upload's 4,096 calls, so changes past them submit it and wait. The copy reads the bytes when the GPU reaches it, which docs/API.md records as an accepted difference. A command buffer keeps each device copy it uses, and an upload each one it copies into, until it retires; the copy's place is freed then. An indirect dispatch reads its arguments from the device copy. Places take a core and give a block back once it empties where it is dedicated or another pooled block of the set is empty; Core::take_memory chooses a pooled or dedicated block for both take_block and the places. Refusals: ManagedBlockNotShared (a Private block) and ModifiedRange (a range past the buffer), both ours; docs/REFUSALS.md and the signatures table regenerated. Tests: changed ranges merge where they overlap or touch; on every device, in the form its query picks, the device copy holds the first bytes and zeros, a changed range reaches it at the next submission and an unmarked change does not, changes past the upload's calls submit it (none without a copy), both refusals, and every gauge zero after teardown. |
||
|
|
bf3d3c1ebb |
rt: GPU times placed by calibrated timestamps on one host clock, the anchor deleted
VK_EXT_calibrated_timestamps joins the floor's device extensions under that one name, and the floor requires the device to calibrate its own clock (VK_TIME_DOMAIN_DEVICE_EXT) with the host clock's domain, HOST_DOMAIN: CLOCK_MONOTONIC on Linux and other Unix systems, CLOCK_MONOTONIC_RAW on macOS, the performance counter on Windows. A device that does not is below the floor (floor::Missing::TimeDomain). host_time() reads that same clock, so a command buffer's GPU times and its kernel times are on one clock with no bridge; on macOS it counts while the system sleeps, where Metal's mach_absolute_time does not, which host_time()'s doc and the README state. The completion thread calibrates once as the device starts, and again at a completion once 100 ms (CALIBRATION_PERIOD) have passed since the last: one vkGetCalibratedTimestampsEXT call of the two domains, no deviation loop, never per command buffer. Each completed command buffer's two timestamps are placed by the last calibration, the tick difference taken signed within the valid bits. The anchor estimate, which took the host time a completion was seen as an end and moved later only by the least lateness of 64 passes, is deleted with its rule. Tests: the times test now holds each command buffer's GPU start and end between host_time() read before its commit and the host time its completed handler reads; a new test holds that the device calibrated at start, not while idle for 150 ms, and once at the first completion of a 32-buffer burst plus at most one per 100 ms it ran; a floor test names a missing host or device time domain. No conformance or harness check compares rt's GPU times with Metal's in absolute terms (conformance relates the old runtime's times; the harness compares durations and spans). |
||
|
|
f34c4a22d2 |
rt: every memory allocation counts against the device's maxMemoryAllocationCount, refused before the driver past it
rt never counted its vkAllocateMemory calls, so it could pass the device's
maxMemoryAllocationCount, which VUID-vkAllocateMemory-maxMemoryAllocationCount-04101
forbids: blocks, each texture's own memory, each staging buffer of replace_region
and get_bytes, the parameter ring's blocks and the zero source.
Every allocation now goes through memory::allocate, the one vkAllocateMemory call.
The live count is the blocks gauge, which already counted exactly these
allocations: allocate raises it only while it is below the device's count, else
returns Limit::MemoryAllocations { max } without calling the driver, and gives the
count back where the driver fails. Each site's own rise of the gauge after its
allocation is gone; the texture's and the staging buffer's failure paths after the
allocation now lower it as they free it.
Device::new is Device::open with the device's limits as queried; a test opens a
device with maxMemoryAllocationCount answered as 8. With the zero source and the
two ready blocks live, five 4x4 textures are made and the sixth is refused with the
typed limit, the gauges unchanged; a replace_region then is refused the same way
for its staging buffer; once a texture is dropped and its memory freed, a texture
is made again; every gauge reads zero after teardown.
The Err docs of Device::new, take_block, new_texture, replace_region (get_bytes
takes its list), set_bytes and the dispatches name the limit, and the runtime's
README states what counts and the limits measured: about 4.29 billion on RADV,
NVIDIA's Linux driver and ANV, 8,401,685 on Intel's Windows driver for the UHD
Graphics 630, 4,096 at Vulkan's minimum. docs/REFUSALS.md and the API signature
table are regenerated for the new Limit variant.
|
||
|
|
d48c2bfc78 |
rt: the longest buffer is 2 GiB
MAX_BUFFER_LENGTH drops from 4 GiB to 2 GiB, so every byte of a buffer lies within 2^31 bytes of each bind address in it, which lets the translator read a buffer argument's 32-bit offsets as signed for every slot. A buffer of 2 GiB is made; one a byte longer is refused with BufferTooLong. The consumer states Metal's maxBufferLength no larger than this. The device test is renamed to its 2 GiB length (a 2 GiB Private block, made where a block allows it, then 2 GiB and a byte refused, gauges zero at drop), and the interpreter test now loads and stores up to the last word below 2 GiB of the bind address and checks that each lands at its own word. REFUSALS.md and api_signatures.tsv regenerated. |
||
|
|
661b97c6e8 |
rt: a buffer longer than 4 GiB is refused
A shader reaches a buffer argument's bytes by 32-bit offsets from its bind address: every access form adds the u32 Metal offset to the slot's 64-bit address, so an access 4 GiB or more past the bind offset lands 4 GiB below, inside the buffer, with no fault. Device::new_buffer now refuses a length past MAX_BUFFER_LENGTH (4 GiB, one constant) with Refusal::BufferTooLong, before the block's range is looked at; heap buffers and a consumer's no-copy placements go through the same call. Metal answers nil past a device's maxBufferLength, which the consumer states no larger than this (the README's contract line). Tests: rt's every-device memory test refuses 4 GiB and a byte and u64::MAX on a pooled block, typed; a test of its own makes a buffer of exactly 4 GiB in a Private block of that length where the device has one (skipping visibly where its largest block or memory is smaller), refuses one a byte longer, and ends with every gauge at zero. The translator's interpreter test loads and stores up to the last word below 4 GiB through a Whole window under the identity domains, each landing at its own word. REFUSALS.md and api_signatures.tsv regenerated. |
||
|
|
643271b319 |
rt: refuse a dispatch whose buffer address breaks its argument's alignment
A kernel states RuntimeFact::AddressAlignment for each buffer argument with an alignment of 2
or more, and reaches one of 4 or more from its address as it is. Metal's API validation refuses
such a bind offset (measured on an Apple M3 Max by the conformance crate's
vector_access_placement probe: "must be a multiple of 4 but was set to 2" for a uint *
argument, "of 16 but was set to 4" for a float4 *). The pipeline records each such slot's mask
with its BufferAddress field, and fill_parameters tests address & mask where it forms the pushed
address, refusing the dispatch with Refusal::MisalignedBuffer { index, address, align } before
any work is recorded.
The test an_argument_bound_off_its_alignment_is_refused binds a float4 argument at offset 4
(refused, naming index 0, align 16 and the address) and 16 (runs), and a uint argument at 2
(refused, align 4) and 4 (runs). docs/REFUSALS.md is regenerated and the api_signatures table
gains the variant.
|
||
|
|
37f0bf51f8 |
rt encoder arms: textures, sampler states and constexpr samplers by pushed index
ComputeCommandEncoder::set_texture (128 slots, Refusal::TextureArgumentIndex past them) and set_sampler_state (16 slots, Refusal::SamplerArgumentIndex) bind as Metal's calls do, and use_resource takes a texture as it takes a buffer. A dispatch pushes, for each texture and sampler slot its kernel reads, the bound object's gpuResourceID (0 for none), whose index names its elements of set 1; for a texture slot an integer write saturates through, the channel widths of the bound texture's format (metal::format::integer_channels_word, now public); and for each constexpr sampler, the index the consumer gave it. Nothing is written into set 1 at bind or dispatch time, and every texture stays in its home layout. A texture's sample and read are reads in the hazard sets, a texture one resource, with a hazard id from core's ids. Each command buffer binds set 1 (vkCmdBindDescriptorSets, firstSet 1) once, before its first pipeline; without it the lavapipe run reported VUID-vkCmdDispatch-None-08600. The command buffer keeps each texture and sampler state an encoder binds or declares, in command.rs's Gpu next to its blocks and pipelines, dropped with them at retire, so their elements stay theirs while work may read them. Device::new_compute_pipeline_state takes sampler_ids: the samplers the kernel numbers, in Metal's order (NumberedSampler: each constexpr sampler, then one for a texture read and one for a texture write), answered with an index each from the consumer's sampler grants (Refusal::SamplerIds for another count). A constexpr sampler takes, before the call returns, the device sampler of each use the kernel has (CombinedSampler::constexpr_sampler, canonical, shared by create info with sampler states') at its index of the three sampler arrays; states that number one constexpr sampler at one index share it, another sampler there is Refusal::IndexInUse, and the last of them writes the defaults back and frees the index. Set 1's layout is checked against the translator's (IdentityArray bindings). A kernel whose texture or sampler the translator would take from the bound object rather than its resource ID stays Gap::KernelInput. The harness grants its own texture and sampler indices on the new runtime and numbers constexpr samplers by their words, so constexpr_sampling runs on it. README: the encoder's texture and sampler arms, the numbering paragraph, the KernelInput gap. REFUSALS.md regenerated; api_signatures and api_surface carry integer_channels_word and the new refusals. Verified: - m3-max-42749 (msi), this tree: clippy of metal2vulkan-rt plain, --cfg m2v_gpu and --cfg m2v_cpu_icd green; rustdoc -D warnings green; nextest 37 of 37; the device tests on lavapipe under the validation layer 79 of 79, 0 validation errors (tests::sampling: sample_down through a runtime sampler, then sample_up through a constexpr sampler, against the linear filter's answers; the constexpr index shared, refused to a sampler state and freed with the last state). - The same change on the sampler landing before development's region commits (tree ed71d2de2e): m3-max-42714 (780M, radv) and m3-max-42716 (3090), its archive under the validation layer, 76 of 76 each (the three source-reading tests skipped off the building machine), 0 validation errors, every gauge zero at drop; m3-max-42735 (UHD 630, Windows), its cross-built archive, 79 of 79, every gauge zero at drop. - m3-max-42638 (msi), tree ed71d2de2e: clippy of metal2vulkan-harness plain and --cfg m2v_gpu green; the api_signatures and api_surface tests green. |
||
|
|
4f8a7db4c8 |
rt sampler states: device samplers shared by create info at the consumer's index
Device::new_sampler_state is newSamplerStateWithDescriptor: at an index of a live Sampler grant. Each state takes the device sampler of each use it can be used in, from the translator's metal::sampler::vk_sampler with its create info chained by ash_interop::sampler_create_info: the plain one always, the comparison one where its compare function is not Never, and the integer-texture one (nearest, the integer border colour). It writes them into set 1's three sampler arrays at its index before the call returns; the comparison array keeps its default where the state has no compare function. Device samplers are shared by create info across uses and states (SamplerTable), and a border colour no address mode reads is no part of a create info (canonical), so a state whose integer-texture use reads as a plain sampler shares it: a nearest state takes one sampler, and a linear compare state two more beside it. The table holds at most maxSamplerAllocationCount minus the arrays' two defaults; past it a state is Limit::DeviceSamplers. Gauges::samplers and Gauges::device_samplers count them. When the last handle goes, the state's elements read the defaults again, its index is free, and each device sampler no other state holds goes to the reaper (Free::Sampler). A cubic filter is Gap::CubicSampler. samplerAnisotropy joins the floor's features (every lab device and capture has it). SamplerState::gpu_resource_id is the index and the translator's SamplerWord. IndexInUse and IndicesInUse now name sampler states too. README: a "Sampler states" section and the floor's feature row. REFUSALS.md regenerated; api_signatures blessed. Verified: - m3-max-42632 (msi), this tree: clippy of metal2vulkan-rt plain, --cfg m2v_gpu and --cfg m2v_cpu_icd green; rustdoc -D warnings green; nextest 37 of 37; the device tests on lavapipe under the validation layer 78 of 78, 0 validation errors. - m3-max-42611 (780M, radv) and m3-max-42612 (3090), the same sampler change on the textures tip before the rebase onto development, its archive under the validation layer: 75 of 75 each, 0 validation errors; every gauge zero at drop. - `python3 scripts/api-signatures/signatures.py --check` and `python3 scripts/refusal-surface/refusal_surface.py --check` clean. |
||
|
|
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. |
||
|
|
1b97a620c8 |
rt: set 1 and index grants
Every pipeline of the new runtime takes set 1, one descriptor set the device makes at creation: 65,536 sampled textures (binding 0), 4,096 storage-capable textures (binding 1) and 4,000 samplers of each use, plain, depth comparison and integer texture (bindings 2, 3 and 4), each partially bound, updated after bind and while unused elements are pending, seen by every stage. Set 0 is empty. The pipeline layout is made once from it, in Device::new, and every pipeline and dispatch uses that layout. Every element no object owns is defined: a texture element is a null descriptor (VK_EXT_robustness2 nullDescriptor, which joins the floor; the robust buffer and image access beside it stay off), and a sampler element is its array's default sampler, nearest and clamped to the edge, the comparison array's comparing with NEVER. The device writes every element at creation and holds the two default VkSamplers (Gauges::device_samplers). The translator is told of VK_EXT_robustness2, so its profile has nullDescriptor. Device::grant_indices(class, first, count) grants the consumer the range it names, so the IDs it picks reproduce in replay: storage-capable textures 1 to 4,095, other textures 4,096 to 65,535, samplers 1 to 3,999, 0 nil and never granted (IndexClass, IndexGrant). Limit::IndexRange, Refusal::IndicesGranted and Refusal::IndicesNotGranted, with Basis lines; docs/REFUSALS.md regenerated. The floor's sampler limits are now three arrays' (12,000 samplers per stage and set, 81,632 update-after-bind descriptors in all pools). README: "Set 1 and index grants", and the floor's extension, feature and limit rows. Device::new output is unchanged: no translator source changes. Verified: - m3-max-42273 (msi): clippy -p metal2vulkan-rt --all-targets --all-features, plain, --cfg m2v_gpu and --cfg m2v_cpu_icd, green; rustdoc -D warnings green; rt tests 33/33; every device test on lavapipe with the Khronos validation layer, 0 validation errors; making a second set 1 takes 106 ms there. refusal_surface.py --check clean. - m3-max-42305 (Radeon 780M, RADV, gem10) and m3-max-42306 (RTX 3090, um870), validation layer on: every device test passes with 0 validation errors, gauges zero at drop; a second set 1 takes 15.1 ms on the 780M and 4.6 ms on the 3090. The three tests that read the source tree fail on those nodes only because the carried archive names msi's paths; they pass on msi. |
||
|
|
445b720f78 |
identity: texture slots sampled through runtime sampler slots from set 1's sampler arrays
Under the identity domains a kernel samples a texture slot through a runtime sampler slot. The
texture is its class's set-1 element at the index of its pushed gpuResourceID, as a read's is.
The sampler is the element of a set-1 sampler array at the index of the sampler slot's pushed
gpuResourceID (SlotGuestBase of the sampler slot), joined to the texture by OpSampledImage. The
array is picked by the use: binding 2 for a plain sample, 3 for a depth comparison, 4 for a
texture of an integer format; 4,000 SAMPLER descriptors each, PARTIALLY_BOUND |
UPDATE_AFTER_BIND | UPDATE_UNUSED_WHILE_PENDING, every stage, the same set 1 for every pipeline.
The sampler's word (pixel coordinates, a nearest pixel sampler) is read from the ID's high word,
so no specialization constant and no SamplerReduction, SamplerCoordinates, CubicSampler or
ConstantLanes fact remains; every precision note is static. An integer write to a storage slot
without a format saturates to the channel widths the consumer pushes
(PushField::TextureIntegerChannels, a u32), with no fact.
Still refused as Unsupported{IdentityDomains}: constexpr samplers (next change: a pushed index),
an argument buffer's sampler, arrays of samplers, bicubic and anisotropy emulation, a slot's
minimum level.
Translation output changes only under the identity domains (Device::from_queries). Device::new
output is unchanged: golden_hashes_match_the_table passes at this tip (job m3-max-42189), with no
"changed under an unchanged key" and no "profile changed:" line.
For the runtime's side (the planner's three facts):
a. The runtime must dedupe device samplers by create info across the three arrays' uses.
Exhausting maxSamplerAllocationCount (4,000 on the 2080, 3090 and UHD 630; 32,768 on
lavapipe; 65,536 on the others) must be a typed refusal, with a fill-past-capacity test.
b. The update-after-bind limits for 65,536 sampled images, 4,096 storage images and 12,000
samplers hold on all nine profiles (the smallest is lavapipe's 1,015,808); the floor must
check them by query.
c. The count of cubic sampler descriptors is asked of the replay lane; if any exist it goes back
to the planner before step 5 closes.
SEMANTICS_VERSION 2161: identity-domain modules of sampling kernels and integer writes change.
Verified:
- m3-max-42094 (msi), this change on
|
||
|
|
fdc3fd3907 |
rt: threadgroups of partial SIMD groups run the kernel's emulated module, lowered on the reaper
A kernel whose tier runs each SIMD group as one subgroup (a pinned subgroup of 32, the device's own 32, or half of a 64-lane subgroup) runs only threadgroups of whole groups of that width. Such a state now has its emulated-SIMD-group variant (LoweringInputs::emulated_simdgroups), which the reaper lowers once new_compute_pipeline_state has returned, through the cache directory like every lowering (a refusal is kept too). A dispatch whose threadgroup is not whole groups runs that module at its own size; one that comes before the reaper is done waits for the lowering, which the reaper takes next (Reaper::hurry), counted as a first-use wait. Nothing translates on an encoding thread. A state made after quiesce, or whose lowering the reaper's end leaves, is marked not lowered (Error::Quiesced at such a dispatch). The emulated module's threadgroup memory is its arena (metal2vulkan::pipeline::arena_bytes, now public) holding the lengths set, the scratch of each SIMD group, and a vote word: the dispatch's total is checked against maxComputeSharedMemorySize (Limit::ThreadgroupMemory). ComputePipelineState::precision_notes returns the emulated module's notes too once it is lowered. Gap::PartialSimdgroups stays for a state with no emulated module: a kernel the consumer compiled, or one whose emulated variant the translator refuses. A ragged dispatchThreads grid at such a size is Gap::PartialThreadgroups: the partial-threadgroups variant does not take the emulated tier. |
||
|
|
d5a475f1a0 |
old-runtime regression fix: the stage bounds return to Device::new's ANV rows; the bound on every device is a fact of from_queries' profile
|
||
|
|
75b422338a |
identity: argument-buffer textures are the set-1 elements their resource IDs name
Under the identity domains an argument buffer's texture handle is the gpuResourceID its member
holds: the handle is the ID's index, the element of the class's set-1 array (0 is nil, the null
descriptor), with no handle table, no search and no descriptor. Where the shader checks a read
itself (no robustImageAccess2) the handle carries the word's missing-alpha bit (word bit 12) at
HANDLE_ALPHA_ONE, so the handle form is Lookup::Element or Lookup::Flagged{alpha} only.
The handle tables' variant forms are off under these domains (`texture::tabled`): reads of a
member of another numeric class, raw-texel decodes, storage conversions (red-blue, sRGB alias),
A8 alpha-in-red, unreadable-storage nulls, YCbCr write marks, and the HeapCrossClassNeutral,
HeapStorageReads and HeapResidency facts. A slot and a member of one class index one array, so
the class's volatility now merges the slots' uses with the groups'. The admission takes heap
groups whose declaration is their identity class with no plain, raw or cross classes; anything
else stays Unsupported{IdentityDomains}.
Translation output changes only under the identity domains: the default domains plan and emit
as before (no golden re-bless needed). SEMANTICS_VERSION 2153.
The test kernel `tex` gains an argument-buffer form (`texture_kernel(true)`), checked on
lavapipe, moltenvk-m3 and moltenvk-m3 without robustImageAccess2: same answers at the same
elements, set 0 empty, and the handle form Element or Flagged{alpha} as the profile checks reads.
Verified (this commit's tree, as 657e2245c2 on
|
||
|
|
4ac52bf082 |
rt: a kernel's threadgroup memory arguments come from its length constants
The device legs of the tile (m3-max-41638/41639/41640) refused every observing kernel with Gap::KernelInput: the runtime took a kernel's [[threadgroup(n)]] arguments from PipelineInterface::threadgroup, which the translator leaves empty, so a TgLength specialization found no argument. The arguments are now the TgLength constants the module specializes on, by their index. With threadgroup memory reaching a pipeline, a dispatch checks it: the kernel's static part (and a predicated walk's 4-byte vote word, RuntimeFact::PredicationVote, now accepted) plus each length set rounded up to 16 bytes must be within maxComputeSharedMemorySize, else the new Limit::ThreadgroupMemory, Metal's maxThreadgroupMemoryLength counterpart. The precise kernel's test found on the 780M and the XTX one word apart between a tile and the app's shape: a NaN/NaN division (0xffb86e83 / 0x7f9fc206) answers the first operand's payload in one pipeline and the second's in the other. The state carries NativeNanEncoding, so two NaNs are alike there; every other word must be equal. README: the threadgroup memory limit, and NVIDIA 615.71.09's sign-extended narrow clamped sum on GA10x (the planner's wording). REFUSALS.md and the API signatures regenerated. |
||
|
|
2930583b47 |
rt: the cache directory keeps lowered kernels and pipeline data
DeviceOptions::pipeline_cache_dir names a directory a device keeps two things in, for compute pipeline states. translations/ holds each lowering, named by its FunctionCompileKey (the kernel's AIR, entry, constants and linked functions, its lowering inputs, the profile fingerprint and the translator's semantics version), in the translator's self-checking encoding; a state reads a lowering there in place of lowering (Metrics::translations_loaded beside the new Metrics::translations), and a partial-threadgroups variant the translator refused is kept as a marker so it is not tried again. The files take at most 256 MiB, least recently used evicted first. pipelines-<uuid> holds the VkPipelineCache data, framed with a length and a checksum since the initial data must be exactly what vkGetPipelineCacheData returned; every VkPipeline is made through the device's cache, the reaper writes the data 10 seconds after a VkPipeline was made at most once per 10 seconds, and the device's end writes it a last time. Writes go through a temporary file renamed over the name; a file that does not check is a miss and nothing the cache does fails a call. The tile commit's README, refusal table and API signatures follow here: direct dispatches past maxComputeWorkGroupCount are split, and Gap::PartialThreadgroups names the variant refusals by the deciding queries. Tests: a store filled past its cap keeps the most recently used files within it, stores on one directory share files, and pipeline data cut short or flipped is a miss (host); a second device on the same directory lowers nothing at creation, reading all three lowerings, and the pipeline data file is there (device). Not yet compiled: the lint follows. |
||
|
|
576a7348bc |
translator: one stage bound on every device; the two stage-size workarounds go
A module whose entry weighs more than COMPILED_STAGE_WEIGHT (99,109, the heaviest stage measured to compile within host-sized memory, on ANV) is now handed to no driver, whatever its identity. A kernel that emulated its simdgroups only in place of the widest mode's pin (the subgroup size range decides it) is planned again keeping the pin, as before; every other module past the bound is refused with Feature::StageSize and a new Needs::StageBound, its symbol naming the weight and the bound. The refusal is permanent for the input on the device (its plan decides the weight), so it is not NotImplemented; validation reads it as the translator's own gap. DriverWorkaround::SerializedStageWrapsLargeModules and CompilerMemoryGrowsWithStageSize go, with ANV's identity entries for them and the serialized bound (786,432), which the single bound sits far below. Why: the workaround ladder takes one form for every device, the slowest compiler's; a device whose compiler would take a heavier stage is refused it, recorded in FAST-PATHS' known gaps. Measured before this change, with a scratch build that applied the bounds and the re-plan to every profile: the corpus on the Iris Xe's description without its identity refused nothing (largest planned module 91,399, job m3-max-41496), and RADV and NVIDIA nothing either; without maximal reconvergence 12 rows were refused, 6 distinct simdgroup-matrix modules of 198 to 285 products whose lockstep pairs force emulated simdgroups (jobs m3-max-41474, m3-max-41523). The owned fixture stage_bound/stage_bound_matrix (512 simdgroup matrix products beside a lockstep pair in divergent flow, our own MSL) has their structure: on the Iris Xe its emulated module weighs 123,307 and its pinned one 37,646; without maximal reconvergence it is refused at 123,308 (scratch weighing, job m3-max-41602). The new test the_stage_bound_fixture_keeps_the_pin_or_is_refused asserts both paths and that the re-planned kernel is under the bound. The old runtime's heap-trim test loses its long chain, now refused on every device; it asks for a trim where the making left more than the floor free (NVIDIA's compile never does under the bound, 189 MB at most measured). SEMANTICS_VERSION 2150; REFUSALS.md regenerated; the API table loses the two variants and gains Needs::StageBound. |
||
|
|
31c1161940 |
rt: SIMD groups at Metal's width, and robustImageAccess, at the floor
The floor requires Vulkan 1.3's subgroupSizeControl, computeFullSubgroups and robustImageAccess, enabled on every device; the translator's profile takes them through the enable set. Where a device lists compute in requiredSubgroupSizeStages with 32 between its sizes, the translator pins a kernel's SIMD groups to subgroups of 32 (the Direct tier); the compute pipeline state now takes such a kernel: each VkPipeline chains VkPipelineShaderStageRequiredSubgroupSizeCreateInfo where the tier pins a size (the translator pins only a stage the device lists, VUID-...-pNext-02755) and carries the stage's REQUIRE_FULL_SUBGROUPS. "A stage that pins a subgroup size" leaves Gap::KernelInput. A flattened tier's LocalSizeConstraint is supplied: a dispatch whose threadgroup is not whole SIMD groups is refused at the dispatch as the new Gap::PartialSimdgroups, since the emulated-SIMD-group variant is not built. With robustImageAccess on, the translator drops its image write and atomic guards on every device; robustImageAccess2, robustBufferAccess, robustBufferAccess2 and nullDescriptor stay off. Tests: the floor names each new missing feature; the translator's enable set holds robustImageAccess and none of a reported geometryShader, samplerMirrorClampToEdge or VK_EXT_robustness2 (host); every device's translator profile has robustImageAccess and none of robustImageAccess2, robustBufferAccess, robustBufferAccess2, nullDescriptor (device); and simd_float_products runs Direct, pinned at 32, wherever compute can pin 32, refusing a 16-thread threadgroup and answering Metal's products (device). REFUSALS.md and the API signatures regenerated. Verified: cargo fmt; the lint and the device legs follow. |
||
|
|
fa52012831 |
identity: texture slots are the set-1 elements their pushed resource IDs name
Under the identity domains a kernel's texture slots now lower. A slot's gpuResourceID is pushed as its PushField::SlotGuestBase (the index in the low word, the word in the high one). Its texture is the element at that index of one of set 1's two fixed arrays: binding 0, SAMPLED_IMAGE x 65,536, and binding 1, STORAGE_IMAGE x 4,096. Each is partially bound, updated after binding and while unused elements are pending, and seen by every stage, with the same layout for every pipeline (BindingSource::IdentityArray). Each image class the kernel declares (shape, numeric type and depth comparison, sampled, or storage without a format) is a variable of its descriptor type's binding. The slot binds no descriptor and declares no specialization constant: - is_null_texture answers whether the index is 0. Nil needs nothing else in the shader, since element 0 of each array is a null descriptor (the device test of |
||
|
|
ac4b2370f5 |
rt: the consumer names the core Vulkan features its own work needs
DeviceOptions::features takes ConsumerFeature values (SamplerYcbcrConversion for now). Device::new enables each one the device reports, once, in the consumer's order, and Device::features lists those enabled, so the consumer can refuse its own path. The runtime's own work and the translator read only the floor's features. No Metal counterpart. The floor test's device creation chains the maximal-reconvergence and subgroup-uniform-control-flow structures where their extensions are listed, as Device::new does (the device cfgs failed to compile without the fields). The consumer-extensions device test also expects the optional extensions the device lists, and asks for the feature twice. REFUSALS.md takes the renamed site of VulkanVersion (derive.rs derived). API signatures blessed. Verified: cargo fmt. Lint and device legs follow. |
||
|
|
136fb66907 |
metal2vulkan-rt: map the identity ABI's parameter block and grid region; translated-kernel device test
Identity steps 2 and 3 are on development: ArgumentTableAddress is the ring block's address in the window, fields placed in the ArgumentTable go to the block, and every dispatch reads Metal's grid from its pushed region (a zero grid for an indirect dispatch), with no MultiRegion constant to specialize. The README gains the pipeline states' section and its known gaps; REFUSALS.md and the API signature table are regenerated. |
||
|
|
5617449350 |
metal2vulkan-rt: the encoder's refusals in REFUSALS.md and its API in the surface table
Generated by refusal_surface.py and signatures.py --bless. Verified: the generators ran clean (0 variants without a reach mark or a basis). |
||
|
|
46e3215e55 |
identity: kernels over buffers lower under the identity domains
Under PointerDomain::Identity with HandleDomain::Identity every buffer slot of a kernel is its
device address used directly. Each slot is the Psb form, its address read from its own push
field, PushField::SlotGuestBase(slot): gpuAddress plus the bind offset, which under the identity
domains is the Vulkan device address. No root table is read, and no access is contained, as Metal
contains no device-address access (psb::prepare_at). Selection admits, under the identity domains,
only the plans lowered so far (select::identity_admits): a kernel whose push fields are its slot
addresses and its dispatch region, all in the push window, with no descriptor and every slot
addressed. Anything else is still Unsupported{IdentityDomains}, not implemented, now refused there
rather than for every function at analysis. SEMANTICS_VERSION 2146: a refusal under the identity
domains became a module.
The new tests (src/tests/engine_identity.rs):
- a1_bool_from_float under the identity domains on lavapipe and moltenvk-m3 has no descriptor,
no root table and three SlotGuestBase fields. It passes L3, and it computes the program's
answer on the CPU interpreter, with its buffers above 4 GiB at bind offsets 32, 16 and 4. It
writes nothing past its output, with its region pushed.
- a2_dynamic_texel_offset, which samples a texture, compiles under the default domains and is
refused under the identity ones.
Verified:
- m3-max-41149 (msi, check commit eeecc4492b, the same tree but for the test's region bytes):
clippy -p metal2vulkan --all-targets --all-features, rustdoc -D warnings, and nextest -p
metal2vulkan --all-features, 3664 of 3665. The one failure was this test, which met the kernel's
DispatchRegion field and did not fill it.
- m3-max-41195 (msi, a5dbfd408f, this tree): clippy and rustdoc; tests::engine_identity and the
domain pair test, 3 of 3.
- m3-max-41150 (msi, eeecc4492b): clippy under --cfg m2v_gpu and --cfg m2v_cpu_icd.
|
||
|
|
94071f82a2 |
device: the identity pointer and handle domains, taken as a pair
The new runtime's form: pointers are device addresses used directly and a texture's or sampler's
handle is its gpuResourceID (docs/RESOURCE-ID.md). The variants come beside the old domains,
which stay until the cutover; nothing lowers under them yet.
- PointerDomain::Identity and HandleDomain::Identity.
- Device::new refuses one identity domain without the other (InvalidDescriptor) and the identity
domains on a device without bufferDeviceAddress and shaderInt64 (Unsupported{IdentityDomains},
naming both features as one alternative).
- A compile under the identity domains is Unsupported{IdentityDomains}, not implemented, at the
start of analysis, so no old form is ever emitted under them. Later steps lift it as the
lowering lands.
- The profile fingerprint covers the domains (tested).
- docs/API.md's policy section names the domains; docs/REFUSALS.md and the reach table carry the
new refusal; api_signatures regenerated.
Verified (this commit's tree, rebased with the ledger commit before it onto
|
||
|
|
077c9722e3 |
metal2vulkan-rt: command queues, command buffers and events on the submit and completion threads
Step (c) of the new runtime's compute core.
What:
- CommandQueue (newCommandQueueWithMaxCommandBufferCount:, its bound on uncompleted command
buffers), CommandBuffer (enqueue, commit, handlers, waits, status, error), Event and
SharedEvent (signaled_value, set_signaled_value, wait_until_signaled_value,
notify_listener).
- A command buffer records at once into segments split at event waits and signals. The submit
thread holds a segment whose waits are not met, and its queue behind it, while the segments
before it run (reims F1). A wait the host's value meets submits no semaphore wait; a GPU
signal not above the highest value submitted or set is left out, so the semaphore only rises.
- The completion thread retires by a progress semaphore, follows submitted event signals (a
listener runs at a mid-buffer signal, reims F2), runs handlers with no lock held, and is
woken through a host-signalled timeline semaphore only when a wait needs it.
- A command buffer keeps each block it uses until it retires. A zeroed Private buffer's fill is
an upload submitted ahead of every later commit, whose segments start with a barrier; each
segment ends with a barrier to the host.
- Device::quiesce(timeout) (F9), with every wait bounded, no join of a thread still running, no
thread-local that exit() tears down, idempotent, freeing nothing; unmap runs on the caller for
every block handed out, once (a handed set replaces the per-idle flag).
- The last handle dropped in a handler: the completion thread finishes the teardown itself (F8).
- CommandQueue::abandon (F14); a loss ends held work, in-flight work once the device is idle,
host waits on pending signals, and later commits, with DeviceLost { in_flight } (F13).
- Refusals Committed, OtherDevice, NoCommandBuffers with their basis; Error::Quiesced;
docs/REFUSALS.md and the API signature table regenerated; the README's contract.
Verified: cargo fmt; refusal_surface --check. The compile and device jobs follow.
|
||
|
|
4e8784ad14 |
refusal surface: the new runtime's own refusal enums, one section each
What: refusal_surface.py reads the new runtime's Error and makes a section of docs/REFUSALS.md for each variant whose payload is one enum the runtime declares: today Refused(Refusal) and Limit(Limit), and any family added later (a Gap included) without a list of names to keep. Each of their variants declares its basis, as Problem's do, and --check fails on one that does not. The translator's Limit section no longer counts rt's Limit sites. A rustdoc link [text](path) in a summary reads as its text; three existing rows lose a link the file could not follow. Why: AGENTS.md wants every new refusal in REFUSALS.md, and the scan of rt read the floor's Missing only, so EmptyBuffer, BufferPastBlock, BlockLen and BlockIds were missing. Their basis lines cite the M3 Max measurements the old runtime records for the same answers (newBufferWithLength:0 and a placement past the heap's end answer nil), the device's limits, and our 32-bit numbers. How verified: the script regenerates, --check and --selftest pass locally; the refusal_surface test runs in the compile job. |
||
|
|
374e29a988 |
metal2vulkan-rt: the floor's shader features, queue family, timestamps and memory types
The floor now also requires what the translator's shaders and the runtime's core need of every device: - shaderInt16, shaderInt8, storageBuffer16BitAccess (Vulkan 1.1 features, now read and enabled through Features::vulkan11), storageBuffer8BitAccess, scalarBlockLayout, vulkanMemoryModel and vulkanMemoryModelDeviceScope. The translator emits 8- and 16-bit access only in storage and physical storage buffers in practice (uniform views are u32 or uvec4, push fields are 32- or 64-bit), so the uniform and push-constant 8/16-bit features stay out; it does use device scope. - timestampComputeAndGraphics, and timestampValidBits of at least 36 on the first queue family with graphics and compute, which Capabilities names (queue_family). A device with no such family is Missing::QueueFamily. - a host-visible, host-coherent, host-cached memory type (Shared storage) and a device-local, host-visible, host-coherent one (the parameter ring), each usable by a buffer of BUFFER_USAGE: every Vulkan 1.3 buffer usage plus device addresses. Vulkan answers buffer memory types only for a created device, so check() finds a type with each set of flags and carries the memory properties, and memory_types(device, &capabilities) chooses the first usable type of each with vkGetDeviceBufferMemoryRequirements. Missing::MemoryType names the flags. Each shortfall is named in BelowFloor, with a unit case; the README's Floor section states every item and tests::floor holds it to the code. The device test now also creates each device with the floor's features and extensions and chooses its memory types on it. CI's lavapipe step (ci.yml and scripts/linux-gate-ci) runs the rt crate's device tests too. refusal_surface.py reads metal2vulkan-rt and writes the floor's Missing as section 10 of docs/REFUSALS.md; signatures.py pins metal2vulkan-rt's public surface in api_signatures.tsv. Verified: see the lane report (compile job, device legs on every lab GPU, lavapipe and the Windows UHD 630). |
||
|
|
f19c613fe1 |
RUNTIME 2489: A compute or render encoder's core is made in the box it lives in: one 3 KB copy per encoder fewer
EncoderCore (2984 bytes, -Zprint-type-sizes on msi) was built by value in EncoderCore::open, copied out of it in the returned Result, and copied again into its box (EncoderCore::boxed / boxed_in) by the compute and render opens: two 3 KB memcpys per encoder. A pinned LBR profile of a guest-shaped compute stream (dispatch_chain --host 400 --only encoders --dispatches 5 --groups 64 --states 3 --binds tex-moved, msi lavapipe) put libc copies under EncoderCore::open (~110 ns) and open_compute (~98 ns) per guest dispatch, one encoder each. EncoderCore::open_placed takes a place closure that puts the core where it lies, the box for compute (parked room or the device's spares) and render (spares), so the core moves once. open keeps the by-value form for the blit encoder (HeldCore). Nothing else changes: the same fields, the same order under the same lock, the same boxes. Test: tests::compute_parked::a_compute_encoder_core_lies_in_the_box_its_command_buffer_parked (three encoders of one command buffer find their core at one address; it pins where the core lies, not the copy count). RUNTIME_VERSION 2489. Verified: msi m3-max-38102: clippy -p metal2vulkan-runtime --all-targets --all-features -D warnings 0; lavapipe debug (cfg m2v_cpu_icd) compute, dispatch, encoder, tracker and render suites 190/190. Pinned interleaved A/B (msi lavapipe, release, taskset -c 0-7, 5 base/tip pairs, guest shape dispatch_chain --host 400 --only encoders --dispatches 5 --groups 64 --states 3 --binds tex-moved, --runs 30): the open call 640 -> 574 ns per guest dispatch (-66 ns); thread_cpu per dispatch within run-to-run noise (6137 vs 6240, range 5615-6681). Profile at the base (m3-max-38071, LBR): open copied the 2984-byte core out in its Result (~110 ns) and open_compute again into its box (~98 ns). |
||
|
|
45ebbdaa5e |
RUNTIME 2484: Copies between a texture's region and a surface's runs of guest RAM
A consumer that keeps an IOSurface's GPU copy as one optimal texture, on a host whose surface path copies by runs of guest RAM (copies_guest_ram: no view of the pages is made), needs the texture forms of the run copies, or its fill, upload and download go back through a view per block or a staging buffer. What: BlitCommandEncoder::copy_texture_from_host_ram(ram, runs, offset, bytes_per_row, size, texture, slice, level, origin) and copy_texture_to_host_ram(texture, slice, level, origin, size, ram, runs, offset, bytes_per_row), runtime extensions (Metal has none). `runs` is the surface's bytes in order (the shape the consumer's run copies pass today); offset and bytes_per_row are Metal's copyFromBuffer layout over those bytes. Each row's texels within a run and a chunk are one vkCmdCopyBufferToImage / vkCmdCopyImageToBuffer region straight on the chunk's import (bufferRowLength and bufferImageHeight 0; bufferOffset a multiple of the texel, VUID-vkCmdCopyImageToBuffer-srcImage-07975; the subresource bounds 07971/07972), with no staging buffer. A first-touch or CPU-only chunk goes through the existing StagedGather / StagedScatter, which now take a buffer or an image target. Hazard tracking, dirty-page reports, imports held to completion and the bytes outside the texels are as the buffer forms keep them. Refused as the buffer forms are, and with Invalid / Problem::HostRam for the texture's own cases (its doc extended); no new RuntimeGap, Degradation kind or WorkCounts field: the direct form shows in host_ram_copy_regions with no staged copy. replay.rs logs the call (HostRamTextureCopy); blit_texture.rs and blit_plan.rs helpers are shared (pub(super)). Runtime README and HOWTO document it; the signature table blessed (+2 methods); REFUSALS regenerated. RUNTIME_VERSION 2484. Verified: msi job m3-max-37991 (lavapipe, --cfg m2v_cpu_icd): clippy -p metal2vulkan-runtime --all-targets --all-features -D warnings 0; nextest host_ram_texture_device + host_ram_copy_device 39 passed. m3-max-37997: "HOST-RAM-TEXTURE llvmpipe: fill regions 250, dispatches 0, staged 0" (a 300x200 BGRA8 Private texture, rows at 1280 bytes from byte 48, one row across a chunk end); the staged test saw exactly one staged gather and one staged scatter. Plain and --cfg m2v_gpu clippy, rustdoc and the 780M and Iris runs follow on development. |
||
|
|
3619e37540 |
RUNTIME 2482: Texture::view_placement answers what a view would be, by the decision its making takes
The consumer will make an IOSurface plane's device cache one optimal Private texture, every texture over the plane a view of it, and needs to know before it makes a view whether the runtime would make it a Vulkan view of the image or a view shadow (which it sends to its own fallback instead). What: `Texture::view_placement(pixel_format)` answers `ViewPlacement` (`Image`, `ImageThroughSwizzle`, `Shadow(ViewShadowReason)`, `OverBytes`), or the error `new_texture_view` would refuse the view with. The decision is factored, not copied: `Texture::checked_view` holds the checks `view_as` ran inline (Metal's rules, rotation, X32, buffer slices, decoded twins), `Texture::view_hold` decides the storage (shared, through a swizzle, the viewed image, a shadow and why, storage over the bytes), and `Device::view_shadow_plan` / `shadow_plan` hold the shadow's refusals `image_shadow` checked while making. `view_as` and the query call the same three. `image_plan::views_missed` replaces `takes_views_of` and names why an image takes no view (another compatibility class, or not in its list); `Device::view_apart` replaces `image_takes_view` and puts the device's missing reinterpretation first; the `shadowed-texture-view` notice's reason now follows that reason (it chose by the texture's PixelFormatView usage before). Tests: `view_placement_device` (runtime, device cfgs) sweeps 10 texture formats x 5 usages x 24 view formats, checks the query moves no count and matches the view made (by `view_shadows`, `views_through_swizzle` and the handed-out image), and names the consumer's cases. `plane_device_cache` (validation lane): a 300x200 BGRA8Unorm Private texture round-trips between no-copy buffers at offset 48 and pitch 1232 with every other byte kept; a clear through its sRGB view then a copy through its own-format view in the next encoder, tracked and untracked with a fence, read the clear with no hazard under synchronization validation, and the unordered control is reported as a read after write. Documented in the runtime README; the signature table blessed (10 rows); REFUSALS regenerated. RUNTIME_VERSION 2482. Verified: msi job m3-max-37961 at c2f0c96d3c: clippy -p metal2vulkan-runtime -p metal2vulkan-validation --all-targets --all-features --cfg m2v_cpu_icd -D warnings 0; the lavapipe tests, plain and --cfg m2v_gpu clippy and rustdoc follow on development. The hazard tracker keys a view's uses on its image (texture.rs view_as shares the Arc<Image>; bound_use/image_use key on image.identity.key), so the order across views needed no fix. |
||
|
|
df87983bb7 |
RUNTIME 2463: Render draws: the restarted list and the error and notice makers out of line, cold
What: draw_resident's restarted-list arm (the index rewrite and gather requests, 205 source lines) is its own #[cold] #[inline(never)] method, restarted_list; Device::degrade, degrade_copied_pages, degrade_host_step, degrade_where and tell, and error.rs's vulkan, invalid, nil and internal are #[cold]. Same commands, barriers and answers; only where the code lies changes (draw_resident 130.7 -> 127.4 KB of machine code). Also folded: draw_costs gains a guest shape of a few render encoders with set_bytes and each thread's CPU a draw (17126bfe04), the encoding thread's own CPU apart from unnamed threads (afa24f4074), and --calls counting each call's cycles and cache misses (7249f6930b). Why: on a Zen 4 host a one-draw render pass ran at IPC 0.79 against 1.7 inside a long pass, the same on RADV and lavapipe (gem10, m3-max-36911/36975). The misses are instruction fetches: per pass about 8.3k L2 instruction misses against 1.2k data, over 806 distinct 4 KiB code pages (more than the L2 iTLB's 512), no function above 7.5% of them (m3-max-37017, -37041). This change is measured neutral (m3-max-37061, lavapipe, release: pass1 instructions 112,257 -> 112,123, L2 misses 10,590 -> 10,577; cycles within the node's noise) and kept as correct and neutral; the lever left is the layout of the path's code across pages, a build setting of the program. Verified: see the landing's check jobs. |
||
|
|
3de483d86f |
RUNTIME 2459: Joined completions: a command buffer marked to join the next groups under Exact
CommandBuffer::set_completion_joins_next marks a command buffer, before its commit, as one whose completion may be seen with the next one's. Under CompletionPolicy::Exact, on a device whose merge check holds and whose queues are not relayed, a marked command buffer's batches wait in the scheduler's group as every batch does under Grouped. The first batch of the VkQueue behind them that is not marked goes last in that group, which then goes at once (GroupEnd::Closed, WorkCounts::group_ends_closed), so it is seen complete at its own end and never held back. Its submission check runs with the marked ones' (check_heads), so they are found ready together. No group is kept past its pass under Exact (Alone::Unkept, WorkCounts::batches_held_alone_unkept): a kept group can reach the GPU after the work ahead of it ended, which would delay the unmarked one behind it. Everywhere else (Grouped, no merge, relayed queues, the encoder trail, batches that never group) the mark changes nothing. Why: on the Iris Xe, ANV on i915 lists every VkDeviceMemory in each execbuffer, about 170-190 us of driver time a vkQueueSubmit at the consumer's import count, and the consumer cuts each guest command buffer into about 12 parts committed under Exact, one kernel submission each. In its walk the GPU sat idle about 1.5 ms per waited guest buffer between parts already committed, behind a backlog of those calls. The consumer will mark every part but the last of a cut whose completion nothing observes. Grouped-completion's notice, docs/API.md's catalogue, FAST-PATHS row 38, the runtime README, CompletionPolicy::Exact's doc, api_signatures and REFUSALS say so. Tests: runtime_lane::joined_completions (marked parts group and a group is closed by the last; checked parts too; a no-op where the device's own check finds no merge; unmarked parts go alone; an unmarked command buffer is seen complete while the long one behind it still runs, the marked one before it complete by then), on lavapipe with the merge assumed. Joined completions: the cost table's length, and the order test's first work done before The conformance cost table's SHARED list holds 36 rows with batches_held_alone_unkept. In the order test the marked command buffer took the new buffers' first work, which no batch in a group takes, so it went alone and nothing grouped: the buffers' first work now runs before it. Verified: clippy and lavapipe lane job m3-max-36769 showed the failure (grouped 0 with grouping true); the rerun is the next job. Verified at 8e6c37c263: m3-max-36784 (msi) clippy --workspace --all-targets --all-features 0; m3-max-36785 (msi, lavapipe, --cfg m2v_cpu_icd) joined_completions + grouped_submissions + alone_batches 21/21 (marked parts under Exact with the merge: 7 command buffers in 2 submissions; unmarked: 7 submissions, 0 grouped; lavapipe's own merge check, not Holds: 0 grouped; an unmarked buffer is seen complete at its own end). The Iris merge check answers Holds (m3-max-36725: 9.6 us in one call of 4 against 26.4 us apart). Release-mode lavapipe, clippy --cfg m2v_gpu and m2v_cpu_icd and rustdoc run after the merge. |
||
|
|
8d617591f8 |
RUNTIME 2409: In-place textures over dma-buf pages: the image bound in the buffer's own import
A texture in place over a no-copy buffer's dma-buf pages no longer always asks the pages' source for a new dma-buf and a dedicated import of its own. Where the pages lie in one import dedicated to nothing (no sparse buffer over several imports, no import the driver made dedicated to the buffer), its DRM_FORMAT_MOD_LINEAR image whose plane lies at offset 0 at the texels' pitches is bound in that import at the texels' offset, beside the buffer (vkBindImageMemory's memoryOffset): no udmabuf, no import, no new GPU mapping. Every fact is asked of the driver: the image requires no dedicated allocation (VUID-vkBindImageMemory- image-01445), the format query takes dma-bufs for it outside one (not DEDICATED_ONLY), its alignment divides the offset (-None-10735), its size fits the pages' placement (-None-10737) and its memory types take the import's. An import dedicated to the buffer binds no image (-memory-10926): DmaBufPages now notes that. A new check class, PagesClass::DmaBufInImport (CHECK_VERSION 20), measures that image; the check's textures of each dma-buf class take that class's image alone (a thread-local of the class the check runs). texture/route.rs takes the new class where its verdicts take the texture, else DmaBuf's; a shadow waits on DmaBuf's verdict while both pend. Where the making refuses the image in the import, it falls back to today's image where DmaBuf's verdicts take it. A pending move re-routes the same way. Binding in the import reads it apart: it is kept imported for good, as an image in a pointer import's is. A rebind remakes such an image in the new pages' import by the same order. RADV requires a dedicated allocation of every such image, so its check leaves the new class unchecked and it never takes the route. New WorkCounts field: dma_buf_images_in_import. No new Degradation kind. The route-(b) device tests (parked images, plane offset, import cycles, a texture's residency) fail the new class's verdicts first, so they keep measuring today's image on any device. A new device test (tests/dma_buf_in_import.rs) counts the route and its negative control. Also: 4c3cbe2f1d and 37d2a750ce (the probe, dma_buf_linear_bind: a linear and a modifier image for dma-bufs bound in the pages' existing import, the dedicated answers, a re-import arm), 5a40c2ef7b (docs: API.md, HOWTO.md, FAST-PATHS.md, host_residency.rs module docs). Why: the owner asked how to remove the per-texture dma-buf. Probe answers (Mesa 26.2.6): RADV on the Radeon 780M refuses LINEAR images for dma-bufs (NOT_SUPPORTED x15) and requires a dedicated allocation of every DRM_FORMAT_MOD_LINEAR image (m3-max-34443), so there it never fires. ANV on the Iris Xe takes both images outside a dedicated allocation, bound in the existing import byte-exact; first use of an 84 MiB texture 1.37 -> 0.21 ms (m3-max-34453). Verified in the lane (m3-max-34571, gem10, at 5d5dee7901): clippy -D warnings -p metal2vulkan-runtime --all-targets --all-features, plain and m2v_cpu_icd. Still running when landed: the lavapipe in-place and dma-buf suites with the new count test (m3-max-34593), clippy m2v_gpu, PHOENIX, and the Iris count test with its negative control. API: adds the field WorkCounts::dma_buf_images_in_import (additive; api_signatures blessed in the lane). |
||
|
|
aa5511f61e |
SEMANTICS 2130 / RUNTIME 2406: 16x16x16 simdgroup matrix products: refused as their own feature, Metal's rule below Apple10
What: `air.simdgroup_matrix_16x16x16_[widening_]multiply_accumulate` is now refused in every stage
as `Unsupported{SimdgroupMatrix16x16x16, NotImplemented}` (a new `Feature`), ahead of the 8x8
lowering's kernel-only check. The runtime's `compile_error` answers it as Metal does:
`Needs::MetalGpuFamily(1010)` on a device that does not claim Apple10, `NotImplemented` on one
that does (as `IndirectRenderState`). The owned fixture engine/simd_matrix16 shrinks to one form
per class (float, half, widening signed int8), each with the four transpose-flag pairs, 12
kernels; the probe carries the M3's answer in its header.
Why: Metal itself refuses these products below Apple10. The M3 Max (macOS 27.0.1) refused every
pipeline of the fixture at creation, AGXMetalG15X_M1 code 3, "simdgroup_matrix<T,16,16x16>
operations are supported by GPUFamily10 and later" (job m3-max-34410). No device the runtime
presents claims Apple10: the family lists the "SIMD-scoped matrix multiply operations" row (from
Apple7), refused NotImplemented(SimdgroupMatrix) on every device, and the lod-bias row, a gap. So
the refusal is Metal's own answer, not a device gap: no FAST-PATHS known gap.
Tests: engine_simd_matrix::products_of_16x16x16_are_refused_as_their_own_feature (every
committed profile, the fixture's 12 kernels); runtime_lane::simd_matrix16 (the device's compute
pipeline creation answers MetalGpuFamily of Apple10). REFUSALS.md regenerated, api_signatures
blessed, reach mark added. The engine fixture expectation table and golden hashes take the
fixture's rows on development.
Also: f639b74288 adds the owned fixture (MSL we wrote, compiled by scripts/regen-air-fixtures) and
its Metal probe; 5dbfa3d3d5 imports AirLibrary in the runtime-lane test.
Verified in the lane: m3-max-34499 (msi, at 38d4694b12) clippy -D warnings for metal2vulkan, runtime
and validation (all targets and features) and 45/45 tests, incl. the new engine_simd_matrix test (12
kernels on every committed profile), the error tests, refusal_surface, api_signatures, api_surface;
m3-max-34514 (gem10, at 5dbfa3d3d5) clippy m2v_cpu_icd and runtime_lane::simd_matrix16 on lavapipe
(Needs::MetalGpuFamily(1010) for all 12). Clippy m2v_gpu (34516) still running when landed.
API: adds Feature::SimdgroupMatrix16x16x16 (additive; api_signatures blessed in the lane).
|
||
|
|
c2206c14b0 |
RUNTIME 2389: Device::import_shared_dma_buf imports a shared dma-buf ahead and keeps it while a handle lives
A runtime extension (Metal has none). A guest's buffers over pieces of one shared file of guest RAM were each imported as their own dma-buf import and freed with the buffer, so a compute loop that made and dropped no-copy buffers paid an import and a free per command buffer, and on RADV each import maps its pages at once (the next submission's CS waits for the page-table job). Device::import_shared_dma_buf(file, options) (unix) imports the whole dma-buf on the caller's thread, or joins the device's live import of it, and returns a SharedDmaBufImport; while a handle lives, the file's entry in the device's map keeps the import, so buffers over its pieces join it instead of importing again, and it is freed once its last buffer, heap and handle have gone (one kept import per file a live handle names, per generation). The class comes from `options` as a no-copy buffer's (Private, Memoryless and undefined options refused, Invalid StorageMode); the import takes the type a no-copy buffer of that class would get first, so pieces join it. Refusals use the existing kinds (Unsupported HostMemory, OutOfMemory). A device's recovery lets go of the lost generation's kept holds and seeds the new one's map, whose first buffer imports the file again; nothing is imported on the recovering thread. A device without a dma-buf importer keeps nothing (Debug: imported false). The handle imports whether or not the device's buffers over those pages take the dma-buf route: on a device that takes the pages' pointer it is one listed dma-buf a submission for nothing. WorkCounts::dma_buf_shared_imports_kept gauges the kept imports; the handle's import counts in dma_buf_imports. Docs: rustdoc, dma_buf.rs Shared files, HOWTO dma-buf section, the runtime README extensions and unix-only lists. REFUSALS.md: the StorageMode site moved to host_class, which the no-copy call and this one share. Public surface: Device::import_shared_dma_buf, SharedDmaBufImport (Send + Sync, consumer_auto_traits) and WorkCounts::dma_buf_shared_imports_kept, blessed in api_signatures.tsv. Verified: m3-max-33745 at the lane tip 856a1fabae: clippy plain, m2v_gpu, m2v_cpu_icd 0; rustdoc 0; lavapipe runtime suite 2836 passed. Device tests (lavapipe): three buffers made and dropped in turn take imports 1 / joined 3 with the handle, imports 3 / joined 0 without; a handle keeps a live buffer's import; recovery imports nothing and the next buffer's import stays kept; Private refused. Churn bench, PHOENIX (RADV 780M, release, interleaved, 450 command buffers an arm, a8f297bf11, the same code but the count): no handle 1 import + 1 free a command buffer, call median 820-907 us, GPU start median 3026-3037 us; handle kept 0 imports, 0 frees, 1 join, call median 25-69 us, GPU start median 104-145 us. |
||
|
|
ab139e4b6e |
RUNTIME 2366: Runtime FALLBACK repro bundle at a creation refusal (default-off diagnostic)
What: metal2vulkan-runtime writes the FALLBACK repro bundle the command line writes for its own failures when it refuses a library or pipeline creation, where METAL2VULKAN_REPRO_DIR names a directory (unset, nothing is written). - The CLI's bundle writer moves into the library as the hidden crate-root module metal2vulkan::repro (feature serde), shared by the binary and the runtime. A bundle's directory is named by its content (metal2vulkan-repro-<16 hex>), written under a temporary name and renamed, so an identical failure is written once, across threads, processes and runs. The CLI's own bundles keep their files (input, profile.json, the descriptor files, repro.sh, repro-command.txt, failure.txt); only the directory's name changed, so a bundle written before still replays. - The CLI takes --device FILE in place of --profile: the JSON of a DeviceDescription and DevicePolicy (ReproDevice), which builds the runtime's own compile device. - The runtime hooks each creation where its refusal returns: a library of a metallib, a function's lookup, every compute and tile state (ComputePipelineState/TileState::create_adding: creations, added binary functions, archive adds) and every render state (GraphicsState::create_reflecting). It bundles Unsupported, NotImplemented and Compile refusals but a cancelled compile and a name the library lacks (Metal's own nil); never Invalid/Nil/MetalError. The bundle holds the library's bytes, device.json, the request as the CLI's options and descriptor files, and failure.txt with the call, the refusal and what the command does not replay. That list comes from a full destructuring of the compute, tile and render descriptors (and the stage functions): a new descriptor field fails to compile in repro.rs until it is replayed or listed. - Bounded: at most 32 bundles and 256 MiB per process; past either nothing more is written and one line says so. Written on the refusing thread; the call returns the same refusal; a write failure is said once. Each bundle is named in one line through the device's message sink (id name metal2vulkan-repro). The runtime's metal2vulkan dependency gains serde. - Not bundled: mesh states (no CLI mesh path), a dispatch's or draw's later variant, driver VkPipeline makings, Metal-source libraries. Docs: env_vars registry, README CLI, docs/HOWTO.md section 4, the runtime README's Errors section, the CLI help. Tests: runtime CPU tests of the bounds (a tally with the seam's limits); a lavapipe/GPU device test (ob3_stage_input with no stage-input descriptor: one bundle with the expected parts and command, device.json rebuilding the runtime's compile device by profile fingerprint and answering the same refusal, none for a second identical refusal or a missing name, none without a directory); CLI tests replaying library-written runtime bundles (compute, and render with a vertex descriptor) through repro.sh to the same FALLBACK, and --device compiling what --profile does. Verified at ae56b195e9 (msi, m3-max-32986): metal2vulkan cli, api_surface and api_signatures 25 passed; runtime repro tests 9 passed; clippy -p metal2vulkan -p metal2vulkan-runtime all targets, all features 0. Lavapipe (m3-max-32978): repro_device writes one bundle that the CLI replays to the same refusal; a second identical refusal writes nothing. |
||
|
|
5ba7afd9d4 |
RUNTIME 2360: Shader cache: no default directory makes a memory-only device, never a failed one
With no caller directory and no home (USERPROFILE on Windows, HOME elsewhere), default_directory answered Err and CacheSetup::of turned it, and any failure to open the default path, into Error::ShaderCache, so every device creation and adoption failed. Metal never fails device creation over its shader cache, and the default is the runtime's choice, not the caller's (owner rule 2). - The Windows default is %LOCALAPPDATA%\metal2vulkan (the local application data folder, read from the environment; no new dependency). XDG_CACHE_HOME and USERPROFILE are no longer read there. - default_directory takes its environment as a closure (CacheSetup::of_in), so a test feeds its own without touching the process's. - Where the caller names no directory and the default does not exist or cannot be made or written, the device keeps its cache in memory alone: the Store has no directory, every lookup is absent, every write is refused with no filesystem call, the scans do nothing, and writers ask has_directory first so nothing is encoded for it (a translated function still is: its encoded length weighs it in the memo). The device says so once as it is made, as the existing degrade notice ShaderCacheEntryNotWritten naming why; each entry it does not write counts in write_failures. The driver's pipeline cache data is not read back, and the device checks' verdicts are not encoded. - A directory the caller names that cannot be used is still Error::ShaderCache. - Device::shader_cache_directory answers Option<&Path>: None for such a device. Docs: the shader_cache module docs, ShaderCacheOptions::directory, write_failures, Error::ShaderCache, the degradation's declaration and its docs/API.md entry, the runtime README (Windows default, error table), HOWTO, create.rs's list of environment variables. api_signatures re-blessed; docs/REFUSALS.md regenerated (a refusal's site function renamed). Tests: tests::shader_cache's default-directory and no-directory-store unit tests (plain gate), and the lavapipe/GPU device test shader_cache_no_directory: a device made with an empty environment and no caller directory is made, has no directory, makes four render states with two functions translated once, writes nothing, and its notice is heard once. Verified (msi): m3-max-32796 clippy plain 0, 67/67 shader_cache and degradation tests, api_signatures 0, clippy x86_64-pc-windows-gnullvm 0; m3-max-32797 (lavapipe) clippy m2v_cpu_icd 0, 61/61 shader_cache and in_place_check, including the no-directory device test. |
||
|
|
0ca24685d7 |
RUNTIME 2351: Textures over buffers: Metal's allocation bound counts the last texel, a heap's size and a no-copy buffer's pages
A texture over a buffer whose texels run past the length was answered nil where its rows' padding ended past the length rounded up to 16 KiB. The M3 Max (macOS 27.0.1, the consumer's limits runs, every buffer kind and length bisected) makes more: - A 2D texture and a texture buffer count to their last texel, not the last row's padding: a 2D R32Uint 64x64 from 256, rows 512 apart, over 20000 bytes is made with its last texel at 32768 (rows' end 33024); a texture buffer of 32768 R8Uint texels at a bytesPerRow of 36864 over 20000 bytes is made. Arrays keep their rounded slices' end. - A heap's buffer is bounded by the heap's size, counted from the buffer's start, whatever its length or place in the heap (4 MiB heap: made to 4194304, nil at 4194305). - A no-copy buffer is bounded by its pages: its pointer's offset in its 16 KiB page plus its length, rounded up to 16 KiB, from its start (16384 bytes starting 4096 short of a page's end: made to 32768). BufferFacts now carries the buffer's allocation (own, a heap's size, a no-copy buffer's page offset), filled from Buffer::heap, host_backing and contents; BufferFacts::allocation_end gives the bound. Buffers under 16 KiB keep no bound (the M3 Max answers nil past 128 KiB there, the x86 Macs make every end measured), and an array whose last texel lies inside the length is still made: no new refusal. Such a texture stays a copy, as before at the old bounds: a 2D texture or array is a shadow image whose copies in and back go through its tail (texture/route.rs Route::Past -> TextureShadowReason::PastLength, announced shadowed-texture), a texture buffer's functions view its tail (into_texture_buffer, staged-texture-buffer). The texels past the length live in the tail, zero when made; the caller's bytes past a no-copy buffer and a heap's other bytes are never read or written. Tests: tests::linear_plan::a_texture_ends_where_metal_s_allocation_of_its_buffer_does (each kind's and form's M3 boundary, made at it and nil one past; the made rows past the old bound fail before this change); device tests in buffer_tail_device (a heap's buffer to its 64 KiB heap's size, a no-copy buffer at page offset 12288 to 32768, a padded 2D texture to its last texel): made, every path reads and writes right, the buffer's CPU write inside the length is read through the texture, shadow copies counted, no other memory touched, one row more Metal's nil. docs/API.md's accepted difference, REFUSALS.md regenerated. Evidence (lane jobs, msi): m3-max-32369: clippy -p metal2vulkan-runtime --all-targets --all-features -D warnings 0; linear_plan|buffer_texture 34/34 incl. tests::linear_plan::a_texture_ends_where_metal_s_allocation_of_its_buffer_does (the M3's boundaries per kind and form, made at E, nil at E+1). m3-max-32370 (lavapipe): 13/13 buffer_tail_device + allocation tests incl. a heap's buffer to its heap's size, a no-copy buffer to its pages, a 2D texture whose last texel ends at the allocation: every path (get_bytes, blit, kernel) reads as made, writes coherent with the buffer's bytes inside the length (shadow copies counted: such textures are shadows / staged texture buffers through their tail), neighbours untouched, one row more Nil(PastAllocation). Negative control and the PHOENIX run follow in the lane. Lane commit: 263219d515. |
||
|
|
f851c07e52 |
SEMANTICS 2123 / RUNTIME 2349: Texture buffers past maxTexelBufferElements bound through views of their parts
Metal makes texture buffers of up to 2^28 texels on every Mac; one texel
buffer view holds at most the device's maxTexelBufferElements (2^27 on ANV
and lavapipe, 2^26 on MoltenVK), and the binding of a wider one was refused
(BindError::TexelBufferTooLarge).
The consumer now states with a texture buffer's binding the views its texels
take (BoundTexture::Buffer::parts, bind::texel_buffer_parts: 1 within the
limit), which its shape carries. A slot whose function only reads, writes,
updates by an atomic or asks the width of the texture buffer, on a device that
indexes texel buffer arrays NonUniform, states RuntimeFact::TexelBufferParts;
where the shape binds more than one part there, the plan asks for the parts
variant (VariantKey::texel_buffer_parts). Under it the slot is an array of
the parts' texel buffers: texel i is texel i - k*P of part
k = min(i / P, parts - 1), P the device's limit rounded down to its texel
buffer offset alignment (bind::part_texels), and the width (parts - 1) * P
plus the last part's. texel_ranges writes one range per part at its array
element (DescriptorRange::element), and the runtime views each.
Each part is the device's own view in the format one view takes, so a read
converts its texel as the one view does: no precision note. A texture buffer
one view holds keeps one view, no variant and its key. The families row
TextureBufferWidth is exact where the parts reach 2^28.
Still refused (TexelBufferTooLarge): a slot read through a sampler or used beyond read/write/atomic/width; a device
without NonUniform indexing of that kind of texel buffer array; formats with several texels a block. Argument-buffer
texture buffers past the limit stay the heap neutral (unnamed-texture-unviewable). New: WorkCounts::texel_buffer_parts_bound,
RuntimeFact::TexelBufferParts (appended), bind::part_texels / texel_buffer_parts, BoundTexture::Buffer.parts,
TextureShape::Buffer.parts (serde default 1), VariantKey/LoweringInputs.texel_buffer_parts (hashed only when non-empty),
DescriptorRange.element. SEMANTICS_VERSION bumped: input once refused now translates.
Evidence (lane jobs, msi): m3-max-32343 at 628264de17: clippy --workspace --all-features --all-targets -D warnings 0;
41 metal2vulkan tests incl. golden_hashes_match_the_table (every fixture's SPIR-V unchanged on every profile: one part is
byte-identical), the binder test (an under-limit slot: no parts entry, empty variant, layout counts 1), the interpreter
parts test (robust and unrobust), api_surface / api_signatures / refusal_surface; families::states_follow_their_sources;
lavapipe texture_buffer_width_device (R32Uint limit+64 texels: both sides of the limit and the last texel read and written,
past the end reads 0 and writes dropped, texel_buffer_parts_bound +3) and buffer_tail_device. Without the fix the device
test fails at bind: TexelBufferTooLarge{elements 134217792, limit 134217728} (m3-max-32140). ANV (2^27) is down; the XTX
(2^29) never parts.
Lane commits: 9fbf7d3c14, 7f7f3ad95e, 9a745ffb3c, 740e9e43dd, 628264de17.
|
||
|
|
b7053280de |
RUNTIME 2346: 4:2:2 textures over IOSurface planes: an image of their texels, decoded from the pairs in place
A GBGR422 or BGRG422 texture made over a buffer's bytes (Buffer::new_texture_with_iosurface_plane,
a CoreVideo 2vuy or yuvs plane, over a Shared buffer or a no-copy buffer's host pages) had no
decoded twin: twins are attached only to textures whose image is their own for good, so every
dispatch or draw that read or sampled it was refused, with a "needs R8G8B8A8_UNORM SampledImage"
line naming a format every device samples.
Such a texture is now an R8G8B8A8_UNORM image of its texels, the converted shadow a two-plane
YCbCr texture over planes already is (ShadowSource::Converted, its conversion now an enum of the
planes' and the pairs'): its copy in, before the first command of a command buffer that reads it
and after a command wrote the bytes, is one dispatch of the new bind::chroma_convert_module that
reads the pairs where they lie, at any byte of their VkBuffer, through one storage-buffer binding,
and writes Metal's texels (ChromaDecode, exact) through the image's R32_UINT view. Copies, blits
and CPU calls keep moving the plane's bytes. Where the device converts the pairs' format with
Metal's reconstruction (MoltenVK), the copy in is that conversion instead: the plane's rows copied
into the pairs' image, sampled through the conversion (chroma_sample_module) into a scratch,
copied into the image; announced decoded-texel-precision at the copy in's planning. The set binds
the buffer's VkBuffer, so the planning makes it again after a rebind gave the buffer another one,
and each command buffer holds the set it took. The placement query answers OtherShape. A plane
the window cannot take (past maxStorageBufferRange, a last word past the buffer, rows that share
bytes, texels past the buffer; with the device's conversion, a first byte or rows off 4 bytes)
keeps the carrier, its reads refused; FAST-PATHS records it as a known gap.
Per frame, per texture (w x h texels): before, no read ran at all; the texture was an R8G8_UNORM
carrier of the plane, 2 bytes a texel. Now no byte is copied: one dispatch reads the w*h*2 bytes
of pairs in place and writes w*h*4 bytes of texels (1920x1080: 4147200 read, 8294400 written).
Memory: one R8G8B8A8_UNORM image, w*h*4 bytes (1920x1080: 8294400), in the carrier's place; with
the device's conversion also the pairs' image (w*h*2) and the scratch (w*h*4), and per copy in a
w*h*2 copy in and a w*h*4 copy out. Announced carried-decoded-twin (an existing kind) with that
cost. No new Degradation kind, no new WorkCounts field.
A carrier's binding without a twin is now refused NotImplemented(Format) naming the texture's
format (pvrtc::holds_for_copies), not a need of the twin's view format.
Public surface: metal2vulkan::bind::{chroma_convert_module, ChromaConvertModule} added
(api_signatures.tsv blessed, api_surface table); docs/REFUSALS.md regenerated (one more
binding_view site of Format).
Tests: the in-place kernel against ChromaDecode's decode under the interpreter (both orders, first
bytes off a word, odd sizes, rows apart); a carrier's binding refusal (binding_view unit test);
a device test of both formats over a Shared buffer and over host pages reading Metal's measured
bar values (an Apple M3 Max, macOS 27.0.1) and Metal's decode of a random frame written on the
CPU before the next command buffer, OtherShape from the placement query, and the device's
conversion counted and announced where it converts. Verification jobs follow in the lane report.
Evidence (lane jobs): msi m3-max-32240 at 94f603bf35, --cfg m2v_cpu_icd on llvmpipe: 130/130 touched tests, clippy -D warnings 0;
the device test fails without the fix (placement not OtherShape, the read's dispatch refused). PHOENIX gem10 m3-max-32260
(archive m3-max-32241): all 4 cases (GBGR422/BGRG422 over a Shared buffer and over host pages) "Metal's texels, exact"
for the M3's measured bars and a random CPU-written frame; ycbcr_device, ycbcr_refresh, twin_reads 7/7. MoltenVK (device form)
run on the M3 follows.
Lane commits: 735234d5f4, d59f44baa6, 94f603bf35.
|
||
|
|
43bb61c60e |
RUNTIME 2344: Runtime: a command queue on the copy engine, and buffer copies merged into runs
Device::new_command_queue_for_copies() answers a CommandQueue whose command buffers submit to the device's copy engine (the staging queue's family of transfers alone), or None where the device has none to give (MoltenVK, lavapipe, RADV by default, a copy engine of one queue, an adopted device). Its VkQueue is the copy engine's third queue where it has one, else the fill queue's, whose submissions then take that QueueSlot's lock: NVIDIA's copy engine has two queues, staging's and fill's, and staging must wait for no work in flight. The slot is the last of the device's VkQueues, after presenting's; its family stays out of image sharing (buffers already share it as the staging queue's family, so no ownership transfer is recorded). Its command buffers take blit encoders alone, and of their commands buffer copies, fills and fences: other encoders and blit commands are refused (Invalid, Problem::CopyQueue(CopyQueueProblem::Encoder | Command)), as is a caller's VkBuffer not concurrent with the copy family (Buffer). A copy batch takes buffers' fills alone from first work. Barriers on its VkQueue name the copy family's reads (Barrier::record_reading), not the primary family's, which a family of transfers alone may not name beside ALL_COMMANDS (VUID-vkCmdPipelineBarrier-dstAccessMask-02816). A blit encoder's consecutive copy_from_buffer_to_buffer calls between the same two VkBuffers that its order needs no barrier between are recorded as one vkCmdCopyBuffer of many regions (copy_run.rs), on every queue; counted as WorkCounts::buffer_copies_merged. Batches on the copy slot are counted as WorkCounts::copy_queue_batches. Verified: not yet built (first build job follows). Also in this landing: - Copy queue: docs, and the device test's None answer checked against the device - Copy queue: keep the copy queue's place alive while the families are counted Evidence: lavapipe 425/425 (m3-max-32049), clippy m2v_cpu_icd and m2v_gpu -D warnings (32049, 32053); XTX m3-max-32073: default RADV answers None; RADV_PERFTEST=transfer_queue: 1 batch on the copy engine, 63 of 64 row copies merged, sync file signalled, bytes right, refusals typed, validation layer silent. The derived API table and docs/REFUSALS.md were re-derived on the merged tree (winport's #[cfg(unix)] gates landed beside copyq). |
||
|
|
ec0be064d0 |
RUNTIME 2342, SEMANTICS 2122: Texture buffers read through argument buffers sit in texel-buffer heap classes
A pipeline whose argument buffers hold texture buffers was refused with ArgumentBufferTextures (NotImplemented, no location): the translator's heap layout (lower/texture/slot.rs declare_heap) had no set-1 class for a texture_buffer member, so SPIRV-Cross-shaped tier-2 argument buffers (descriptor sets as [[buffer(n)]] structs with texture_buffer, texture2d and sampler members) could not be made, on any device. - Set 1 gains texel-buffer heap classes: UNIFORM_TEXEL_BUFFER for read, formatless STORAGE_TEXEL_BUFFER for read_write and write. The class follows the facts' texture type. - DescriptorCaps gains update_after_bind_uniform_texel_buffer and update_after_bind_storage_texel_buffer; where a device lacks them a typed needs_any_of names the missing features. Non-uniform texel-buffer indexing and the without-format read/write needs are checked as for images; link counts STORAGE_TEXEL_BUFFER with the images against the update-after-bind limits. - New public bind::heap::HeapElement::TexelBuffer(vk::Format). - The runtime writes each live texture buffer's texel view at its resource ID, with a neutral texel view at element 0; a gone texture buffer's Texels stay alive until its tickets clear. A texture buffer whose bytes cannot be viewed in place (staged, tail-viewed, offset off minTexelBufferOffsetAlignment, past maxTexelBufferElements, swizzled, or a non-direct format) reads the neutral and is announced through the existing UnnamedTextureUnviewable. No new Degradation kind. - docs/REFUSALS.md and api_signatures.tsv regenerated. Test: runtime_lane::argument_texel_buffers::a_texture_buffer_in_an_argument_buffer_is_read_in_both_stages (an owned fixture in SPIRV-Cross's shape): vertex and fragment read a texture_buffer member of a set-0 argument buffer, the fragment also samples a set-1 texture2d through the sampler beside it; every pixel must equal texel[1] + texel[4]*tint + albedo. Verified: lavapipe with the validation layer, m3-max-31658 at 6626eeaff3: pass. Control m3-max-31636 (the fixture and test at the base, without the fix): fails with exactly the ArgumentBufferTextures NotImplemented refusal. |