diff --git a/crates/metal2vulkan-runtime/src/pipeline/dispatch_making.rs b/crates/metal2vulkan-runtime/src/pipeline/dispatch_making.rs index 4dc6ca5bd..38ece331d 100644 --- a/crates/metal2vulkan-runtime/src/pipeline/dispatch_making.rs +++ b/crates/metal2vulkan-runtime/src/pipeline/dispatch_making.rs @@ -13,14 +13,14 @@ //! alike, its pass recorded later (`render/pending_tile.rs`). Its specialized notices are announced //! at the dispatch that hands the making over, on the program's thread, naming what it binds: the //! pool decides nothing the program sees. -//! - **The predicted region, made at the creation.** Metal compiles a compute state inside -//! `newComputePipelineState`, and its first dispatch compiles nothing. The creation makes the -//! `VkPipeline` of the region a first dispatch is predicted to take -//! ([`Variant::make_at_creation`]): a `dispatchThreadgroups:` on the base variant, planned for -//! nothing bound but Metal's default sampler at each runtime sampler slot that does not compare -//! (as a render state's prediction, `predicted.rs`), at the descriptor's -//! `requiredThreadsPerThreadgroup` where it states one, else at the size Apple's guide to -//! threadgroup sizes ("Calculating Threadgroup and Grid Sizes") computes from the state +//! - **The predicted region, made at the creation, where the request states its threadgroup.** +//! Metal compiles a compute state inside `newComputePipelineState`, and its first dispatch +//! compiles nothing. Where the descriptor states `requiredThreadsPerThreadgroup`, that size is +//! the threadgroup every dispatch of the state must have, so the local size of a first +//! dispatch's region is part of the request itself. The creation then makes that +//! region's `VkPipeline` ([`Variant::make_at_creation`]): a `dispatchThreadgroups:` on the base +//! variant, planned for nothing bound but Metal's default sampler at each runtime sampler slot +//! that does not compare (as a render state's prediction, `predicted.rs`), at that size //! ([`predicted_threads`]). A dispatch whose region has that key takes the pipeline made; one //! whose key differs from it only where it reads a uniform view at its bind offset alone takes //! it too, at once, while its own key is made on the pool, nothing waiting for it, as a draw @@ -32,18 +32,28 @@ //! drop, which Metal's never does. Its specialized notices wait for the first dispatch that //! takes it, which announces them naming what it binds. A creation inside a host step, a tile //! function's state and a stand-in compile make nothing here. -//! - **What the prediction cannot know.** The guess is the threadgroup size and nothing else, so a -//! state whose dispatches choose their own size pays its per-pipeline compile twice: once here -//! and once on the pool. A creation cannot know the size, and no better guess reaches it. It -//! cannot know either whether the dispatch will be a `dispatchThreads:` with a ragged edge, -//! whose interior and edge regions are two local sizes and so two keys of which the prediction -//! can hold at most one; nor what the dispatch will bind, which decides its variant +//! - **Where the request states no threadgroup, the creation predicts nothing**, because nothing +//! in the request answers what the dispatch will ask for. The local size is the dispatch's own +//! call, and a size guessed from the state instead -- Apple's guide to threadgroup sizes +//! ("Calculating Threadgroup and Grid Sizes") computes `threadExecutionWidth` across by +//! `maxTotalThreadsPerThreadgroup / threadExecutionWidth` down, which is `[32, 32, 1]` on an M3 +//! -- is a `VkPipeline` only a dispatch that happens to choose it can take. **Measured over the +//! whole conformance suite on an M3 Max, one in-set run of all 1,121 cases: 141 such pipelines +//! made in 106 cases and 0 taken by any dispatch**, while the same run's render prediction +//! (`predicted.rs`) was taken 764 times in 794. The committed recordings' own 8-run census +//! reads the same thing from the other side: 0 of 461 taken over the 277 rows that dispatch and +//! do not draw (`cost.rs`'s `the_creation_prediction`). So the guess is not made, and the first +//! dispatch hands its region's making to the pool as it did before, waiting for nothing. +//! - **What the prediction still cannot know**, where the request does state the threadgroup. It +//! cannot know whether the dispatch will be a `dispatchThreads:` with a ragged edge, whose +//! interior and edge regions are two local sizes and so two keys of which the prediction can +//! hold at most one; nor what the dispatch will bind, which decides its variant //! (`VariantKey::extended_range` and `VariantKey::swizzled_storage` read the bound texture's //! pixel format and swizzle, `bind::plan::resources`), so for a kernel whose dispatches all //! bind a texture the prediction's base variant is one no dispatch takes and its stage's -//! `VkShaderModule` is a module of its own. Where the dispatches do follow Apple's guide the -//! prediction holds and the pool makes nothing. `creation_pipelines_made` against -//! `creation_pipelines_drawn` is the measure of it. +//! `VkShaderModule` is a module of its own. `creation_dispatch_pipelines_made` against +//! `creation_dispatch_pipelines_drawn` is the measure of it, apart from the render +//! prediction's own pair. //! - **Kept by the state** (`piece_holds.rs`). What a piece needs (its variant and its making's //! ticket) is kept by the state, never by the pool's thread; the state's release stops a piece //! not started, its making failing, and a dispatch that took it (of another state of the variant) @@ -205,8 +215,9 @@ impl Variant { /// Make, on this thread, the `VkPipeline` of the region a first dispatch of a state of /// `descriptor` on this variant, its base, is predicted to take (the module docs), where no /// caller made or began it: its notices wait for the first dispatch that takes it. A - /// prediction the plan refuses, or that runs on another variant, makes nothing; a failed - /// making is not kept and refuses nothing, its dispatch meeting it as before. + /// descriptor that requires no threadgroup size predicts no region at all, and a prediction + /// the plan refuses or that runs on another variant makes nothing; a failed making is not + /// kept and refuses nothing, its dispatch meeting it as before. pub(super) fn make_at_creation(&self, device: &Device, descriptor: &ComputePipelineDescriptor) { if crate::exit_guard::in_host_step() { return; @@ -232,23 +243,22 @@ impl Variant { /// The key of the region of the predicted first dispatch of `descriptor` on this variant /// (the module docs): one `dispatchThreadgroups:` threadgroup of [`predicted_threads`], - /// planned for [`predicted_bindings`]. `None` where it plans or instantiates no region, or - /// runs on another variant (a threadgroup the kernel's simd tier cannot run whole). + /// planned for [`predicted_bindings`]. `None` where `descriptor` requires no threadgroup + /// size, so the request names none to predict; and where it plans or instantiates no region, + /// or runs on another variant (a threadgroup the kernel's simd tier cannot run whole). fn predicted_region( &self, device: &Device, descriptor: &ComputePipelineDescriptor, ) -> Option { + // The threadgroup first, before anything is planned: where the request states none there + // is no region to predict, and the plan below would be built for a key nobody makes. + let threads_per_group = predicted_threads(descriptor.required_threads_per_threadgroup)?; let state = predicted_bindings(&self.pipeline); let plan = self.plan(device, &state.shape()).ok()?; - let info = &self.pipeline.metal_info; let dispatch = Dispatch::Threadgroups { groups: [1, 1, 1], - threads_per_group: predicted_threads( - descriptor.required_threads_per_threadgroup, - info.thread_execution_width, - info.max_total_threads_per_threadgroup, - ), + threads_per_group, }; if plan.dispatch_variant(&dispatch).ok()? != self.key { return None; @@ -312,19 +322,12 @@ impl ComputePipelineState { /// The threads per threadgroup a first dispatch of a state is predicted to take (the module /// docs): its descriptor's `requiredThreadsPerThreadgroup` (`required`) where it states one, -/// which every dispatch takes; else the size Apple's guide to threadgroup sizes computes from the -/// state's `threadExecutionWidth` (`width`) and `maxTotalThreadsPerThreadgroup` (`total`), -/// `width` threads across by `total / width` down (one row of `total` where that is narrower -/// than `width`). -fn predicted_threads(required: Option<[u32; 3]>, width: u32, total: u32) -> [u32; 3] { - if let Some(required) = required.filter(|size| size.iter().all(|&axis| axis > 0)) { - return required; - } - let (width, total) = (width.max(1), total.max(1)); - match total < width { - true => [total, 1, 1], - false => [width, total / width, 1], - } +/// which is then the threadgroup of every dispatch of the state; `None` where it states none +/// (Metal's all-zero size requires nothing), because the size is then the dispatch's own call and +/// no part of the request answers it. A size with one zero axis never reaches here: the creation +/// refuses it before the compile (`additions::check_kernel`, `RequiredThreadsProblem::EmptyAxis`). +fn predicted_threads(required: Option<[u32; 3]>) -> Option<[u32; 3]> { + super::additions::required_size(required) } /// What the predicted first dispatch of `pipeline`'s kernel binds (the module docs): Metal's @@ -349,16 +352,16 @@ fn predicted_bindings(pipeline: &ComputePipeline) -> BindState { mod tests { use super::predicted_threads; - /// The predicted threadgroup: a required size as it stands; else Apple's guide's - /// `threadExecutionWidth` by `maxTotalThreadsPerThreadgroup / threadExecutionWidth`, or one - /// row of the total where that is narrower than the width. + /// The predicted threadgroup is the required size and nothing else: a state whose descriptor + /// requires none predicts no region at all, so the creation makes no `VkPipeline` for a + /// threadgroup the request never named. Measured over the whole conformance suite, such a + /// guess was taken by 0 dispatches of 141 made (the module docs). #[test] - fn the_predicted_threadgroup_is_the_required_one_or_apple_s_guide_s() { - assert_eq!(predicted_threads(Some([8, 8, 1]), 32, 1024), [8, 8, 1]); - assert_eq!(predicted_threads(None, 32, 1024), [32, 32, 1]); - assert_eq!(predicted_threads(None, 32, 896), [32, 28, 1]); - assert_eq!(predicted_threads(None, 32, 16), [16, 1, 1]); - // Metal's zero size requires nothing. - assert_eq!(predicted_threads(Some([0, 0, 0]), 32, 256), [32, 8, 1]); + fn the_predicted_threadgroup_is_the_required_one_and_nothing_is_predicted_without_one() { + assert_eq!(predicted_threads(Some([8, 8, 1])), Some([8, 8, 1])); + assert_eq!(predicted_threads(Some([1, 1, 1])), Some([1, 1, 1])); + assert_eq!(predicted_threads(None), None); + // Metal's all-zero size requires nothing, so it predicts nothing either. + assert_eq!(predicted_threads(Some([0, 0, 0])), None); } } diff --git a/crates/metal2vulkan-runtime/src/tests/creation_prediction_kinds.rs b/crates/metal2vulkan-runtime/src/tests/creation_prediction_kinds.rs index 85c32c301..dc5bfc072 100644 --- a/crates/metal2vulkan-runtime/src/tests/creation_prediction_kinds.rs +++ b/crates/metal2vulkan-runtime/src/tests/creation_prediction_kinds.rs @@ -18,6 +18,19 @@ //! predicts nothing at all would read zero for both kinds and make the "the other kind did not //! move" assertion vacuous. //! +//! # Which compute creations predict at all +//! +//! A compute state predicts a region only where its descriptor states +//! `requiredThreadsPerThreadgroup`, which Metal then makes the threadgroup of every dispatch of +//! the state (`pipeline/dispatch_making.rs`). So the compute leg states one, and a third leg +//! creates the same kernel's state **without** one and holds the kind's count still: a guess at +//! the threadgroup where the request names none was taken by 0 dispatches of 141 made over the +//! whole conformance suite, so it is not made. +//! +//! Every reading here is a delta across one creation on this test's own device, never a +//! device-wide total: a total would be moved by anything else the process did and would pass with +//! the behaviour put back. +//! //! The assertion is a count, never a time: it is a fact of the structure, so it holds on any host //! under any load. The device takes a shader cache directory of its own, empty, so no run reads a //! pipeline an earlier run stored. @@ -30,6 +43,7 @@ use super::blit_holds::{device, Scratch}; use super::descriptor_key_once::descriptor; use crate::{PipelineOptions, WorkCounts}; +use metal2vulkan::pipeline::{ComputePipelineDescriptor, StageSource}; use std::path::Path; /// The two predictions' makings, and the whole count: render made, dispatch made, all made. @@ -82,14 +96,20 @@ fn the_render_and_dispatch_predictions_are_counted_apart() { ) .new_function_with_name("scale_and_offset") .unwrap(); + // The threadgroup every dispatch of the state must take, so the region of its first dispatch + // is part of the request and the creation makes that region's pipeline. + let mut descriptor = + ComputePipelineDescriptor::new(StageSource::Function(function.function_descriptor())); + descriptor.required_threads_per_threadgroup = Some([32, 1, 1]); let _compute = device - .new_compute_pipeline_state_with_function(&function, &options) + .new_compute_pipeline_state(&descriptor, &options) .unwrap(); let after_compute = made(&device.work_counts()); let compute = moved(after_render, after_compute); assert!( compute[1] > 0, - "a compute creation must make its predicted pipeline at all, not {} times", + "a compute creation whose descriptor requires a threadgroup must make its predicted \ + pipeline at all, not {} times", compute[1] ); assert_eq!( @@ -102,4 +122,24 @@ fn the_render_and_dispatch_predictions_are_counted_apart() { "the whole count moved {} where the dispatch prediction moved {}", compute[2], compute[1] ); + + // And the same kernel with no required threadgroup: nothing in the request says what the + // dispatch will ask for, so nothing is predicted. Read as the delta across this one creation. + let _unrequired = device + .new_compute_pipeline_state_with_function(&function, &options) + .unwrap(); + let after_unrequired = made(&device.work_counts()); + let unrequired = moved(after_compute, after_unrequired); + assert_eq!( + unrequired[1], 0, + "a compute creation whose descriptor requires no threadgroup made {} predicted \ + pipeline(s) for a threadgroup the request never named; such a guess was taken by 0 \ + dispatches of 141 made over the whole conformance suite", + unrequired[1] + ); + assert_eq!( + unrequired[2], 0, + "the whole count moved {} over a creation that predicts nothing", + unrequired[2] + ); } diff --git a/crates/metal2vulkan-runtime/src/tests/uniform_bind_offsets.rs b/crates/metal2vulkan-runtime/src/tests/uniform_bind_offsets.rs index 8371f56d6..a53c2ded6 100644 --- a/crates/metal2vulkan-runtime/src/tests/uniform_bind_offsets.rs +++ b/crates/metal2vulkan-runtime/src/tests/uniform_bind_offsets.rs @@ -19,12 +19,14 @@ use super::blit_holds::{device, Scratch, WAIT}; use crate::{ - BlitOption, Buffer, CommandQueue, Device, LoadAction, Origin, PipelineOptions, - RenderPassDescriptor, RenderPipelineState, ResourceOptions, ScissorRect, Size, StoreAction, - Texture, TextureDescriptor, + BlitOption, Buffer, CommandQueue, ComputePipelineState, Device, LoadAction, Origin, + PipelineOptions, RenderPassDescriptor, RenderPipelineState, ResourceOptions, ScissorRect, Size, + StoreAction, Texture, TextureDescriptor, }; use metal2vulkan::metal::{PixelFormat, PrimitiveType, TextureUsage}; -use metal2vulkan::pipeline::{ColorAttachmentDescriptor, RenderPipelineDescriptor, StageSource}; +use metal2vulkan::pipeline::{ + ColorAttachmentDescriptor, ComputePipelineDescriptor, RenderPipelineDescriptor, StageSource, +}; use std::path::Path; /// The target's side, in pixels. @@ -77,6 +79,25 @@ fn state(device: &Device) -> RenderPipelineState { .unwrap() } +/// The threadgroup a kernel state of [`kernel_state`] requires, and so the one its creation +/// predicts a region for: 32 by 1 by 1, which the Vulkan floor's +/// `maxComputeWorkGroupInvocations` of 128 allows on any venue and the kernel runs whole. +const PREDICTED_THREADS: [u32; 3] = [32, 1, 1]; + +/// A compute state of `function` whose descriptor requires [`PREDICTED_THREADS`] per threadgroup. +/// +/// A creation predicts a region only where the descriptor requires a threadgroup, since nothing +/// else in the request says what a dispatch will ask for (`pipeline/dispatch_making.rs`), so a +/// test of the prediction states one. +fn kernel_state(device: &Device, function: &crate::Function) -> ComputePipelineState { + let mut descriptor = + ComputePipelineDescriptor::new(StageSource::Function(function.function_descriptor())); + descriptor.required_threads_per_threadgroup = Some(PREDICTED_THREADS); + device + .new_compute_pipeline_state(&descriptor, &PipelineOptions::default()) + .unwrap() +} + fn constants() -> Vec { (0..FLOATS) .flat_map(|i| (i as f32 / 255.0).to_le_bytes()) @@ -492,7 +513,7 @@ fn first_draws_make_no_second_pipeline_where_views_are_read_at_their_residual() /// Whether a compute state's creation-time prediction (`pipeline/dispatch_making.rs`) can serve a /// `dispatchThreads:`, the call Metal programs reach for. The prediction's region is a -/// `dispatchThreadgroups:` of one threadgroup of Apple's guide's size; this dispatches +/// `dispatchThreadgroups:` of one threadgroup of the size the descriptor requires; this dispatches /// `dispatchThreads:` over a grid of exactly that size, so the threads per threadgroup, the /// bindings and the specialization are the predicted ones and only the call differs. The counts /// say which: a prediction drawn, or a region handed to the pool and a second `VkPipeline` made. @@ -505,21 +526,15 @@ fn a_dispatch_threads_over_the_predicted_threadgroup_reads_what_the_prediction_s .new_function_with_name("ubo_offsets_kernel") .unwrap(); let before = idle(&device); - let state = device - .new_compute_pipeline_state_with_function(&function, &PipelineOptions::default()) - .unwrap(); + let state = kernel_state(&device, &function); let created = idle(&device); assert_eq!( created.creation_pipelines_made - before.creation_pipelines_made, 1, "the creation made its predicted region's pipeline" ); - let width = state.thread_execution_width(); - let threads = Size::new( - u64::from(width), - u64::from(state.max_total_threads_per_threadgroup() / width), - 1, - ); + let [width, height, depth] = PREDICTED_THREADS; + let threads = Size::new(u64::from(width), u64::from(height), u64::from(depth)); let data = constants(); let constants = device .new_buffer_with_bytes(&data, ResourceOptions::shared()) @@ -552,14 +567,14 @@ fn a_dispatch_threads_over_the_predicted_threadgroup_reads_what_the_prediction_s } /// A compute state's creation makes the `VkPipeline` of its predicted region, a threadgroup of -/// Apple's guide's size (`pipeline/dispatch_making.rs`), as Metal compiles at creation and its -/// first dispatch compiles nothing. With the device's pool held, a dispatch of that size reading -/// its constants at offset 0 and one reading them as inline bytes are recorded at once, and their -/// command buffer completes while the pool is still held: where the device reads every uniform -/// view at its residual their key is the creation's, and nothing is made, begun or handed over; -/// elsewhere their key reads the view at its bind offset alone, and they take the creation's -/// pipeline, its residual form, while their own key, handed to the pool once, is made there. The -/// kernel reads its constants either way. +/// the size its descriptor requires (`pipeline/dispatch_making.rs`), as Metal compiles at +/// creation and its first dispatch compiles nothing. With the device's pool held, a dispatch of +/// that size reading its constants at offset 0 and one reading them as inline bytes are recorded +/// at once, and their command buffer completes while the pool is still held: where the device +/// reads every uniform view at its residual their key is the creation's, and nothing is made, +/// begun or handed over; elsewhere their key reads the view at its bind offset alone, and they +/// take the creation's pipeline, its residual form, while their own key, handed to the pool once, +/// is made there. The kernel reads its constants either way. #[test] fn a_compute_state_s_creation_makes_its_first_dispatch_s_pipeline() { let scratch = Scratch::new("uniform-kernel-creation"); @@ -569,9 +584,7 @@ fn a_compute_state_s_creation_makes_its_first_dispatch_s_pipeline() { .new_function_with_name("ubo_offsets_kernel") .unwrap(); let before = idle(&device); - let state = device - .new_compute_pipeline_state_with_function(&function, &PipelineOptions::default()) - .unwrap(); + let state = kernel_state(&device, &function); let created = idle(&device); assert_eq!( ( @@ -581,12 +594,8 @@ fn a_compute_state_s_creation_makes_its_first_dispatch_s_pipeline() { (1, 1), "pipelines the creation made" ); - let width = state.thread_execution_width(); - let threads = Size::new( - u64::from(width), - u64::from(state.max_total_threads_per_threadgroup() / width), - 1, - ); + let [width, height, depth] = PREDICTED_THREADS; + let threads = Size::new(u64::from(width), u64::from(height), u64::from(depth)); let data = constants(); let constants = device .new_buffer_with_bytes(&data, ResourceOptions::shared()) diff --git a/crates/metal2vulkan-validation/runtime-sources.sha256 b/crates/metal2vulkan-validation/runtime-sources.sha256 index 686a078ad..8ffc6c0f7 100644 --- a/crates/metal2vulkan-validation/runtime-sources.sha256 +++ b/crates/metal2vulkan-validation/runtime-sources.sha256 @@ -1 +1 @@ -7cfb24c9c96cdb2f06a9b0480a3f2f7c7daec3a474bb018626c77c660b577b69 +122e19a863f040e8c70bf685e5e2957ed36fb700704fa8bb81ad6e2a1011b26e diff --git a/crates/metal2vulkan/src/cache/mod.rs b/crates/metal2vulkan/src/cache/mod.rs index 669af9721..344079f13 100644 --- a/crates/metal2vulkan/src/cache/mod.rs +++ b/crates/metal2vulkan/src/cache/mod.rs @@ -93,7 +93,7 @@ pub const ARTIFACT_FORMAT_VERSION: u32 = 450; /// changes no behaviour, and then updates that hash alone with the commit saying why, or changes /// behaviour and also bumps this version. The commit that bumps it says what changed; this comment /// keeps no history. -pub const RUNTIME_VERSION: u32 = 1627; +pub const RUNTIME_VERSION: u32 = 1630; /// The digest of the sources this build of the crate was compiled from: SHA-256, as lowercase hex, /// of the manifest, the build script, and exactly the files the crate roots' module tree compiles diff --git a/crates/metal2vulkan/tests/api_signatures.tsv b/crates/metal2vulkan/tests/api_signatures.tsv index 9c7da5d77..f53474ef4 100644 --- a/crates/metal2vulkan/tests/api_signatures.tsv +++ b/crates/metal2vulkan/tests/api_signatures.tsv @@ -2728,6 +2728,7 @@ field metal2vulkan-runtime::WorkCounts.provoking_listed_draws pub provoking_list field metal2vulkan-runtime::WorkCounts.query_result_copies_recorded pub query_result_copies_recorded: u64 field metal2vulkan-runtime::WorkCounts.queue_drains pub queue_drains: u64 field metal2vulkan-runtime::WorkCounts.queue_submissions pub queue_submissions: u64 +field metal2vulkan-runtime::WorkCounts.queues_sharing_a_vk_queue pub queues_sharing_a_vk_queue: u64 field metal2vulkan-runtime::WorkCounts.reading_draws_snapshotted pub reading_draws_snapshotted: u64 field metal2vulkan-runtime::WorkCounts.reencodes_refused pub reencodes_refused: u64 field metal2vulkan-runtime::WorkCounts.registrations_waited pub registrations_waited: u64 diff --git a/docs/API.md b/docs/API.md index 75a06ebd5..7ef66e4f6 100644 --- a/docs/API.md +++ b/docs/API.md @@ -3128,12 +3128,16 @@ each item named states the rule in full. `residual_form_makings`). On MoltenVK every key is its residual form (the two forms measured alike there), so a state's draws at every bind offset take the one pipeline its creation made. - **A dispatch's `VkPipeline` is made while the dispatch goes on**, the same way: one pipeline per - threadgroup size and edge region, made on the pool. A compute state's creation makes one first: - its predicted region's, a threadgroup of the descriptor's `requiredThreadsPerThreadgroup`, else - of `threadExecutionWidth` by `maxTotalThreadsPerThreadgroup / threadExecutionWidth` (Apple's - guide's size), each uniform view read at its residual; a dispatch of that region takes it, as - does one whose key differs only in reading a view at its bind offset alone while its own is made - (`WorkCounts::creation_pipelines_made`, `creation_pipelines_drawn`). A tile dispatch's pipeline + threadgroup size and edge region, made on the pool. A compute state whose descriptor states + `requiredThreadsPerThreadgroup` -- the threadgroup every dispatch of the state must have -- makes + one at its creation: its predicted region's, at that size, each uniform view read at its + residual; a dispatch of that region takes it, as does one whose key differs only in reading a + view at its bind offset alone while its own is made + (`WorkCounts::creation_dispatch_pipelines_made`, `creation_dispatch_pipelines_drawn`). A state + whose descriptor requires no threadgroup size makes none at its creation: the size is the + dispatch's own call and nothing in the request answers it, and a pipeline guessed from the state + instead was taken by no dispatch at all over the whole conformance suite (141 made, 0 taken, + against the render-side prediction's 764 of 794 in the same run). A tile dispatch's pipeline is made on the pool too, its pass recorded once it is made, the making ranked from the dispatch as one a committed command buffer waits for (`WorkCounts::tile_pipelines_pooled`); a failed making fails the command buffer, as a draw's does, `FailedPipeline` naming the dispatch by its diff --git a/docs/FAST-PATHS.md b/docs/FAST-PATHS.md index 8f296aba5..6d497bc1b 100644 --- a/docs/FAST-PATHS.md +++ b/docs/FAST-PATHS.md @@ -285,6 +285,18 @@ recorded here. Open differences from Metal that no note announces yet, and runtime costs still above the driver's. Each is open work. +- **Command queues past the device's `VkQueue`s share one, so one's command buffers wait behind + another's whole command buffer where Metal's wait only inside one command.** Measured on Metal's + own API on an Apple M3 Max: a side command queue completed one command buffer behind a single + 2.50 s dispatch, waiting its whole duration, and 11,335 to 12,992 behind the same 2.5 s of work + as 256 dispatches, none waiting past 3.8 ms. So Metal holds an unrelated queue for one long + command and for nothing else, while one `VkQueue` runs its submissions in order and cannot + schedule a sharing queue out of them. A device now lends the round robin every queue its families + have past the two reserved for presenting, at least four and at most sixteen, which on a graphics + family of sixteen gives fourteen; a device whose families have none to spare -- MoltenVK's four + families of one queue, a single-graphics-queue device -- still shares, and the sharing is counted + (`WorkCounts::queues_sharing_a_vk_queue`). Not announced. + - **GPU writes into read-only memory are dropped only through a bound buffer slot.** A shader's stores through a slot bound to memory whose GPU writes Metal drops (no-copy memory of its private option bit 24, or pages replaced read-only) are now dropped in the shader, gated on a uniform @@ -493,10 +505,17 @@ driver's. Each is open work. every one, because the footprint is arithmetic over the descriptor and no image decides it. A texture, a view, a copy, a read and a write of one stay refused `NotImplemented(Format)`: no Vulkan format holds the bytes (an ASTC 4x2 or 8x4 block) or their reads and writes are not - measured yet. The two packed 10-bit ones are the only members plain Metal makes a texture of in - `Memoryless` storage and in no mode that holds memory (an Apple M3 Max, macOS 27.0.1, - `conformance/probes/packed10_texture_alone.m`), so that one is this crate's refusal of the format - and not Metal's nil. A **multisample** descriptor of one is refused there too, its layout + measured yet. Plain Metal lays out no image storage for the two packed 10-bit + ones and makes a texture from every creator that needs none -- a placement heap's offset, the + shared creator in `Private`, a buffer's and an IOSurface plane's own bytes, and `Memoryless` -- + so the refusal from each of those is this crate's own and not Metal's nil; the device's own + creator and an automatic heap, the two that would have to lay the image out, answer nil (an Apple + M3 Max, macOS 27.0.1, `conformance/probes/packed10_texture_alone.m`). Their reads are a stream of + 10-bit codes that no Vulkan format holds, and none of that is built: no image is made, so + sampling, a blit, `getBytes:` and a render pass of one are all unbuilt behind the same refusal. + The code layout is derived in `metal/format/packed_codes.rs` and is **not** held to a texel: the + two measured anchors fix codes 0 and 1 only, and a padded 32-bit word and an unpadded bitstream + first differ at `R10Unorm_PACKED`'s texel 3, which nothing has measured. A **multisample** descriptor of one is refused there too, its layout unmeasured: Metal's validation may stop such a descriptor, so none was asked. `ARGB8Unorm_sRGB` is the one of them whose gap is not the bytes: they are `ARGB8Unorm`'s, which this crate holds, and no Vulkan format applies the sRGB transfer function to the three channels