diff --git a/crates/metal2vulkan-harness/Cargo.toml b/crates/metal2vulkan-harness/Cargo.toml index 239a57b21..542ef4e6b 100644 --- a/crates/metal2vulkan-harness/Cargo.toml +++ b/crates/metal2vulkan-harness/Cargo.toml @@ -5,7 +5,7 @@ edition.workspace = true rust-version.workspace = true license.workspace = true authors.workspace = true -description = "The runtimes' compute harness: one set of Metal compute workloads through each runtime's Metal-shaped API, checked and timed" +description = "The runtime's compute harness: one set of Metal compute workloads through the runtime's Metal-shaped API, checked and timed" # Dev-only: never published. publish = false autobins = false @@ -21,11 +21,8 @@ name = "harness" path = "src/bin/harness.rs" [dependencies] -# The translator: the library of AIR bitcode the old runtime takes (`old.rs`), and the function -# constant values both runtimes take (`plan.rs`). +# The translator: the function constant values the runtime takes (`plan.rs`). metal2vulkan = { path = "../metal2vulkan" } -# The old runtime, behind the harness's traits in `old.rs` alone. -metal2vulkan-runtime = { path = "../metal2vulkan-runtime" } # The new runtime, behind the harness's traits in `rt.rs` alone, and the Vulkan types it chooses # a physical device by. metal2vulkan-rt = { path = "../metal2vulkan-rt" } diff --git a/crates/metal2vulkan-harness/src/bin/harness.rs b/crates/metal2vulkan-harness/src/bin/harness.rs index 61acd78de..93317adf7 100644 --- a/crates/metal2vulkan-harness/src/bin/harness.rs +++ b/crates/metal2vulkan-harness/src/bin/harness.rs @@ -2,7 +2,7 @@ //! runtime or several, checked, then timed (the crate's docs). //! //! ```text -//! harness --runtime old|new[,old|new...] [--runs N] [--warmup N] [--no-settle] +//! harness --runtime new[,new...] [--runs N] [--warmup N] [--no-settle] //! [--only NAME,NAME...] [--skip NAME,NAME...] [--size NAME=N]... [--store DIRECTORY] //! [--workloads DIRECTORY --description FILE] //! ``` @@ -12,8 +12,7 @@ //! before it: `--skip 'create_*'` runs every workload but the creation ones, and //! `--only 'create_*'` those alone. A name that names no workload is an error. //! -//! Each runtime's device keeps its pipelines (the old runtime's shader cache, the new runtime's -//! cache directory) in a store of its own: `/-` under `--store`, so a +//! Each runtime's device keeps its pipelines (the runtime's cache directory) in a store of its own: `/-` under `--store`, so a //! second run on the same directory is warm, or a directory made for the run under the OS temp //! directory and removed after it, so every run is cold. Each runtime's line says whether its //! store was fresh or held files, and so does each `create_state` row. @@ -39,7 +38,7 @@ use metal2vulkan_harness::run::{ count_instructions, matrix_time, percentile, run_each, steady, CreateReport, Harness, Report, Runs, Session, Warmup, FROM_IDLE, }; -use metal2vulkan_harness::{authored, description, old, rt, Error, Failed, Result, Waits}; +use metal2vulkan_harness::{authored, description, rt, Error, Failed, Result, Waits}; use std::path::{Path, PathBuf}; use std::process::ExitCode; @@ -58,7 +57,7 @@ struct Args { description: Option, } -const USAGE: &str = "usage: harness --runtime old|new[,old|new...] [--runs N] [--warmup N] \ +const USAGE: &str = "usage: harness --runtime new[,new...] [--runs N] [--warmup N] \ [--no-settle] [--only NAME,NAME...] [--skip NAME,NAME...] [--size NAME=N]... \ [--store DIRECTORY] [--workloads DIRECTORY --description FILE]"; @@ -164,15 +163,11 @@ fn files(directory: &Path) -> usize { /// The session of the runtime named `name`, its device's pipelines kept in `store`. fn session(name: &str, authored: &[u8], store: &Path) -> Result> { match name { - "old" => Ok(Box::new(Harness::new( - old::system_default(Some(store))?, - authored, - )?)), "new" => Ok(Box::new(Harness::new( rt::system_default(Some(store))?, authored, )?)), - other => Err(format!("no runtime {other}; the runtimes are: old, new").into()), + other => Err(format!("no runtime {other}; the runtime is: new").into()), } } diff --git a/crates/metal2vulkan-harness/src/lib.rs b/crates/metal2vulkan-harness/src/lib.rs index df60b3567..6518f8a8f 100644 --- a/crates/metal2vulkan-harness/src/lib.rs +++ b/crates/metal2vulkan-harness/src/lib.rs @@ -1,12 +1,10 @@ -//! The runtimes' compute harness: one set of Metal compute workloads run through a runtime's +//! The runtime's compute harness: one set of Metal compute workloads run through the runtime's //! Metal-shaped API on one GPU, with no guest. Each workload's result is checked against a CPU -//! reference before any time is reported. It is a regression gate between the runtimes, not a -//! measure against native Metal. +//! reference before any time is reported. It is not a measure against native Metal. //! //! The traits below are the Metal compute subset the workloads call, one method per Metal call, //! with the blit encoder's copies and fill and a render encoder's draws of triangles. -//! A runtime implements them once: the old runtime in [`old`], which the cutover deletes with its -//! file, and the new runtime in [`rt`]. A workload a runtime answers with a typed refusal (a +//! The runtime implements them in [`rt`]. A workload the runtime answers with a typed refusal (a //! known gap or a device limit, [`Refused`]) is reported by name as refused, not as a failure. //! //! A workload is a [`plan::Plan`]: its buffers and their starting contents, the dispatches of one @@ -23,9 +21,8 @@ //! `draw_full` into a target of `RenderTarget` usage alone, whose texels nothing checks; //! `bind_2000` is `draw_2000` with a vertex buffer and a fragment texture set before each draw, //! each alternating between two objects. -//! Every command buffer of a workload's runs carries a scheduled handler (on the old runtime, its -//! submission handler) and a completed handler, as the consumer's command buffers do, so the times -//! hold what the runtimes do to run them. +//! Every command buffer of a workload's runs carries a scheduled handler and a completed handler, +//! as the consumer's command buffers do, so the times hold what the runtime does to run them. //! A [`run::Session`] makes its objects, checks the first run, then times the rest. The authored //! workloads ([`authored`]) are MSL kernels committed as public fixtures //! (`crates/metal2vulkan-validation/fixtures/public/harness/workloads.metal`, compiled by @@ -54,7 +51,7 @@ //! function), timed as the row's `device_first` ([`run::CreateReport::device_first_us`]). //! //! ```sh -//! cargo run --release -p metal2vulkan-harness -- --runtime old|new[,old|new...] [--runs 200] \ +//! cargo run --release -p metal2vulkan-harness -- --runtime new[,new...] [--runs 200] \ //! [--warmup 5] [--no-settle] [--only NAME,NAME...] [--skip NAME,NAME...] [--size NAME=N]... \ //! [--store DIRECTORY] [--workloads DIRECTORY --description FILE] //! ``` @@ -153,14 +150,13 @@ //! began 25 ms or more past its allocation's idle age fails the row, and they record no time. //! `export_submit_cost` records a submission's median time with no export and with 64 live //! (`none` and `exports_64`), which the matrix judges as it judges a time of one runtime: as a -//! cross-GPU outlier against the leg's base; with no old runtime's row it has no harness budget. +//! cross-GPU outlier against the leg's base. use std::ptr::NonNull; pub mod authored; mod clocks; pub mod description; -pub mod old; pub mod plan; pub mod rt; pub mod run; @@ -188,7 +184,7 @@ impl std::error::Error for Refused {} /// A workload's failure on one runtime, other than a refusal: the runtime's name and why. #[derive(Debug)] pub struct Failed { - /// The runtime's name (`old` or `new`). + /// The runtime's name (`new`). pub runtime: String, /// Why it failed. pub why: Error, @@ -444,8 +440,7 @@ pub trait CommandBuffer { /// `GPUEndTime` to the handler's start, both on the runtime's host clock, in microseconds. fn add_completed_handler(&self, handler: Box) -> Result<()>; - /// `addScheduledHandler:`; on the old runtime its submission handler, the point its consumer - /// takes as a command buffer is scheduled. + /// `addScheduledHandler:`. fn add_scheduled_handler(&self, handler: Box) -> Result<()>; } diff --git a/crates/metal2vulkan-harness/src/old.rs b/crates/metal2vulkan-harness/src/old.rs deleted file mode 100644 index f076734ce..000000000 --- a/crates/metal2vulkan-harness/src/old.rs +++ /dev/null @@ -1,604 +0,0 @@ -//! The old runtime (`metal2vulkan-runtime`) behind the harness's traits, each method its call of -//! the same name. The cutover deletes this file, its `mod` line, the `--runtime old` arm of the -//! command and the crate's dependency on the old runtime. - -use crate::plan::{self, Constant, TextureSource}; -use crate::{Code, Result, Size, Storage}; -use metal2vulkan::pipeline::{ - ColorAttachmentDescriptor, ComputePipelineDescriptor, RenderPipelineDescriptor, StageSource, -}; -use metal2vulkan_runtime as runtime; -use runtime::{ - BlitOption, CommandBufferStatus, HeapDescriptor, HeapType, Origin, PipelineOptions, - ResourceOptions, TextureDescriptor, -}; -use std::path::Path; -use std::ptr::NonNull; - -/// The old runtime's `MTLCreateSystemDefaultDevice`: the preferred Vulkan physical device -/// (discrete, then integrated, virtual, CPU) it can open, with its default options and its -/// shader cache in `store` where one is given (else its per-user directory). -pub fn system_default(store: Option<&Path>) -> Result { - let Some(store) = store else { - return Ok(runtime::Device::system_default()?); - }; - let mut options = runtime::DeviceOptions::default(); - options.shader_cache = runtime::ShaderCacheOptions::in_directory(store); - Ok(runtime::Device::system_default_with(&options)?) -} - -fn size(size: Size) -> runtime::Size { - runtime::Size::new(size[0], size[1], size[2]) -} - -impl crate::Device for runtime::Device { - type Buffer = runtime::Buffer; - - fn name(&self) -> String { - runtime::Device::name(self).to_owned() - } - - fn new_buffer(&self, length: u64, storage: Storage) -> Result { - Ok(runtime::Device::new_buffer(self, length, options(storage))?) - } - - /// Its pooled and its dedicated `VkDeviceMemory` blocks with a placement in them - /// (`WorkCounts`). Its empty blocks are left out: a bounded set it keeps for the next - /// placements, which fills as other blocks empty. - fn gauges(&self) -> Vec<(&'static str, u64)> { - let counts = self.work_counts(); - vec![ - ("memory_blocks", counts.memory_blocks_live), - ("dedicated_blocks", counts.dedicated_memory_blocks_live), - ] - } - - /// `None`: its counts end with the device. - fn gauges_after_drop(&self) -> Option { - None - } - - /// None: the old runtime keeps no such count. - fn totals(&self) -> Vec<(&'static str, u64)> { - Vec::new() - } - - /// None: the old runtime gives no account of its threads. - fn threads(&self) -> Vec { - Vec::new() - } - - /// The `VkPipeline`s its pipeline states' variants made (`WorkCounts::variant_pipelines_made`): - /// compute regions, replays and draws, those made at a state's creation among them. - fn pipelines_created(&self) -> u64 { - self.work_counts().variant_pipelines_made - } - - /// Its render pass instances of render encoders' passes (`WorkCounts::render_passes_begun_*` - /// summed), those of no draws that resolve a pass after its last - /// (`render_passes_begun_resolves`), the passes that made or took the framebuffers of their - /// exact color resolves (`color_resolve_passes_made` and `_kept`), and the commands it - /// recorded of five kinds (`commands_recorded`): every `vkCmdBeginRenderPass` (its own - /// clears', resolves' and copies' among them), draws, pipeline barriers, and image copies and - /// blits. - fn counts(&self) -> Vec<(&'static str, u64)> { - let w = self.work_counts(); - let c = w.commands_recorded; - vec![ - ( - "pass_instances", - w.render_passes_begun_instances - + w.render_passes_begun_inline - + w.render_passes_begun_inline_splits - + w.render_passes_begun_resolves, - ), - ("resolve_instances", w.render_passes_begun_resolves), - ( - "exact_color_resolve_passes", - w.color_resolve_passes_made + w.color_resolve_passes_kept, - ), - ("cmd_begin_render_pass", c.cmd_begin_render_pass), - ("cmd_draw", c.cmd_draw), - ("cmd_pipeline_barrier", c.cmd_pipeline_barrier), - ("cmd_copy_image", c.cmd_copy_image), - ("cmd_blit_image", c.cmd_blit_image), - ] - } - - /// `WorkCounts::queue_submissions`. - fn submissions(&self) -> u64 { - self.work_counts().queue_submissions - } - - /// None: it counts no submit infos. - fn submit_infos(&self) -> Option { - None - } - - /// `None`: it does not count them. - fn first_use_waits(&self) -> Option { - None - } - - /// `None`: it does not count them. - fn allocations(&self) -> Option { - None - } - - /// `None`: the old runtime has no rows of its own. - fn own_row(&self, _: crate::authored::OwnRow) -> Option> { - None - } -} - -impl crate::ComputeDevice for runtime::Device { - type Library = runtime::Library; - type Function = runtime::Function; - type ComputePipelineState = runtime::ComputePipelineState; - type CommandQueue = runtime::CommandQueue; - type CommandBuffer = runtime::CommandBuffer; - type ComputeCommandEncoder = runtime::ComputeCommandEncoder; - type BlitCommandEncoder = runtime::BlitCommandEncoder; - type Texture = Texture; - type SamplerState = runtime::SamplerState; - type RenderPipelineState = runtime::RenderPipelineState; - type RenderCommandEncoder = runtime::RenderCommandEncoder; - - fn new_library(&self, code: Code<'_>) -> Result { - match code { - Code::Metallib(bytes) => Ok(self.new_library_with_data(bytes)?), - Code::Air(bytes) => { - let library = metal2vulkan::library::Library::from_air(bytes)?; - Ok(self.new_library_with_compile_library(library)) - } - } - } - - fn new_compute_pipeline_state( - &self, - function: &runtime::Function, - private: &[runtime::Function], - ) -> Result { - let options = PipelineOptions::default(); - if private.is_empty() { - return Ok(self.new_compute_pipeline_state_with_function(function, &options)?); - } - let private: Vec<_> = private - .iter() - .map(runtime::Function::function_descriptor) - .collect(); - let function = plan::with_private(function.function_descriptor(), &private); - let descriptor = ComputePipelineDescriptor::new(StageSource::Function(function)); - Ok(runtime::Device::new_compute_pipeline_state( - self, - &descriptor, - &options, - )?) - } - - fn new_render_pipeline_state( - &self, - vertex: &runtime::Function, - fragment: &runtime::Function, - color: metal2vulkan::metal::PixelFormat, - samples: u32, - ) -> Result { - let vertex = StageSource::Function(vertex.function_descriptor()); - let mut descriptor = RenderPipelineDescriptor::new(vertex); - descriptor.fragment = Some(StageSource::Function(fragment.function_descriptor())); - descriptor.color_attachments[0] = Some(ColorAttachmentDescriptor::new(color)); - descriptor.raster_sample_count = samples; - Ok(runtime::Device::new_render_pipeline_state( - self, - &descriptor, - &PipelineOptions::default(), - )?) - } - - fn new_command_queue(&self) -> Result { - Ok(runtime::Device::new_command_queue(self)?) - } - - fn new_texture(&self, texture: &plan::TexturePlan) -> Result { - let options = options(texture.storage); - let mut descriptor = TextureDescriptor::default(); - descriptor.texture_type = texture.texture_type; - descriptor.pixel_format = texture.pixel_format; - descriptor.width = texture.width.into(); - descriptor.height = texture.height.into(); - descriptor.array_length = texture.array_length.into(); - descriptor.sample_count = texture.sample_count.into(); - descriptor.usage = texture.usage; - descriptor.resource_options = options; - let made = |texture, heap, buffer| Texture { - texture, - _heap: heap, - _buffer: buffer, - }; - Ok(match texture.source { - TextureSource::Plain => { - made(runtime::Device::new_texture(self, &descriptor)?, None, None) - } - TextureSource::Heap => { - let size = self.heap_texture_size_and_align(&descriptor)?.size; - let heap = - self.new_heap(&HeapDescriptor::new(HeapType::Automatic, size, options))?; - made(heap.new_texture(&descriptor)?, Some(heap), None) - } - TextureSource::OverBuffer => { - let align = - self.minimum_linear_texture_alignment_for_pixel_format(texture.pixel_format)?; - let row = (texture.row_bytes()) - .ok_or("a texture's format has no known size")? - .next_multiple_of(align); - let length = row * u64::from(texture.height); - let buffer = runtime::Device::new_buffer(self, length, options)?; - made(buffer.new_texture(&descriptor, 0, row)?, None, Some(buffer)) - } - TextureSource::View { .. } => return Err("a view is made from its parent".into()), - }) - } - - fn new_texture_view( - &self, - parent: &Texture, - texture: &plan::TexturePlan, - slices: std::ops::Range, - ) -> Result { - let view = parent.texture.new_texture_view_with_levels_slices( - texture.pixel_format, - texture.texture_type, - 0..1, - u64::from(slices.start)..u64::from(slices.end), - )?; - Ok(Texture { - texture: view, - _heap: None, - _buffer: None, - }) - } - - fn new_sampler_state(&self, sampler: plan::SamplerPlan) -> Result { - Ok(runtime::Device::new_sampler_state( - self, - &sampler.descriptor(), - )?) - } -} - -/// The resource options of `storage`, the other modes Metal's defaults. -fn options(storage: Storage) -> ResourceOptions { - match storage { - Storage::Shared => ResourceOptions::shared(), - Storage::Private => ResourceOptions::private(), - Storage::Managed => ResourceOptions::new( - runtime::StorageMode::Managed, - runtime::CpuCacheMode::DefaultCache, - runtime::HazardTrackingMode::Default, - ), - } -} - -/// A texture of the old runtime with the heap or the buffer it was made of, which it holds as -/// long as it lives: the old runtime's texture holds only their memory, and reaches a heap's -/// bytes for a CPU write through the heap. -pub struct Texture { - texture: runtime::Texture, - _heap: Option, - _buffer: Option, -} - -impl crate::Texture for Texture { - fn replace_region( - &self, - slice: u32, - [width, height]: [u32; 2], - bytes: &[u8], - bytes_per_row: u64, - ) -> Result<()> { - let region = runtime::Region { - origin: runtime::Origin { x: 0, y: 0, z: 0 }, - size: runtime::Size { - width: width.into(), - height: height.into(), - depth: 1, - }, - }; - let texture = &self.texture; - Ok(texture.replace_region(region, 0, slice.into(), bytes, bytes_per_row, 0)?) - } -} - -impl crate::Buffer for runtime::Buffer { - fn contents(&self) -> Option> { - runtime::Buffer::contents(self) - } - - fn did_modify_range(&self, offset: u64, length: u64) -> Result<()> { - Ok(runtime::Buffer::did_modify_range( - self, - offset..offset + length, - )?) - } -} - -impl crate::Library for runtime::Library { - fn new_function(&self, name: &str, constants: &[Constant]) -> Result { - if constants.is_empty() { - return Ok(self.new_function_with_name(name)?); - } - Ok(self.new_function_with_name_constant_values(name, &plan::values(constants)?)?) - } -} - -impl crate::CommandQueue for runtime::CommandQueue { - fn command_buffer(&self) -> Result { - Ok(runtime::CommandQueue::command_buffer(self)?) - } -} - -impl crate::CommandBuffer for runtime::CommandBuffer { - fn compute_command_encoder(&self) -> Result { - Ok(runtime::CommandBuffer::compute_command_encoder(self)?) - } - - fn blit_command_encoder(&self) -> Result { - Ok(runtime::CommandBuffer::blit_command_encoder(self)?) - } - - fn render_command_encoder( - &self, - target: &Texture, - resolve: Option<&Texture>, - ) -> Result { - let mut d = runtime::RenderPassDescriptor::new(); - let color = &mut d.color_attachments[0]; - color.texture = Some(target.texture.clone()); - color.load_action = runtime::LoadAction::Clear; - color.store_action = match resolve { - Some(_) => runtime::StoreAction::MultisampleResolve, - None => runtime::StoreAction::Store, - }; - color.resolve_texture = resolve.map(|texture| texture.texture.clone()); - color.clear_color = runtime::ClearColor::new(0.0, 0.0, 0.0, 0.0); - Ok(runtime::CommandBuffer::render_command_encoder(self, &d)?) - } - - fn commit(&self) -> Result<()> { - Ok(runtime::CommandBuffer::commit(self)?) - } - - fn wait_until_completed(&self) -> Result<()> { - runtime::CommandBuffer::wait_until_completed(self)?; - match self.status() { - CommandBufferStatus::Completed => Ok(()), - status => { - Err(format!("the command buffer ended {status:?}: {:?}", self.error()).into()) - } - } - } - - fn gpu_start_time(&self) -> Result { - Ok(runtime::CommandBuffer::gpu_start_time(self)?) - } - - fn gpu_end_time(&self) -> Result { - Ok(runtime::CommandBuffer::gpu_end_time(self)?) - } - - fn add_completed_handler(&self, handler: Box) -> Result<()> { - Ok(runtime::CommandBuffer::add_completed_handler( - self, - Box::new(move |done| { - let end = runtime::CommandBuffer::gpu_end_time(done).unwrap_or(0.0); - handler((runtime::host_time() - end) * 1e6) - }), - )?) - } - - fn add_scheduled_handler(&self, handler: Box) -> Result<()> { - Ok(runtime::CommandBuffer::add_submission_handler( - self, - Box::new(move |_| handler()), - )?) - } -} - -impl crate::BlitCommandEncoder for runtime::BlitCommandEncoder { - fn copy_from_texture( - &mut self, - copy: &plan::TextureCopy, - source: &Texture, - destination: &Texture, - ) -> Result<()> { - let origin = |[x, y]: [u32; 2]| Origin::new(x.into(), y.into(), 0); - let [width, height] = copy.size; - Ok(self.copy_from_texture_to_texture( - &source.texture, - copy.source_slice.into(), - 0, - origin(copy.source_origin), - runtime::Size::new(width.into(), height.into(), 1), - &destination.texture, - copy.destination_slice.into(), - 0, - origin(copy.destination_origin), - )?) - } - - fn copy_from_buffer( - &mut self, - copy: &plan::BufferCopy, - buffer: &runtime::Buffer, - texture: &Texture, - ) -> Result<()> { - let [x, y] = copy.origin; - let [width, height] = copy.size; - Ok(self.copy_from_buffer_to_texture( - buffer, - copy.offset, - copy.bytes_per_row, - copy.bytes_per_image, - runtime::Size::new(width.into(), height.into(), 1), - &texture.texture, - copy.slice.into(), - 0, - Origin::new(x.into(), y.into(), 0), - BlitOption::None, - )?) - } - - fn copy_from_texture_to_buffer( - &mut self, - copy: &plan::BufferCopy, - texture: &Texture, - buffer: &runtime::Buffer, - ) -> Result<()> { - let [x, y] = copy.origin; - let [width, height] = copy.size; - Ok(runtime::BlitCommandEncoder::copy_from_texture_to_buffer( - self, - &texture.texture, - copy.slice.into(), - 0, - Origin::new(x.into(), y.into(), 0), - runtime::Size::new(width.into(), height.into(), 1), - buffer, - copy.offset, - copy.bytes_per_row, - copy.bytes_per_image, - BlitOption::None, - )?) - } - - fn fill_buffer( - &mut self, - buffer: &runtime::Buffer, - range: std::ops::Range, - value: u8, - ) -> Result<()> { - Ok(runtime::BlitCommandEncoder::fill_buffer( - self, buffer, range, value, - )?) - } - - fn synchronize_resource(&mut self, buffer: &runtime::Buffer) -> Result<()> { - let resource = runtime::ResourceRef::Buffer(buffer); - Ok(runtime::BlitCommandEncoder::synchronize_resource( - self, resource, - )?) - } - - fn end_encoding(self) -> Result<()> { - Ok(runtime::BlitCommandEncoder::end_encoding(self)?) - } -} - -impl crate::RenderCommandEncoder for runtime::RenderCommandEncoder { - fn set_render_pipeline_state(&mut self, state: &runtime::RenderPipelineState) -> Result<()> { - Ok(runtime::RenderCommandEncoder::set_render_pipeline_state( - self, state, - )?) - } - - fn set_vertex_buffer( - &mut self, - buffer: &runtime::Buffer, - offset: u64, - index: u32, - ) -> Result<()> { - Ok(runtime::RenderCommandEncoder::set_vertex_buffer( - self, - Some(buffer), - offset, - index, - )?) - } - - fn set_fragment_texture(&mut self, texture: &Texture, index: u32) -> Result<()> { - Ok(runtime::RenderCommandEncoder::set_fragment_texture( - self, - Some(&texture.texture), - index, - )?) - } - - fn draw_triangles(&mut self, vertex_start: u32, vertex_count: u32) -> Result<()> { - let triangle = metal2vulkan::metal::PrimitiveType::Triangle; - Ok(runtime::RenderCommandEncoder::draw_primitives( - self, - triangle, - vertex_start, - vertex_count, - 1, - 0, - )?) - } - - fn end_encoding(self) -> Result<()> { - Ok(runtime::RenderCommandEncoder::end_encoding(self)?) - } -} - -impl crate::ComputeCommandEncoder for runtime::ComputeCommandEncoder { - fn set_compute_pipeline_state(&mut self, state: &runtime::ComputePipelineState) -> Result<()> { - Ok(runtime::ComputeCommandEncoder::set_compute_pipeline_state( - self, state, - )?) - } - - fn set_buffer(&mut self, buffer: &runtime::Buffer, offset: u64, index: u32) -> Result<()> { - Ok(runtime::ComputeCommandEncoder::set_buffer( - self, - Some(buffer), - offset, - index, - )?) - } - - fn set_bytes(&mut self, bytes: &[u8], index: u32) -> Result<()> { - Ok(runtime::ComputeCommandEncoder::set_bytes( - self, bytes, index, - )?) - } - - fn set_texture(&mut self, texture: &Texture, index: u32) -> Result<()> { - Ok(runtime::ComputeCommandEncoder::set_texture( - self, - Some(&texture.texture), - index, - )?) - } - - fn set_sampler_state(&mut self, sampler: &runtime::SamplerState, index: u32) -> Result<()> { - Ok(runtime::ComputeCommandEncoder::set_sampler_state( - self, - Some(sampler), - index, - )?) - } - - fn set_threadgroup_memory_length(&mut self, length: u32, index: u32) -> Result<()> { - Ok(runtime::ComputeCommandEncoder::set_threadgroup_memory_length(self, length, index)?) - } - - fn dispatch_threadgroups(&mut self, groups: Size, threads: Size) -> Result<()> { - Ok(runtime::ComputeCommandEncoder::dispatch_threadgroups( - self, - size(groups), - size(threads), - )?) - } - - fn dispatch_threads(&mut self, threads: Size, per_group: Size) -> Result<()> { - Ok(runtime::ComputeCommandEncoder::dispatch_threads( - self, - size(threads), - size(per_group), - )?) - } - - fn end_encoding(self) -> Result<()> { - Ok(runtime::ComputeCommandEncoder::end_encoding(self)?) - } -} diff --git a/crates/metal2vulkan-harness/src/rt.rs b/crates/metal2vulkan-harness/src/rt.rs index 38d300cb1..14d4b9260 100644 --- a/crates/metal2vulkan-harness/src/rt.rs +++ b/crates/metal2vulkan-harness/src/rt.rs @@ -73,7 +73,7 @@ pub(crate) fn size(size: Size) -> Result<[u32; 3]> { /// The new runtime's `MTLCreateSystemDefaultDevice`: the first physical device of the most /// preferred type (discrete, integrated, virtual, CPU, other) that opens, in the loader's order -/// within a type, as the old runtime chooses, with its cache directory `store` where one is given +/// within a type, with its cache directory `store` where one is given /// (else none). pub fn system_default(store: Option<&Path>) -> Result { let instance = rt::Instance::new(&[])?;