diff --git a/Cargo.lock b/Cargo.lock index f77725d349..566894c6e3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -411,7 +411,8 @@ dependencies = [ [[package]] name = "block2" version = "0.6.0" -source = "git+https://github.com/madsmtm/objc2?branch=metal-wgpu#b700e0d03bbef850651c0943988136b98614cd45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d59b4c170e16f0405a2e95aff44432a0d41aa97675f3d52623effe95792a037" dependencies = [ "objc2 0.6.0", ] @@ -2383,7 +2384,8 @@ dependencies = [ [[package]] name = "objc2" version = "0.6.0" -source = "git+https://github.com/madsmtm/objc2?branch=metal-wgpu#b700e0d03bbef850651c0943988136b98614cd45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3531f65190d9cff863b77a99857e74c314dd16bf56c538c4b57c7cbc3f3a6e59" dependencies = [ "objc2-encode 4.1.0", ] @@ -2391,7 +2393,8 @@ dependencies = [ [[package]] name = "objc2-core-foundation" version = "0.3.0" -source = "git+https://github.com/madsmtm/objc2?branch=metal-wgpu#b700e0d03bbef850651c0943988136b98614cd45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "daeaf60f25471d26948a1c2f840e3f7d86f4109e3af4e8e4b5cd70c39690d925" dependencies = [ "bitflags 2.8.0", "objc2 0.6.0", @@ -2406,12 +2409,14 @@ checksum = "d079845b37af429bfe5dfa76e6d087d788031045b25cfc6fd898486fd9847666" [[package]] name = "objc2-encode" version = "4.1.0" -source = "git+https://github.com/madsmtm/objc2?branch=metal-wgpu#b700e0d03bbef850651c0943988136b98614cd45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef25abbcd74fb2609453eb695bd2f860d389e457f67dc17cafc8b8cbc89d0c33" [[package]] name = "objc2-foundation" version = "0.3.0" -source = "git+https://github.com/madsmtm/objc2?branch=metal-wgpu#b700e0d03bbef850651c0943988136b98614cd45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a21c6c9014b82c39515db5b396f91645182611c97d24637cf56ac01e5f8d998" dependencies = [ "bitflags 2.8.0", "objc2 0.6.0", @@ -2420,7 +2425,8 @@ dependencies = [ [[package]] name = "objc2-metal" version = "0.3.0" -source = "git+https://github.com/madsmtm/objc2?branch=metal-wgpu#b700e0d03bbef850651c0943988136b98614cd45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "01c41bc8b0e50ea7a5304a56f25e0066f526e99641b46fd7b9ad4421dd35bff6" dependencies = [ "bitflags 2.8.0", "block2 0.6.0", @@ -2431,7 +2437,8 @@ dependencies = [ [[package]] name = "objc2-quartz-core" version = "0.3.0" -source = "git+https://github.com/madsmtm/objc2?branch=metal-wgpu#b700e0d03bbef850651c0943988136b98614cd45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6fb3794501bb1bee12f08dcad8c61f2a5875791ad1c6f47faa71a0f033f20071" dependencies = [ "bitflags 2.8.0", "objc2 0.6.0", diff --git a/Cargo.toml b/Cargo.toml index 536f87b9c1..5a40b031f4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -242,13 +242,6 @@ ndk-sys = "0.5.0" # These overrides allow our examples to explicitly depend on release crates [patch.crates-io] wgpu = { path = "./wgpu" } -block2 = { git = "https://github.com/madsmtm/objc2", branch = "metal-wgpu" } -objc2 = { git = "https://github.com/madsmtm/objc2", branch = "metal-wgpu" } -objc2-encode = { git = "https://github.com/madsmtm/objc2", branch = "metal-wgpu" } -objc2-foundation = { git = "https://github.com/madsmtm/objc2", branch = "metal-wgpu" } -objc2-quartz-core = { git = "https://github.com/madsmtm/objc2", branch = "metal-wgpu" } -objc2-metal = { git = "https://github.com/madsmtm/objc2", branch = "metal-wgpu" } -objc2-core-foundation = { git = "https://github.com/madsmtm/objc2", branch = "metal-wgpu" } [profile.release] lto = "thin" diff --git a/wgpu-hal/src/metal/adapter.rs b/wgpu-hal/src/metal/adapter.rs index 14406b2743..7415d5a83d 100644 --- a/wgpu-hal/src/metal/adapter.rs +++ b/wgpu-hal/src/metal/adapter.rs @@ -35,7 +35,7 @@ impl crate::Adapter for super::Adapter { .shared .device .lock() - .new_command_queue_with_max_command_buffer_count(MAX_COMMAND_BUFFERS) + .newCommandQueueWithMaxCommandBufferCount(MAX_COMMAND_BUFFERS) .unwrap(); // Acquiring the meaning of timestamp ticks is hard with Metal! @@ -519,7 +519,7 @@ impl super::PrivateCapabilities { features_sets .iter() .cloned() - .any(|x| raw.supports_feature_set(x)) + .any(|x| raw.supportsFeatureSet(x)) } pub fn new(device: &ProtocolObject) -> Self { @@ -553,27 +553,27 @@ impl super::PrivateCapabilities { let version = NSProcessInfo::processInfo().operatingSystemVersion(); - let os_is_mac = device.supports_feature_set(MTLFeatureSet::macOS_GPUFamily1_v1); + let os_is_mac = device.supportsFeatureSet(MTLFeatureSet::macOS_GPUFamily1_v1); // Metal was first introduced in OS X 10.11 and iOS 8. The current version number of visionOS is 1.0.0. Additionally, // on the Simulator, Apple only provides the Apple2 GPU capability, and the Apple2+ GPU capability covers the capabilities of Apple2. // Therefore, the following conditions can be used to determine if it is visionOS. // https://developer.apple.com/documentation/metal/developing_metal_apps_that_run_in_simulator - let os_is_xr = version.majorVersion < 8 && device.supports_family(MTLGPUFamily::Apple2); + let os_is_xr = version.majorVersion < 8 && device.supportsFamily(MTLGPUFamily::Apple2); let family_check = os_is_xr || version.at_least((10, 15), (13, 0), os_is_mac); let mut sample_count_mask = crate::TextureFormatCapabilities::MULTISAMPLE_X4; // 1 and 4 samples are supported on all devices - if device.supports_texture_sample_count(2) { + if device.supportsTextureSampleCount(2) { sample_count_mask |= crate::TextureFormatCapabilities::MULTISAMPLE_X2; } - if device.supports_texture_sample_count(8) { + if device.supportsTextureSampleCount(8) { sample_count_mask |= crate::TextureFormatCapabilities::MULTISAMPLE_X8; } - if device.supports_texture_sample_count(16) { + if device.supportsTextureSampleCount(16) { sample_count_mask |= crate::TextureFormatCapabilities::MULTISAMPLE_X16; } let rw_texture_tier = if version.at_least((10, 13), (11, 0), os_is_mac) { - device.read_write_texture_support() + device.readWriteTextureSupport() } else if version.at_least((10, 12), OS_NOT_SUPPORT, os_is_mac) { if Self::supports_any(device, &[MTLFeatureSet::macOS_ReadWriteTextureTier2]) { MTLReadWriteTextureTier::Tier2 @@ -586,18 +586,18 @@ impl super::PrivateCapabilities { let mut timestamp_query_support = TimestampQuerySupport::empty(); if version.at_least((11, 0), (14, 0), os_is_mac) - && device.supports_counter_sampling(MTLCounterSamplingPoint::AtStageBoundary) + && device.supportsCounterSampling(MTLCounterSamplingPoint::AtStageBoundary) { // If we don't support at stage boundary, don't support anything else. timestamp_query_support.insert(TimestampQuerySupport::STAGE_BOUNDARIES); - if device.supports_counter_sampling(MTLCounterSamplingPoint::AtDrawBoundary) { + if device.supportsCounterSampling(MTLCounterSamplingPoint::AtDrawBoundary) { timestamp_query_support.insert(TimestampQuerySupport::ON_RENDER_ENCODER); } - if device.supports_counter_sampling(MTLCounterSamplingPoint::AtDispatchBoundary) { + if device.supportsCounterSampling(MTLCounterSamplingPoint::AtDispatchBoundary) { timestamp_query_support.insert(TimestampQuerySupport::ON_COMPUTE_ENCODER); } - if device.supports_counter_sampling(MTLCounterSamplingPoint::AtBlitBoundary) { + if device.supportsCounterSampling(MTLCounterSamplingPoint::AtBlitBoundary) { timestamp_query_support.insert(TimestampQuerySupport::ON_BLIT_ENCODER); } // `TimestampQuerySupport::INSIDE_WGPU_PASSES` emerges from the other flags. @@ -631,13 +631,13 @@ impl super::PrivateCapabilities { read_write_texture_tier: rw_texture_tier, msaa_desktop: os_is_mac, msaa_apple3: if family_check { - device.supports_family(MTLGPUFamily::Apple3) + device.supportsFamily(MTLGPUFamily::Apple3) } else { - device.supports_feature_set(MTLFeatureSet::iOS_GPUFamily3_v4) + device.supportsFeatureSet(MTLFeatureSet::iOS_GPUFamily3_v4) }, - msaa_apple7: family_check && device.supports_family(MTLGPUFamily::Apple7), + msaa_apple7: family_check && device.supportsFamily(MTLGPUFamily::Apple7), resource_heaps: Self::supports_any(device, RESOURCE_HEAP_SUPPORT), - argument_buffers: device.argument_buffers_support(), + argument_buffers: device.argumentBuffersSupport(), shared_textures: !os_is_mac, mutable_comparison_samplers: Self::supports_any( device, @@ -650,17 +650,16 @@ impl super::PrivateCapabilities { BASE_VERTEX_FIRST_INSTANCE_SUPPORT, ), dual_source_blending: Self::supports_any(device, DUAL_SOURCE_BLEND_SUPPORT), - low_power: !os_is_mac || device.is_low_power(), - headless: os_is_mac && device.is_headless(), + low_power: !os_is_mac || device.isLowPower(), + headless: os_is_mac && device.isHeadless(), layered_rendering: Self::supports_any(device, LAYERED_RENDERING_SUPPORT), function_specialization: Self::supports_any(device, FUNCTION_SPECIALIZATION_SUPPORT), depth_clip_mode: Self::supports_any(device, DEPTH_CLIP_MODE), texture_cube_array: Self::supports_any(device, TEXTURE_CUBE_ARRAY_SUPPORT), supports_float_filtering: os_is_mac || (version.at_least((11, 0), (14, 0), os_is_mac) - && device.supports32_bit_float_filtering()), - format_depth24_stencil8: os_is_mac - && device.is_depth24_stencil8_pixel_format_supported(), + && device.supports32BitFloatFiltering()), + format_depth24_stencil8: os_is_mac && device.isDepth24Stencil8PixelFormatSupported(), format_depth32_stencil8_filter: os_is_mac, format_depth32_stencil8_none: !os_is_mac, format_min_srgb_channels: if os_is_mac { 4 } else { 1 }, @@ -668,12 +667,12 @@ impl super::PrivateCapabilities { format_bc: os_is_mac, format_eac_etc: !os_is_mac // M1 in macOS supports EAC/ETC2 - || (family_check && device.supports_family(MTLGPUFamily::Apple7)), + || (family_check && device.supportsFamily(MTLGPUFamily::Apple7)), // A8(Apple2) and later always support ASTC pixel formats - format_astc: (family_check && device.supports_family(MTLGPUFamily::Apple2)) + format_astc: (family_check && device.supportsFamily(MTLGPUFamily::Apple2)) || Self::supports_any(device, ASTC_PIXEL_FORMAT_FEATURES), // A13(Apple6) M1(Apple7) and later always support HDR ASTC pixel formats - format_astc_hdr: family_check && device.supports_family(MTLGPUFamily::Apple6), + format_astc_hdr: family_check && device.supportsFamily(MTLGPUFamily::Apple6), format_any8_unorm_srgb_all: Self::supports_any(device, ANY8_UNORM_SRGB_ALL), format_any8_unorm_srgb_no_write: !Self::supports_any(device, ANY8_UNORM_SRGB_ALL) && !os_is_mac, @@ -728,10 +727,10 @@ impl super::PrivateCapabilities { max_buffers_per_stage: 31, max_vertex_buffers: 31.min(crate::MAX_VERTEX_BUFFERS as u32), max_textures_per_stage: if os_is_mac - || (family_check && device.supports_family(MTLGPUFamily::Apple6)) + || (family_check && device.supportsFamily(MTLGPUFamily::Apple6)) { 128 - } else if family_check && device.supports_family(MTLGPUFamily::Apple4) { + } else if family_check && device.supportsFamily(MTLGPUFamily::Apple4) { 96 } else { 31 @@ -740,7 +739,7 @@ impl super::PrivateCapabilities { buffer_alignment: if os_is_mac || os_is_xr { 256 } else { 64 }, max_buffer_size: if version.at_least((10, 14), (12, 0), os_is_mac) { // maxBufferLength available on macOS 10.14+ and iOS 12.0+ - device.max_buffer_length() as u64 + device.maxBufferLength() as u64 } else if os_is_mac { 1 << 30 // 1GB on macOS 10.11 and up } else { @@ -761,7 +760,7 @@ impl super::PrivateCapabilities { max_texture_3d_size: 2048, max_texture_layers: 2048, max_fragment_input_components: if os_is_mac - || device.supports_feature_set(MTLFeatureSet::iOS_GPUFamily4_v1) + || device.supportsFeatureSet(MTLFeatureSet::iOS_GPUFamily4_v1) { 124 } else { @@ -781,14 +780,13 @@ impl super::PrivateCapabilities { }, // Per https://developer.apple.com/metal/Metal-Feature-Set-Tables.pdf max_color_attachment_bytes_per_sample: if family_check - && device.supports_family(MTLGPUFamily::Apple4) + && device.supportsFamily(MTLGPUFamily::Apple4) { 64 } else { 32 }, - max_varying_components: if device - .supports_feature_set(MTLFeatureSet::macOS_GPUFamily1_v1) + max_varying_components: if device.supportsFeatureSet(MTLFeatureSet::macOS_GPUFamily1_v1) { 124 } else { @@ -826,8 +824,8 @@ impl super::PrivateCapabilities { ], ), supports_binary_archives: family_check - && (device.supports_family(MTLGPUFamily::Apple3) - || device.supports_family(MTLGPUFamily::Mac1)), + && (device.supportsFamily(MTLGPUFamily::Apple3) + || device.supportsFamily(MTLGPUFamily::Mac1)), supports_capture_manager: version.at_least((10, 13), (11, 0), os_is_mac), can_set_maximum_drawables_count: version.at_least((10, 14), (11, 2), os_is_mac), can_set_display_sync: version.at_least((10, 13), OS_NOT_SUPPORT, os_is_mac), @@ -841,39 +839,39 @@ impl super::PrivateCapabilities { ], ), supports_arrays_of_textures_write: family_check - && (device.supports_family(MTLGPUFamily::Apple6) - || device.supports_family(MTLGPUFamily::Mac1) - || device.supports_family(MTLGPUFamily::MacCatalyst1)), + && (device.supportsFamily(MTLGPUFamily::Apple6) + || device.supportsFamily(MTLGPUFamily::Mac1) + || device.supportsFamily(MTLGPUFamily::MacCatalyst1)), supports_mutability: version.at_least((10, 13), (11, 0), os_is_mac), //Depth clipping is supported on all macOS GPU families and iOS family 4 and later supports_depth_clip_control: os_is_mac - || device.supports_feature_set(MTLFeatureSet::iOS_GPUFamily4_v1), + || device.supportsFeatureSet(MTLFeatureSet::iOS_GPUFamily4_v1), supports_preserve_invariance: version.at_least((11, 0), (13, 0), os_is_mac), // Metal 2.2 on mac, 2.3 on iOS. supports_shader_primitive_index: version.at_least((10, 15), (14, 0), os_is_mac), has_unified_memory: if version.at_least((10, 15), (13, 0), os_is_mac) { - Some(device.has_unified_memory()) + Some(device.hasUnifiedMemory()) } else { None }, timestamp_query_support, supports_simd_scoped_operations: family_check - && (device.supports_family(MTLGPUFamily::Metal3) - || device.supports_family(MTLGPUFamily::Mac2) - || device.supports_family(MTLGPUFamily::Apple7)), + && (device.supportsFamily(MTLGPUFamily::Metal3) + || device.supportsFamily(MTLGPUFamily::Mac2) + || device.supportsFamily(MTLGPUFamily::Apple7)), // https://developer.apple.com/metal/Metal-Feature-Set-Tables.pdf#page=5 int64: family_check - && (device.supports_family(MTLGPUFamily::Apple3) - || device.supports_family(MTLGPUFamily::Metal3)), + && (device.supportsFamily(MTLGPUFamily::Apple3) + || device.supportsFamily(MTLGPUFamily::Metal3)), // https://developer.apple.com/metal/Metal-Feature-Set-Tables.pdf#page=6 int64_atomics: family_check - && ((device.supports_family(MTLGPUFamily::Apple8) - && device.supports_family(MTLGPUFamily::Mac2)) - || device.supports_family(MTLGPUFamily::Apple9)), + && ((device.supportsFamily(MTLGPUFamily::Apple8) + && device.supportsFamily(MTLGPUFamily::Mac2)) + || device.supportsFamily(MTLGPUFamily::Apple9)), // https://developer.apple.com/metal/Metal-Feature-Set-Tables.pdf#page=6 float_atomics: family_check - && (device.supports_family(MTLGPUFamily::Apple7) - || device.supports_family(MTLGPUFamily::Mac2)), + && (device.supportsFamily(MTLGPUFamily::Apple7) + || device.supportsFamily(MTLGPUFamily::Mac2)), supports_shared_event: version.at_least((10, 14), (12, 0), os_is_mac), } } @@ -1235,7 +1233,7 @@ impl super::PrivateDisabilities { let is_intel = device.name().to_string().starts_with("Intel"); Self { broken_viewport_near_depth: is_intel - && !device.supports_feature_set(MTLFeatureSet::macOS_GPUFamily1_v4), + && !device.supportsFeatureSet(MTLFeatureSet::macOS_GPUFamily1_v4), broken_layered_clear_image: is_intel, } } diff --git a/wgpu-hal/src/metal/command.rs b/wgpu-hal/src/metal/command.rs index 7d617b0610..f88d2b48f9 100644 --- a/wgpu-hal/src/metal/command.rs +++ b/wgpu-hal/src/metal/command.rs @@ -75,20 +75,20 @@ impl super::CommandEncoder { for (i, (set, index)) in self.state.pending_timer_queries.drain(..).enumerate() { let sba_descriptor = descriptor - .sample_buffer_attachments() - .object_at_indexed_subscript(i); + .sampleBufferAttachments() + .objectAtIndexedSubscript(i); sba_descriptor - .set_sample_buffer(Some(set.counter_sample_buffer.as_ref().unwrap())); + .setSampleBuffer(Some(set.counter_sample_buffer.as_ref().unwrap())); // Here be dragons: // As mentioned above, for some reasons using the start of the encoder won't yield any results sometimes! - sba_descriptor.set_start_of_encoder_sample_index(MTLCounterDontSample); - sba_descriptor.set_end_of_encoder_sample_index(index as _); + sba_descriptor.setStartOfEncoderSampleIndex(MTLCounterDontSample); + sba_descriptor.setEndOfEncoderSampleIndex(index as _); last_query = Some((set, index)); } let encoder = cmd_buf - .blit_command_encoder_with_descriptor(&descriptor) + .blitCommandEncoderWithDescriptor(&descriptor) .unwrap(); // As explained above, we need to do some write: @@ -99,18 +99,18 @@ impl super::CommandEncoder { * crate::QUERY_SIZE as usize, length: 1, }; - encoder.fill_buffer_range_value( + encoder.fillBuffer_range_value( &last_query.as_ref().unwrap().0.raw_buffer, raw_range, 255, // Don't write 0, so it's easier to identify if something went wrong. ); - encoder.end_encoding(); + encoder.endEncoding(); }); } autoreleasepool(|_| { - self.state.blit = Some(cmd_buf.blit_command_encoder().unwrap()); + self.state.blit = Some(cmd_buf.blitCommandEncoder().unwrap()); }); let encoder = self.state.blit.as_ref().unwrap(); @@ -120,7 +120,7 @@ impl super::CommandEncoder { for (set, index) in self.state.pending_timer_queries.drain(..) { debug_assert!(supports_sample_counters_in_buffer); unsafe { - encoder.sample_counters_in_buffer_at_sample_index_with_barrier( + encoder.sampleCountersInBuffer_atSampleIndex_withBarrier( set.counter_sample_buffer.as_ref().unwrap(), index as _, true, @@ -133,7 +133,7 @@ impl super::CommandEncoder { pub(super) fn leave_blit(&mut self) { if let Some(encoder) = self.state.blit.take() { - encoder.end_encoding(); + encoder.endEncoding(); } } @@ -207,13 +207,13 @@ impl crate::CommandEncoder for super::CommandEncoder { let retain_references = self.shared.settings.retain_command_buffer_references; let raw = autoreleasepool(move |_| { let cmd_buf_ref = if retain_references { - queue.command_buffer() + queue.commandBuffer() } else { - queue.command_buffer_with_unretained_references() + queue.commandBufferWithUnretainedReferences() } .unwrap(); if let Some(label) = label { - cmd_buf_ref.set_label(Some(&NSString::from_str(label))); + cmd_buf_ref.setLabel(Some(&NSString::from_str(label))); } cmd_buf_ref.to_owned() }); @@ -228,10 +228,10 @@ impl crate::CommandEncoder for super::CommandEncoder { // when discarding, we don't have a guarantee that // everything is in a good state, so check carefully if let Some(encoder) = self.state.render.take() { - encoder.end_encoding(); + encoder.endEncoding(); } if let Some(encoder) = self.state.compute.take() { - encoder.end_encoding(); + encoder.endEncoding(); } self.raw_cmd_buf = None; } @@ -274,7 +274,7 @@ impl crate::CommandEncoder for super::CommandEncoder { unsafe fn clear_buffer(&mut self, buffer: &super::Buffer, range: crate::MemoryRange) { let encoder = self.enter_blit(); - encoder.fill_buffer_range_value(&buffer.raw, conv::map_range(&range), 0); + encoder.fillBuffer_range_value(&buffer.raw, conv::map_range(&range), 0); } unsafe fn copy_buffer_to_buffer( @@ -287,7 +287,7 @@ impl crate::CommandEncoder for super::CommandEncoder { { let encoder = self.enter_blit(); for copy in regions { - encoder.copy_from_buffer_source_offset_to_buffer_destination_offset_size( + encoder.copyFromBuffer_sourceOffset_toBuffer_destinationOffset_size( &src.raw, copy.src_offset as usize, &dst.raw, @@ -309,9 +309,7 @@ impl crate::CommandEncoder for super::CommandEncoder { let dst_texture = if src.format != dst.format { let raw_format = self.shared.private_caps.map_format(src.format); Cow::Owned(autoreleasepool(|_| { - dst.raw - .new_texture_view_with_pixel_format(raw_format) - .unwrap() + dst.raw.newTextureViewWithPixelFormat(raw_format).unwrap() })) } else { Cow::Borrowed(&dst.raw) @@ -322,7 +320,7 @@ impl crate::CommandEncoder for super::CommandEncoder { let dst_origin = conv::map_origin(©.dst_base.origin); // no clamping is done: Metal expects physical sizes here let extent = conv::map_copy_extent(©.size); - encoder.copy_from_texture_source_slice_source_level_source_origin_source_size_to_texture_destination_slice_destination_level_destination_origin( + encoder.copyFromTexture_sourceSlice_sourceLevel_sourceOrigin_sourceSize_toTexture_destinationSlice_destinationLevel_destinationOrigin( &src.raw, copy.src_base.array_layer as usize, copy.src_base.mip_level as usize, @@ -363,7 +361,7 @@ impl crate::CommandEncoder for super::CommandEncoder { // the amount of data to copy. 0 }; - encoder.copy_from_buffer_source_offset_source_bytes_per_row_source_bytes_per_image_source_size_to_texture_destination_slice_destination_level_destination_origin_options( + encoder.copyFromBuffer_sourceOffset_sourceBytesPerRow_sourceBytesPerImage_sourceSize_toTexture_destinationSlice_destinationLevel_destinationOrigin_options( &src.raw, copy.buffer_layout.offset as usize, bytes_per_row as usize, @@ -400,7 +398,7 @@ impl crate::CommandEncoder for super::CommandEncoder { .buffer_layout .rows_per_image .map_or(0, |v| v as u64 * bytes_per_row); - encoder.copy_from_texture_source_slice_source_level_source_origin_source_size_to_buffer_destination_offset_destination_bytes_per_row_destination_bytes_per_image_options( + encoder.copyFromTexture_sourceSlice_sourceLevel_sourceOrigin_sourceSize_toBuffer_destinationOffset_destinationBytesPerRow_destinationBytesPerImage_options( &src.raw, copy.texture_base.array_layer as usize, copy.texture_base.mip_level as usize, @@ -422,7 +420,7 @@ impl crate::CommandEncoder for super::CommandEncoder { .render .as_ref() .unwrap() - .set_visibility_result_mode_offset( + .setVisibilityResultMode_offset( MTLVisibilityResultMode::Boolean, index as usize * crate::QUERY_SIZE as usize, ); @@ -437,7 +435,7 @@ impl crate::CommandEncoder for super::CommandEncoder { .render .as_ref() .unwrap() - .set_visibility_result_mode_offset(MTLVisibilityResultMode::Disabled, 0); + .setVisibilityResultMode_offset(MTLVisibilityResultMode::Disabled, 0); } _ => {} } @@ -457,7 +455,7 @@ impl crate::CommandEncoder for super::CommandEncoder { support.contains(TimestampQuerySupport::ON_BLIT_ENCODER), self.state.blit.as_ref(), ) { - encoder.sample_counters_in_buffer_at_sample_index_with_barrier( + encoder.sampleCountersInBuffer_atSampleIndex_withBarrier( sample_buffer, index as _, with_barrier, @@ -466,7 +464,7 @@ impl crate::CommandEncoder for super::CommandEncoder { support.contains(TimestampQuerySupport::ON_RENDER_ENCODER), self.state.render.as_ref(), ) { - encoder.sample_counters_in_buffer_at_sample_index_with_barrier( + encoder.sampleCountersInBuffer_atSampleIndex_withBarrier( sample_buffer, index as _, with_barrier, @@ -475,7 +473,7 @@ impl crate::CommandEncoder for super::CommandEncoder { support.contains(TimestampQuerySupport::ON_COMPUTE_ENCODER), self.state.compute.as_ref(), ) { - encoder.sample_counters_in_buffer_at_sample_index_with_barrier( + encoder.sampleCountersInBuffer_atSampleIndex_withBarrier( sample_buffer, index as _, with_barrier, @@ -499,7 +497,7 @@ impl crate::CommandEncoder for super::CommandEncoder { location: range.start as usize * crate::QUERY_SIZE as usize, length: (range.end - range.start) as usize * crate::QUERY_SIZE as usize, }; - encoder.fill_buffer_range_value(&set.raw_buffer, raw_range, 0); + encoder.fillBuffer_range_value(&set.raw_buffer, raw_range, 0); } unsafe fn copy_query_results( @@ -514,7 +512,7 @@ impl crate::CommandEncoder for super::CommandEncoder { match set.ty { wgt::QueryType::Occlusion => { let size = (range.end - range.start) as u64 * crate::QUERY_SIZE; - encoder.copy_from_buffer_source_offset_to_buffer_destination_offset_size( + encoder.copyFromBuffer_sourceOffset_toBuffer_destinationOffset_size( &set.raw_buffer, range.start as usize * crate::QUERY_SIZE as usize, &buffer.raw, @@ -523,7 +521,7 @@ impl crate::CommandEncoder for super::CommandEncoder { ); } wgt::QueryType::Timestamp => { - encoder.resolve_counters_in_range_destination_buffer_destination_offset( + encoder.resolveCounters_inRange_destinationBuffer_destinationOffset( set.counter_sample_buffer.as_ref().unwrap(), NSRange::new(range.start as usize, (range.end - range.start) as usize), &buffer.raw, @@ -552,38 +550,36 @@ impl crate::CommandEncoder for super::CommandEncoder { for (i, at) in desc.color_attachments.iter().enumerate() { if let Some(at) = at.as_ref() { - let at_descriptor = descriptor - .color_attachments() - .object_at_indexed_subscript(i); - at_descriptor.set_texture(Some(&at.target.view.raw)); + let at_descriptor = descriptor.colorAttachments().objectAtIndexedSubscript(i); + at_descriptor.setTexture(Some(&at.target.view.raw)); if let Some(ref resolve) = at.resolve_target { //Note: the selection of levels and slices is already handled by `TextureView` - at_descriptor.set_resolve_texture(Some(&resolve.view.raw)); + at_descriptor.setResolveTexture(Some(&resolve.view.raw)); } let load_action = if at.ops.contains(crate::AttachmentOps::LOAD) { MTLLoadAction::Load } else { - at_descriptor.set_clear_color(conv::map_clear_color(&at.clear_value)); + at_descriptor.setClearColor(conv::map_clear_color(&at.clear_value)); MTLLoadAction::Clear }; let store_action = conv::map_store_action( at.ops.contains(crate::AttachmentOps::STORE), at.resolve_target.is_some(), ); - at_descriptor.set_load_action(load_action); - at_descriptor.set_store_action(store_action); + at_descriptor.setLoadAction(load_action); + at_descriptor.setStoreAction(store_action); } } if let Some(ref at) = desc.depth_stencil_attachment { if at.target.view.aspects.contains(crate::FormatAspects::DEPTH) { - let at_descriptor = descriptor.depth_attachment(); - at_descriptor.set_texture(Some(&at.target.view.raw)); + let at_descriptor = descriptor.depthAttachment(); + at_descriptor.setTexture(Some(&at.target.view.raw)); let load_action = if at.depth_ops.contains(crate::AttachmentOps::LOAD) { MTLLoadAction::Load } else { - at_descriptor.set_clear_depth(at.clear_value.0 as f64); + at_descriptor.setClearDepth(at.clear_value.0 as f64); MTLLoadAction::Clear }; let store_action = if at.depth_ops.contains(crate::AttachmentOps::STORE) { @@ -591,8 +587,8 @@ impl crate::CommandEncoder for super::CommandEncoder { } else { MTLStoreAction::DontCare }; - at_descriptor.set_load_action(load_action); - at_descriptor.set_store_action(store_action); + at_descriptor.setLoadAction(load_action); + at_descriptor.setStoreAction(store_action); } if at .target @@ -600,13 +596,13 @@ impl crate::CommandEncoder for super::CommandEncoder { .aspects .contains(crate::FormatAspects::STENCIL) { - let at_descriptor = descriptor.stencil_attachment(); - at_descriptor.set_texture(Some(&at.target.view.raw)); + let at_descriptor = descriptor.stencilAttachment(); + at_descriptor.setTexture(Some(&at.target.view.raw)); let load_action = if at.stencil_ops.contains(crate::AttachmentOps::LOAD) { MTLLoadAction::Load } else { - at_descriptor.set_clear_stencil(at.clear_value.1); + at_descriptor.setClearStencil(at.clear_value.1); MTLLoadAction::Clear }; let store_action = if at.stencil_ops.contains(crate::AttachmentOps::STORE) { @@ -614,19 +610,19 @@ impl crate::CommandEncoder for super::CommandEncoder { } else { MTLStoreAction::DontCare }; - at_descriptor.set_load_action(load_action); - at_descriptor.set_store_action(store_action); + at_descriptor.setLoadAction(load_action); + at_descriptor.setStoreAction(store_action); } } let mut sba_index = 0; let mut next_sba_descriptor = || { let sba_descriptor = descriptor - .sample_buffer_attachments() - .object_at_indexed_subscript(sba_index); + .sampleBufferAttachments() + .objectAtIndexedSubscript(sba_index); - sba_descriptor.set_end_of_vertex_sample_index(MTLCounterDontSample); - sba_descriptor.set_start_of_fragment_sample_index(MTLCounterDontSample); + sba_descriptor.setEndOfVertexSampleIndex(MTLCounterDontSample); + sba_descriptor.setStartOfFragmentSampleIndex(MTLCounterDontSample); sba_index += 1; sba_descriptor @@ -634,14 +630,14 @@ impl crate::CommandEncoder for super::CommandEncoder { for (set, index) in self.state.pending_timer_queries.drain(..) { let sba_descriptor = next_sba_descriptor(); - sba_descriptor.set_sample_buffer(Some(set.counter_sample_buffer.as_ref().unwrap())); - sba_descriptor.set_start_of_vertex_sample_index(index as _); - sba_descriptor.set_end_of_fragment_sample_index(MTLCounterDontSample); + sba_descriptor.setSampleBuffer(Some(set.counter_sample_buffer.as_ref().unwrap())); + sba_descriptor.setStartOfVertexSampleIndex(index as _); + sba_descriptor.setEndOfFragmentSampleIndex(MTLCounterDontSample); } if let Some(ref timestamp_writes) = desc.timestamp_writes { let sba_descriptor = next_sba_descriptor(); - sba_descriptor.set_sample_buffer(Some( + sba_descriptor.setSampleBuffer(Some( timestamp_writes .query_set .counter_sample_buffer @@ -649,12 +645,12 @@ impl crate::CommandEncoder for super::CommandEncoder { .unwrap(), )); - sba_descriptor.set_start_of_vertex_sample_index( + sba_descriptor.setStartOfVertexSampleIndex( timestamp_writes .beginning_of_pass_write_index .map_or(MTLCounterDontSample, |i| i as _), ); - sba_descriptor.set_end_of_fragment_sample_index( + sba_descriptor.setEndOfFragmentSampleIndex( timestamp_writes .end_of_pass_write_index .map_or(MTLCounterDontSample, |i| i as _), @@ -662,23 +658,20 @@ impl crate::CommandEncoder for super::CommandEncoder { } if let Some(occlusion_query_set) = desc.occlusion_query_set { - descriptor - .set_visibility_result_buffer(Some(occlusion_query_set.raw_buffer.as_ref())) + descriptor.setVisibilityResultBuffer(Some(occlusion_query_set.raw_buffer.as_ref())) } let raw = self.raw_cmd_buf.as_ref().unwrap(); - let encoder = raw - .render_command_encoder_with_descriptor(&descriptor) - .unwrap(); + let encoder = raw.renderCommandEncoderWithDescriptor(&descriptor).unwrap(); if let Some(label) = desc.label { - encoder.set_label(Some(&NSString::from_str(label))); + encoder.setLabel(Some(&NSString::from_str(label))); } self.state.render = Some(encoder); }); } unsafe fn end_render_pass(&mut self) { - self.state.render.take().unwrap().end_encoding(); + self.state.render.take().unwrap().endEncoding(); } unsafe fn set_bind_group( @@ -698,7 +691,7 @@ impl crate::CommandEncoder for super::CommandEncoder { if let Some(dyn_index) = buf.dynamic_index { offset += dynamic_offsets[dyn_index as usize] as wgt::BufferAddress; } - encoder.setVertexBuffer_offset_atIndex_( + encoder.setVertexBuffer_offset_atIndex( Some(buf.ptr.as_ref()), offset as usize, (bg_info.base_resource_indices.vs.buffers + index) as usize, @@ -717,7 +710,7 @@ impl crate::CommandEncoder for super::CommandEncoder { naga::ShaderStage::Vertex, &mut self.temp.binding_sizes, ) { - encoder.set_vertex_bytes_length_at_index( + encoder.setVertexBytes_length_atIndex( NonNull::new(sizes.as_ptr().cast_mut().cast()).unwrap(), sizes.len() * WORD_SIZE, index as _, @@ -732,7 +725,7 @@ impl crate::CommandEncoder for super::CommandEncoder { if let Some(dyn_index) = buf.dynamic_index { offset += dynamic_offsets[dyn_index as usize] as wgt::BufferAddress; } - encoder.setFragmentBuffer_offset_atIndex_( + encoder.setFragmentBuffer_offset_atIndex( Some(buf.ptr.as_ref()), offset as usize, (bg_info.base_resource_indices.fs.buffers + index) as usize, @@ -751,7 +744,7 @@ impl crate::CommandEncoder for super::CommandEncoder { naga::ShaderStage::Fragment, &mut self.temp.binding_sizes, ) { - encoder.set_fragment_bytes_length_at_index( + encoder.setFragmentBytes_length_atIndex( NonNull::new(sizes.as_ptr().cast_mut().cast()).unwrap(), sizes.len() * WORD_SIZE, index as _, @@ -761,14 +754,14 @@ impl crate::CommandEncoder for super::CommandEncoder { for index in 0..group.counters.vs.samplers { let res = group.samplers[index as usize]; - encoder.set_vertex_sampler_state_at_index( + encoder.setVertexSamplerState_atIndex( Some(res.as_ref()), (bg_info.base_resource_indices.vs.samplers + index) as usize, ); } for index in 0..group.counters.fs.samplers { let res = group.samplers[(group.counters.vs.samplers + index) as usize]; - encoder.set_fragment_sampler_state_at_index( + encoder.setFragmentSamplerState_atIndex( Some(res.as_ref()), (bg_info.base_resource_indices.fs.samplers + index) as usize, ); @@ -776,14 +769,14 @@ impl crate::CommandEncoder for super::CommandEncoder { for index in 0..group.counters.vs.textures { let res = group.textures[index as usize]; - encoder.set_vertex_texture_at_index( + encoder.setVertexTexture_atIndex( Some(res.as_ref()), (bg_info.base_resource_indices.vs.textures + index) as usize, ); } for index in 0..group.counters.fs.textures { let res = group.textures[(group.counters.vs.textures + index) as usize]; - encoder.set_fragment_texture_at_index( + encoder.setFragmentTexture_atIndex( Some(res.as_ref()), (bg_info.base_resource_indices.fs.textures + index) as usize, ); @@ -791,11 +784,7 @@ impl crate::CommandEncoder for super::CommandEncoder { // Call useResource on all textures and buffers used indirectly so they are alive for (resource, use_info) in group.resources_to_use.iter() { - encoder.use_resource_usage_stages( - resource.as_ref(), - use_info.uses, - use_info.stages, - ); + encoder.useResource_usage_stages(resource.as_ref(), use_info.uses, use_info.stages); } } @@ -813,7 +802,7 @@ impl crate::CommandEncoder for super::CommandEncoder { if let Some(dyn_index) = buf.dynamic_index { offset += dynamic_offsets[dyn_index as usize] as wgt::BufferAddress; } - encoder.setBuffer_offset_atIndex_( + encoder.setBuffer_offset_atIndex( Some(buf.ptr.as_ref()), offset as usize, (bg_info.base_resource_indices.cs.buffers + index) as usize, @@ -832,7 +821,7 @@ impl crate::CommandEncoder for super::CommandEncoder { naga::ShaderStage::Compute, &mut self.temp.binding_sizes, ) { - encoder.set_bytes_length_at_index( + encoder.setBytes_length_atIndex( NonNull::new(sizes.as_ptr().cast_mut().cast()).unwrap(), sizes.len() * WORD_SIZE, index as _, @@ -842,14 +831,14 @@ impl crate::CommandEncoder for super::CommandEncoder { for index in 0..group.counters.cs.samplers { let res = group.samplers[(index_base.samplers + index) as usize]; - encoder.set_sampler_state_at_index( + encoder.setSamplerState_atIndex( Some(res.as_ref()), (bg_info.base_resource_indices.cs.samplers + index) as usize, ); } for index in 0..group.counters.cs.textures { let res = group.textures[(index_base.textures + index) as usize]; - encoder.set_texture_at_index( + encoder.setTexture_atIndex( Some(res.as_ref()), (bg_info.base_resource_indices.cs.textures + index) as usize, ); @@ -860,7 +849,7 @@ impl crate::CommandEncoder for super::CommandEncoder { if !use_info.visible_in_compute { continue; } - encoder.use_resource_usage(resource.as_ref(), use_info.uses); + encoder.useResource_usage(resource.as_ref(), use_info.uses); } } } @@ -887,7 +876,7 @@ impl crate::CommandEncoder for super::CommandEncoder { .compute .as_ref() .unwrap() - .set_bytes_length_at_index( + .setBytes_length_atIndex( bytes, layout.total_push_constants as usize * WORD_SIZE, layout.push_constants_infos.cs.unwrap().buffer_index as _, @@ -898,7 +887,7 @@ impl crate::CommandEncoder for super::CommandEncoder { .render .as_ref() .unwrap() - .set_vertex_bytes_length_at_index( + .setVertexBytes_length_atIndex( bytes, layout.total_push_constants as usize * WORD_SIZE, layout.push_constants_infos.vs.unwrap().buffer_index as _, @@ -909,7 +898,7 @@ impl crate::CommandEncoder for super::CommandEncoder { .render .as_ref() .unwrap() - .set_fragment_bytes_length_at_index( + .setFragmentBytes_length_atIndex( bytes, layout.total_push_constants as usize * WORD_SIZE, layout.push_constants_infos.fs.unwrap().buffer_index as _, @@ -919,21 +908,21 @@ impl crate::CommandEncoder for super::CommandEncoder { unsafe fn insert_debug_marker(&mut self, label: &str) { if let Some(encoder) = self.active_encoder() { - encoder.insert_debug_signpost(&NSString::from_str(label)); + encoder.insertDebugSignpost(&NSString::from_str(label)); } } unsafe fn begin_debug_marker(&mut self, group_label: &str) { if let Some(encoder) = self.active_encoder() { - encoder.push_debug_group(&NSString::from_str(group_label)); + encoder.pushDebugGroup(&NSString::from_str(group_label)); } else if let Some(ref buf) = self.raw_cmd_buf { - buf.push_debug_group(&NSString::from_str(group_label)); + buf.pushDebugGroup(&NSString::from_str(group_label)); } } unsafe fn end_debug_marker(&mut self) { if let Some(encoder) = self.active_encoder() { - encoder.pop_debug_group(); + encoder.popDebugGroup(); } else if let Some(ref buf) = self.raw_cmd_buf { - buf.pop_debug_group(); + buf.popDebugGroup(); } } @@ -946,16 +935,16 @@ impl crate::CommandEncoder for super::CommandEncoder { } let encoder = self.state.render.as_ref().unwrap(); - encoder.set_render_pipeline_state(&pipeline.raw); - encoder.set_front_facing_winding(pipeline.raw_front_winding); - encoder.set_cull_mode(pipeline.raw_cull_mode); - encoder.set_triangle_fill_mode(pipeline.raw_triangle_fill_mode); + encoder.setRenderPipelineState(&pipeline.raw); + encoder.setFrontFacingWinding(pipeline.raw_front_winding); + encoder.setCullMode(pipeline.raw_cull_mode); + encoder.setTriangleFillMode(pipeline.raw_triangle_fill_mode); if let Some(depth_clip) = pipeline.raw_depth_clip_mode { - encoder.set_depth_clip_mode(depth_clip); + encoder.setDepthClipMode(depth_clip); } if let Some((ref state, bias)) = pipeline.depth_stencil { - encoder.set_depth_stencil_state(Some(state)); - encoder.set_depth_bias_slope_scale_clamp( + encoder.setDepthStencilState(Some(state)); + encoder.setDepthBias_slopeScale_clamp( bias.constant as f32, bias.slope_scale, bias.clamp, @@ -967,7 +956,7 @@ impl crate::CommandEncoder for super::CommandEncoder { .state .make_sizes_buffer_update(naga::ShaderStage::Vertex, &mut self.temp.binding_sizes) { - encoder.set_vertex_bytes_length_at_index( + encoder.setVertexBytes_length_atIndex( NonNull::new(sizes.as_ptr().cast_mut().cast()).unwrap(), sizes.len() * WORD_SIZE, index as _, @@ -979,7 +968,7 @@ impl crate::CommandEncoder for super::CommandEncoder { .state .make_sizes_buffer_update(naga::ShaderStage::Fragment, &mut self.temp.binding_sizes) { - encoder.set_fragment_bytes_length_at_index( + encoder.setFragmentBytes_length_atIndex( NonNull::new(sizes.as_ptr().cast_mut().cast()).unwrap(), sizes.len() * WORD_SIZE, index as _, @@ -1012,7 +1001,7 @@ impl crate::CommandEncoder for super::CommandEncoder { ) { let buffer_index = self.shared.private_caps.max_vertex_buffers as u64 - 1 - index as u64; let encoder = self.state.render.as_ref().unwrap(); - encoder.setVertexBuffer_offset_atIndex_( + encoder.setVertexBuffer_offset_atIndex( Some(&binding.buffer.raw), binding.offset as usize, buffer_index as usize, @@ -1032,7 +1021,7 @@ impl crate::CommandEncoder for super::CommandEncoder { .state .make_sizes_buffer_update(naga::ShaderStage::Vertex, &mut self.temp.binding_sizes) { - encoder.set_vertex_bytes_length_at_index( + encoder.setVertexBytes_length_atIndex( NonNull::new(sizes.as_ptr().cast_mut().cast()).unwrap(), sizes.len() * WORD_SIZE, index as _, @@ -1047,7 +1036,7 @@ impl crate::CommandEncoder for super::CommandEncoder { depth_range.end }; let encoder = self.state.render.as_ref().unwrap(); - encoder.set_viewport(MTLViewport { + encoder.setViewport(MTLViewport { originX: rect.x as _, originY: rect.y as _, width: rect.w as _, @@ -1065,15 +1054,15 @@ impl crate::CommandEncoder for super::CommandEncoder { height: rect.h as _, }; let encoder = self.state.render.as_ref().unwrap(); - encoder.set_scissor_rect(scissor); + encoder.setScissorRect(scissor); } unsafe fn set_stencil_reference(&mut self, value: u32) { let encoder = self.state.render.as_ref().unwrap(); - encoder.set_stencil_front_reference_value_back_reference_value(value, value); + encoder.setStencilFrontReferenceValue_backReferenceValue(value, value); } unsafe fn set_blend_constants(&mut self, color: &[f32; 4]) { let encoder = self.state.render.as_ref().unwrap(); - encoder.set_blend_color_red_green_blue_alpha(color[0], color[1], color[2], color[3]); + encoder.setBlendColorRed_green_blue_alpha(color[0], color[1], color[2], color[3]); } unsafe fn draw( @@ -1085,7 +1074,7 @@ impl crate::CommandEncoder for super::CommandEncoder { ) { let encoder = self.state.render.as_ref().unwrap(); if first_instance != 0 { - encoder.draw_primitives_vertex_start_vertex_count_instance_count_base_instance( + encoder.drawPrimitives_vertexStart_vertexCount_instanceCount_baseInstance( self.state.raw_primitive_type, first_vertex as _, vertex_count as _, @@ -1093,14 +1082,14 @@ impl crate::CommandEncoder for super::CommandEncoder { first_instance as _, ); } else if instance_count != 1 { - encoder.draw_primitives_vertex_start_vertex_count_instance_count( + encoder.drawPrimitives_vertexStart_vertexCount_instanceCount( self.state.raw_primitive_type, first_vertex as _, vertex_count as _, instance_count as _, ); } else { - encoder.draw_primitives_vertex_start_vertex_count( + encoder.drawPrimitives_vertexStart_vertexCount( self.state.raw_primitive_type, first_vertex as _, vertex_count as _, @@ -1120,7 +1109,7 @@ impl crate::CommandEncoder for super::CommandEncoder { let index = self.state.index.as_ref().unwrap(); let offset = (index.offset + index.stride * first_index as wgt::BufferAddress) as usize; if base_vertex != 0 || first_instance != 0 { - encoder.draw_indexed_primitives_index_count_index_type_index_buffer_index_buffer_offset_instance_count_base_vertex_base_instance( + encoder.drawIndexedPrimitives_indexCount_indexType_indexBuffer_indexBufferOffset_instanceCount_baseVertex_baseInstance( self.state.raw_primitive_type, index_count as _, index.raw_type, @@ -1131,7 +1120,7 @@ impl crate::CommandEncoder for super::CommandEncoder { first_instance as _, ); } else if instance_count != 1 { - encoder.draw_indexed_primitives_index_count_index_type_index_buffer_index_buffer_offset_instance_count( + encoder.drawIndexedPrimitives_indexCount_indexType_indexBuffer_indexBufferOffset_instanceCount( self.state.raw_primitive_type, index_count as _, index.raw_type, @@ -1140,14 +1129,13 @@ impl crate::CommandEncoder for super::CommandEncoder { instance_count as _, ); } else { - encoder - .draw_indexed_primitives_index_count_index_type_index_buffer_index_buffer_offset( - self.state.raw_primitive_type, - index_count as _, - index.raw_type, - index.buffer_ptr.as_ref(), - offset, - ); + encoder.drawIndexedPrimitives_indexCount_indexType_indexBuffer_indexBufferOffset( + self.state.raw_primitive_type, + index_count as _, + index.raw_type, + index.buffer_ptr.as_ref(), + offset, + ); } } @@ -1159,7 +1147,7 @@ impl crate::CommandEncoder for super::CommandEncoder { ) { let encoder = self.state.render.as_ref().unwrap(); for _ in 0..draw_count { - encoder.draw_primitives_indirect_buffer_indirect_buffer_offset( + encoder.drawPrimitives_indirectBuffer_indirectBufferOffset( self.state.raw_primitive_type, &buffer.raw, offset as usize, @@ -1177,7 +1165,7 @@ impl crate::CommandEncoder for super::CommandEncoder { let encoder = self.state.render.as_ref().unwrap(); let index = self.state.index.as_ref().unwrap(); for _ in 0..draw_count { - encoder.draw_indexed_primitives_index_type_index_buffer_index_buffer_offset_indirect_buffer_indirect_buffer_offset( + encoder.drawIndexedPrimitives_indexType_indexBuffer_indexBufferOffset_indirectBuffer_indirectBufferOffset( self.state.raw_primitive_type, index.raw_type, index.buffer_ptr.as_ref(), @@ -1225,15 +1213,15 @@ impl crate::CommandEncoder for super::CommandEncoder { // TimeStamp Queries and ComputePassDescriptor were both introduced in Metal 2.3 (macOS 11, iOS 14) // and we currently only need ComputePassDescriptor for timestamp queries let encoder = if self.shared.private_caps.timestamp_query_support.is_empty() { - raw.compute_command_encoder().unwrap() + raw.computeCommandEncoder().unwrap() } else { let descriptor = MTLComputePassDescriptor::new(); let mut sba_index = 0; let mut next_sba_descriptor = || { let sba_descriptor = descriptor - .sample_buffer_attachments() - .object_at_indexed_subscript(sba_index); + .sampleBufferAttachments() + .objectAtIndexedSubscript(sba_index); sba_index += 1; sba_descriptor }; @@ -1241,14 +1229,14 @@ impl crate::CommandEncoder for super::CommandEncoder { for (set, index) in self.state.pending_timer_queries.drain(..) { let sba_descriptor = next_sba_descriptor(); sba_descriptor - .set_sample_buffer(Some(set.counter_sample_buffer.as_ref().unwrap())); - sba_descriptor.set_start_of_encoder_sample_index(index as _); - sba_descriptor.set_end_of_encoder_sample_index(MTLCounterDontSample); + .setSampleBuffer(Some(set.counter_sample_buffer.as_ref().unwrap())); + sba_descriptor.setStartOfEncoderSampleIndex(index as _); + sba_descriptor.setEndOfEncoderSampleIndex(MTLCounterDontSample); } if let Some(timestamp_writes) = desc.timestamp_writes.as_ref() { let sba_descriptor = next_sba_descriptor(); - sba_descriptor.set_sample_buffer(Some( + sba_descriptor.setSampleBuffer(Some( timestamp_writes .query_set .counter_sample_buffer @@ -1256,31 +1244,31 @@ impl crate::CommandEncoder for super::CommandEncoder { .unwrap(), )); - sba_descriptor.set_start_of_encoder_sample_index( + sba_descriptor.setStartOfEncoderSampleIndex( timestamp_writes .beginning_of_pass_write_index .map_or(MTLCounterDontSample, |i| i as _), ); - sba_descriptor.set_end_of_encoder_sample_index( + sba_descriptor.setEndOfEncoderSampleIndex( timestamp_writes .end_of_pass_write_index .map_or(MTLCounterDontSample, |i| i as _), ); } - raw.compute_command_encoder_with_descriptor(&descriptor) + raw.computeCommandEncoderWithDescriptor(&descriptor) .unwrap() }; if let Some(label) = desc.label { - encoder.set_label(Some(&NSString::from_str(label))); + encoder.setLabel(Some(&NSString::from_str(label))); } self.state.compute = Some(encoder.to_owned()); }); } unsafe fn end_compute_pass(&mut self) { - self.state.compute.take().unwrap().end_encoding(); + self.state.compute.take().unwrap().endEncoding(); } unsafe fn set_compute_pipeline(&mut self, pipeline: &super::ComputePipeline) { @@ -1288,13 +1276,13 @@ impl crate::CommandEncoder for super::CommandEncoder { self.state.stage_infos.cs.assign_from(&pipeline.cs_info); let encoder = self.state.compute.as_ref().unwrap(); - encoder.set_compute_pipeline_state(&pipeline.raw); + encoder.setComputePipelineState(&pipeline.raw); if let Some((index, sizes)) = self .state .make_sizes_buffer_update(naga::ShaderStage::Compute, &mut self.temp.binding_sizes) { - encoder.set_bytes_length_at_index( + encoder.setBytes_length_atIndex( NonNull::new(sizes.as_ptr().cast_mut().cast()).unwrap(), sizes.len() * WORD_SIZE, index as _, @@ -1316,7 +1304,7 @@ impl crate::CommandEncoder for super::CommandEncoder { let size = ((*pipeline_size - 1) | ALIGN_MASK) + 1; if *cur_size != size { *cur_size = size; - encoder.set_threadgroup_memory_length_at_index(size as _, index); + encoder.setThreadgroupMemoryLength_atIndex(size as _, index); } } } @@ -1329,14 +1317,17 @@ impl crate::CommandEncoder for super::CommandEncoder { height: count[1] as usize, depth: count[2] as usize, }; - encoder - .dispatch_threadgroups_threads_per_threadgroup(raw_count, self.state.raw_wg_size); + encoder.dispatchThreadgroups_threadsPerThreadgroup(raw_count, self.state.raw_wg_size); } } unsafe fn dispatch_indirect(&mut self, buffer: &super::Buffer, offset: wgt::BufferAddress) { let encoder = self.state.compute.as_ref().unwrap(); - encoder.dispatch_threadgroups_with_indirect_buffer_indirect_buffer_offset_threads_per_threadgroup(&buffer.raw, offset as usize, self.state.raw_wg_size); + encoder.dispatchThreadgroupsWithIndirectBuffer_indirectBufferOffset_threadsPerThreadgroup( + &buffer.raw, + offset as usize, + self.state.raw_wg_size, + ); } unsafe fn build_acceleration_structures<'a, T>( @@ -1374,7 +1365,7 @@ impl Drop for super::CommandEncoder { // appears to be a requirement for all MTLCommandEncoder objects. Failing to call // endEncoding causes a crash with the message 'Command encoder released without // endEncoding'. To prevent this, we explicitiy call discard_encoding, which - // calls end_encoding on any still-held MTLCommandEncoders. + // calls endEncoding on any still-held MTLCommandEncoders. unsafe { self.discard_encoding(); } diff --git a/wgpu-hal/src/metal/device.rs b/wgpu-hal/src/metal/device.rs index 667238d374..43047c7bcf 100644 --- a/wgpu-hal/src/metal/device.rs +++ b/wgpu-hal/src/metal/device.rs @@ -52,12 +52,12 @@ fn create_stencil_desc( write_mask: u32, ) -> Retained { let desc = unsafe { MTLStencilDescriptor::new() }; - desc.set_stencil_compare_function(conv::map_compare_function(face.compare)); - desc.set_read_mask(read_mask); - desc.set_write_mask(write_mask); - desc.set_stencil_failure_operation(conv::map_stencil_op(face.fail_op)); - desc.set_depth_failure_operation(conv::map_stencil_op(face.depth_fail_op)); - desc.set_depth_stencil_pass_operation(conv::map_stencil_op(face.pass_op)); + desc.setStencilCompareFunction(conv::map_compare_function(face.compare)); + desc.setReadMask(read_mask); + desc.setWriteMask(write_mask); + desc.setStencilFailureOperation(conv::map_stencil_op(face.fail_op)); + desc.setDepthFailureOperation(conv::map_stencil_op(face.depth_fail_op)); + desc.setDepthStencilPassOperation(conv::map_stencil_op(face.pass_op)); desc } @@ -65,14 +65,14 @@ fn create_depth_stencil_desc( state: &wgt::DepthStencilState, ) -> Retained { let desc = unsafe { MTLDepthStencilDescriptor::new() }; - desc.set_depth_compare_function(conv::map_compare_function(state.depth_compare)); - desc.set_depth_write_enabled(state.depth_write_enabled); + desc.setDepthCompareFunction(conv::map_compare_function(state.depth_compare)); + desc.setDepthWriteEnabled(state.depth_write_enabled); let s = &state.stencil; if s.is_enabled() { let front_desc = create_stencil_desc(&s.front, s.read_mask, s.write_mask); - desc.set_front_face_stencil(Some(&front_desc)); + desc.setFrontFaceStencil(Some(&front_desc)); let back_desc = create_stencil_desc(&s.back, s.read_mask, s.write_mask); - desc.set_back_face_stencil(Some(&back_desc)); + desc.setBackFaceStencil(Some(&back_desc)); } desc } @@ -211,17 +211,17 @@ impl super::Device { ); let options = MTLCompileOptions::new(); - options.set_language_version(self.shared.private_caps.msl_version); + options.setLanguageVersion(self.shared.private_caps.msl_version); if self.shared.private_caps.supports_preserve_invariance { - options.set_preserve_invariance(true); + options.setPreserveInvariance(true); } let library = self .shared .device .lock() - .new_library_with_source_options_error(&NSString::from_str(&source), Some(&options)) + .newLibraryWithSource_options_error(&NSString::from_str(&source), Some(&options)) .map_err(|err| { log::warn!("Naga generated shader:\n{}", source); crate::PipelineError::Linkage(stage_bit, format!("Metal: {}", err)) @@ -244,7 +244,7 @@ impl super::Device { }; let function = library - .new_function_with_name(&NSString::from_str(ep_name)) + .newFunctionWithName(&NSString::from_str(ep_name)) .ok_or_else(|| { log::error!("Function '{ep_name}' does not exist"); crate::PipelineError::EntryPoint(naga_stage) @@ -315,8 +315,8 @@ impl super::Device { while immutable_mask != 0 { let slot = immutable_mask.trailing_zeros(); immutable_mask ^= 1 << slot; - unsafe { buffers.object_at_indexed_subscript(slot as usize) } - .set_mutability(MTLMutability::Immutable); + unsafe { buffers.objectAtIndexedSubscript(slot as usize) } + .setMutability(MTLMutability::Immutable); } } @@ -384,10 +384,10 @@ impl crate::Device for super::Device { .shared .device .lock() - .new_buffer_with_length_options(desc.size as usize, options) + .newBufferWithLength_options(desc.size as usize, options) .unwrap(); if let Some(label) = desc.label { - raw.set_label(Some(&NSString::from_str(label))); + raw.setLabel(Some(&NSString::from_str(label))); } self.counters.buffers.add(1); Ok(super::Buffer { @@ -433,37 +433,37 @@ impl crate::Device for super::Device { wgt::TextureDimension::D1 => MTLTextureType::Type1D, wgt::TextureDimension::D2 => { if desc.sample_count > 1 { - descriptor.set_sample_count(desc.sample_count as usize); + descriptor.setSampleCount(desc.sample_count as usize); MTLTextureType::Type2DMultisample } else if desc.size.depth_or_array_layers > 1 { - descriptor.set_array_length(desc.size.depth_or_array_layers as usize); + descriptor.setArrayLength(desc.size.depth_or_array_layers as usize); MTLTextureType::Type2DArray } else { MTLTextureType::Type2D } } wgt::TextureDimension::D3 => { - descriptor.set_depth(desc.size.depth_or_array_layers as usize); + descriptor.setDepth(desc.size.depth_or_array_layers as usize); MTLTextureType::Type3D } }; - descriptor.set_texture_type(mtl_type); - descriptor.set_width(desc.size.width as usize); - descriptor.set_height(desc.size.height as usize); - descriptor.set_mipmap_level_count(desc.mip_level_count as usize); - descriptor.set_pixel_format(mtl_format); - descriptor.set_usage(conv::map_texture_usage(desc.format, desc.usage)); - descriptor.set_storage_mode(MTLStorageMode::Private); + descriptor.setTextureType(mtl_type); + descriptor.setWidth(desc.size.width as usize); + descriptor.setHeight(desc.size.height as usize); + descriptor.setMipmapLevelCount(desc.mip_level_count as usize); + descriptor.setPixelFormat(mtl_format); + descriptor.setUsage(conv::map_texture_usage(desc.format, desc.usage)); + descriptor.setStorageMode(MTLStorageMode::Private); let raw = self .shared .device .lock() - .new_texture_with_descriptor(&descriptor) + .newTextureWithDescriptor(&descriptor) .ok_or(crate::DeviceError::OutOfMemory)?; if let Some(label) = desc.label { - raw.set_label(Some(&NSString::from_str(label))); + raw.setLabel(Some(&NSString::from_str(label))); } self.counters.textures.add(1); @@ -528,7 +528,7 @@ impl crate::Device for super::Device { autoreleasepool(|_| { let raw = texture .raw - .new_texture_view_with_pixel_format_texture_type_levels_slices( + .newTextureViewWithPixelFormat_textureType_levels_slices( raw_format, raw_type, NSRange { @@ -542,7 +542,7 @@ impl crate::Device for super::Device { ) .unwrap(); if let Some(label) = desc.label { - raw.set_label(Some(&NSString::from_str(label))); + raw.setLabel(Some(&NSString::from_str(label))); } raw }) @@ -564,9 +564,9 @@ impl crate::Device for super::Device { autoreleasepool(|_| { let descriptor = MTLSamplerDescriptor::new(); - descriptor.set_min_filter(conv::map_filter_mode(desc.min_filter)); - descriptor.set_mag_filter(conv::map_filter_mode(desc.mag_filter)); - descriptor.set_mip_filter(match desc.mipmap_filter { + descriptor.setMinFilter(conv::map_filter_mode(desc.min_filter)); + descriptor.setMagFilter(conv::map_filter_mode(desc.mag_filter)); + descriptor.setMipFilter(match desc.mipmap_filter { wgt::FilterMode::Nearest if desc.lod_clamp == (0.0..0.0) => { MTLSamplerMipFilter::NotMipmapped } @@ -575,49 +575,49 @@ impl crate::Device for super::Device { }); let [s, t, r] = desc.address_modes; - descriptor.set_s_address_mode(conv::map_address_mode(s)); - descriptor.set_t_address_mode(conv::map_address_mode(t)); - descriptor.set_r_address_mode(conv::map_address_mode(r)); + descriptor.setSAddressMode(conv::map_address_mode(s)); + descriptor.setTAddressMode(conv::map_address_mode(t)); + descriptor.setRAddressMode(conv::map_address_mode(r)); // Anisotropy is always supported on mac up to 16x - descriptor.set_max_anisotropy(desc.anisotropy_clamp as _); + descriptor.setMaxAnisotropy(desc.anisotropy_clamp as _); - descriptor.set_lod_min_clamp(desc.lod_clamp.start); - descriptor.set_lod_max_clamp(desc.lod_clamp.end); + descriptor.setLodMinClamp(desc.lod_clamp.start); + descriptor.setLodMaxClamp(desc.lod_clamp.end); if let Some(fun) = desc.compare { - descriptor.set_compare_function(conv::map_compare_function(fun)); + descriptor.setCompareFunction(conv::map_compare_function(fun)); } if let Some(border_color) = desc.border_color { if let wgt::SamplerBorderColor::Zero = border_color { if s == wgt::AddressMode::ClampToBorder { - descriptor.set_s_address_mode(MTLSamplerAddressMode::ClampToZero); + descriptor.setSAddressMode(MTLSamplerAddressMode::ClampToZero); } if t == wgt::AddressMode::ClampToBorder { - descriptor.set_t_address_mode(MTLSamplerAddressMode::ClampToZero); + descriptor.setTAddressMode(MTLSamplerAddressMode::ClampToZero); } if r == wgt::AddressMode::ClampToBorder { - descriptor.set_r_address_mode(MTLSamplerAddressMode::ClampToZero); + descriptor.setRAddressMode(MTLSamplerAddressMode::ClampToZero); } } else { - descriptor.set_border_color(conv::map_border_color(border_color)); + descriptor.setBorderColor(conv::map_border_color(border_color)); } } if let Some(label) = desc.label { - descriptor.set_label(Some(&NSString::from_str(label))); + descriptor.setLabel(Some(&NSString::from_str(label))); } if self.features.contains(wgt::Features::TEXTURE_BINDING_ARRAY) { - descriptor.set_support_argument_buffers(true); + descriptor.setSupportArgumentBuffers(true); } let raw = self .shared .device .lock() - .new_sampler_state_with_descriptor(&descriptor) + .newSamplerStateWithDescriptor(&descriptor) .unwrap(); self.counters.samplers.add(1); @@ -876,7 +876,7 @@ impl crate::Device for super::Device { .shared .device .lock() - .new_buffer_with_length_options( + .newBufferWithLength_options( 8 * count as usize, MTLResourceOptions::HazardTrackingModeUntracked | MTLResourceOptions::StorageModeShared, @@ -898,7 +898,7 @@ impl crate::Device for super::Device { let textures = &desc.textures[start..end]; for (idx, tex) in textures.iter().enumerate() { - contents[idx] = tex.view.raw.gpu_resource_id(); + contents[idx] = tex.view.raw.gpuResourceID(); let use_info = bg .resources_to_use @@ -916,7 +916,7 @@ impl crate::Device for super::Device { let samplers = &desc.samplers[start..end]; for (idx, &sampler) in samplers.iter().enumerate() { - contents[idx] = sampler.raw.gpu_resource_id(); + contents[idx] = sampler.raw.gpuResourceID(); // Samplers aren't resources like buffers and textures, so don't // need to be passed to useResource } @@ -1103,10 +1103,10 @@ impl crate::Device for super::Device { naga::ShaderStage::Vertex, )?; - descriptor.set_vertex_function(Some(&vs.function)); + descriptor.setVertexFunction(Some(&vs.function)); if self.shared.private_caps.supports_mutability { Self::set_buffers_mutability( - &descriptor.vertex_buffers(), + &descriptor.vertexBuffers(), vs.immutable_buffer_mask, ); } @@ -1132,10 +1132,10 @@ impl crate::Device for super::Device { naga::ShaderStage::Fragment, )?; - descriptor.set_fragment_function(Some(&fs.function)); + descriptor.setFragmentFunction(Some(&fs.function)); if self.shared.private_caps.supports_mutability { Self::set_buffers_mutability( - &descriptor.fragment_buffers(), + &descriptor.fragmentBuffers(), fs.immutable_buffer_mask, ); } @@ -1153,39 +1153,37 @@ impl crate::Device for super::Device { // TODO: This is a workaround for what appears to be a Metal validation bug // A pixel format is required even though no attachments are provided if desc.color_targets.is_empty() && desc.depth_stencil.is_none() { - descriptor.set_depth_attachment_pixel_format(MTLPixelFormat::Depth32Float); + descriptor.setDepthAttachmentPixelFormat(MTLPixelFormat::Depth32Float); } (None, None) } }; for (i, ct) in desc.color_targets.iter().enumerate() { - let at_descriptor = descriptor - .color_attachments() - .object_at_indexed_subscript(i); + let at_descriptor = descriptor.colorAttachments().objectAtIndexedSubscript(i); let ct = if let Some(color_target) = ct.as_ref() { color_target } else { - at_descriptor.set_pixel_format(MTLPixelFormat::Invalid); + at_descriptor.setPixelFormat(MTLPixelFormat::Invalid); continue; }; let raw_format = self.shared.private_caps.map_format(ct.format); - at_descriptor.set_pixel_format(raw_format); - at_descriptor.set_write_mask(conv::map_color_write(ct.write_mask)); + at_descriptor.setPixelFormat(raw_format); + at_descriptor.setWriteMask(conv::map_color_write(ct.write_mask)); if let Some(ref blend) = ct.blend { - at_descriptor.set_blending_enabled(true); + at_descriptor.setBlendingEnabled(true); let (color_op, color_src, color_dst) = conv::map_blend_component(&blend.color); let (alpha_op, alpha_src, alpha_dst) = conv::map_blend_component(&blend.alpha); - at_descriptor.set_rgb_blend_operation(color_op); - at_descriptor.set_source_rgb_blend_factor(color_src); - at_descriptor.set_destination_rgb_blend_factor(color_dst); + at_descriptor.setRgbBlendOperation(color_op); + at_descriptor.setSourceRGBBlendFactor(color_src); + at_descriptor.setDestinationRGBBlendFactor(color_dst); - at_descriptor.set_alpha_blend_operation(alpha_op); - at_descriptor.set_source_alpha_blend_factor(alpha_src); - at_descriptor.set_destination_alpha_blend_factor(alpha_dst); + at_descriptor.setAlphaBlendOperation(alpha_op); + at_descriptor.setSourceAlphaBlendFactor(alpha_src); + at_descriptor.setDestinationAlphaBlendFactor(alpha_dst); } } @@ -1194,10 +1192,10 @@ impl crate::Device for super::Device { let raw_format = self.shared.private_caps.map_format(ds.format); let aspects = crate::FormatAspects::from(ds.format); if aspects.contains(crate::FormatAspects::DEPTH) { - descriptor.set_depth_attachment_pixel_format(raw_format); + descriptor.setDepthAttachmentPixelFormat(raw_format); } if aspects.contains(crate::FormatAspects::STENCIL) { - descriptor.set_stencil_attachment_pixel_format(raw_format); + descriptor.setStencilAttachmentPixelFormat(raw_format); } let ds_descriptor = create_depth_stencil_desc(ds); @@ -1205,7 +1203,7 @@ impl crate::Device for super::Device { .shared .device .lock() - .new_depth_stencil_state_with_descriptor(&ds_descriptor) + .newDepthStencilStateWithDescriptor(&ds_descriptor) .unwrap(); Some((raw, ds.bias)) } @@ -1233,7 +1231,7 @@ impl crate::Device for super::Device { self.shared.private_caps.max_vertex_buffers as u64 - 1 - i as u64; let buffer_desc = vertex_descriptor .layouts() - .object_at_indexed_subscript(buffer_index as usize); + .objectAtIndexedSubscript(buffer_index as usize); // Metal expects the stride to be the actual size of the attributes. // The semantics of array_stride == 0 can be achieved by setting @@ -1245,44 +1243,43 @@ impl crate::Device for super::Device { .map(|attribute| attribute.offset + attribute.format.size()) .max() .unwrap_or(0); - buffer_desc.set_stride(wgt::math::align_to(stride as usize, 4)); - buffer_desc.set_step_function(MTLVertexStepFunction::Constant); - buffer_desc.set_step_rate(0); + buffer_desc.setStride(wgt::math::align_to(stride as usize, 4)); + buffer_desc.setStepFunction(MTLVertexStepFunction::Constant); + buffer_desc.setStepRate(0); } else { - buffer_desc.set_stride(vb.array_stride as usize); - buffer_desc.set_step_function(conv::map_step_mode(vb.step_mode)); + buffer_desc.setStride(vb.array_stride as usize); + buffer_desc.setStepFunction(conv::map_step_mode(vb.step_mode)); } for at in vb.attributes { let attribute_desc = vertex_descriptor .attributes() - .object_at_indexed_subscript(at.shader_location as usize); - attribute_desc.set_format(conv::map_vertex_format(at.format)); - attribute_desc.set_buffer_index(buffer_index as usize); - attribute_desc.set_offset(at.offset as usize); + .objectAtIndexedSubscript(at.shader_location as usize); + attribute_desc.setFormat(conv::map_vertex_format(at.format)); + attribute_desc.setBufferIndex(buffer_index as usize); + attribute_desc.setOffset(at.offset as usize); } } - descriptor.set_vertex_descriptor(Some(&vertex_descriptor)); + descriptor.setVertexDescriptor(Some(&vertex_descriptor)); } if desc.multisample.count != 1 { //TODO: handle sample mask #[allow(deprecated)] - descriptor.set_sample_count(desc.multisample.count as usize); - descriptor - .set_alpha_to_coverage_enabled(desc.multisample.alpha_to_coverage_enabled); + descriptor.setSampleCount(desc.multisample.count as usize); + descriptor.setAlphaToCoverageEnabled(desc.multisample.alpha_to_coverage_enabled); //descriptor.set_alpha_to_one_enabled(desc.multisample.alpha_to_one_enabled); } if let Some(name) = desc.label { - descriptor.set_label(Some(&NSString::from_str(name))); + descriptor.setLabel(Some(&NSString::from_str(name))); } let raw = self .shared .device .lock() - .new_render_pipeline_state_with_descriptor_error(&descriptor) + .newRenderPipelineStateWithDescriptor_error(&descriptor) .map_err(|e| { crate::PipelineError::Linkage( wgt::ShaderStages::VERTEX | wgt::ShaderStages::FRAGMENT, @@ -1338,7 +1335,7 @@ impl crate::Device for super::Device { MTLPrimitiveTopologyClass::Unspecified, naga::ShaderStage::Compute, )?; - descriptor.set_compute_function(Some(&cs.function)); + descriptor.setComputeFunction(Some(&cs.function)); if self.shared.private_caps.supports_mutability { Self::set_buffers_mutability(&descriptor.buffers(), cs.immutable_buffer_mask); @@ -1352,7 +1349,7 @@ impl crate::Device for super::Device { }; if let Some(name) = desc.label { - descriptor.set_label(Some(&NSString::from_str(name))); + descriptor.setLabel(Some(&NSString::from_str(name))); } let raw = @@ -1402,10 +1399,10 @@ impl crate::Device for super::Device { .shared .device .lock() - .new_buffer_with_length_options(size as usize, options) + .newBufferWithLength_options(size as usize, options) .unwrap(); if let Some(label) = desc.label { - raw_buffer.set_label(Some(&NSString::from_str(label))); + raw_buffer.setLabel(Some(&NSString::from_str(label))); } Ok(super::QuerySet { raw_buffer, @@ -1417,17 +1414,17 @@ impl crate::Device for super::Device { let size = desc.count as u64 * crate::QUERY_SIZE; let device = self.shared.device.lock(); let destination_buffer = device - .new_buffer_with_length_options(size as usize, MTLResourceOptions::empty()) + .newBufferWithLength_options(size as usize, MTLResourceOptions::empty()) .unwrap(); let csb_desc = MTLCounterSampleBufferDescriptor::new(); - csb_desc.set_storage_mode(MTLStorageMode::Shared); - csb_desc.set_sample_count(desc.count as _); + csb_desc.setStorageMode(MTLStorageMode::Shared); + csb_desc.setSampleCount(desc.count as _); if let Some(label) = desc.label { - csb_desc.set_label(&NSString::from_str(label)); + csb_desc.setLabel(&NSString::from_str(label)); } - let counter_sets = device.counter_sets().unwrap(); + let counter_sets = device.counterSets().unwrap(); let timestamp_counter = match counter_sets .iter() .find(|cs| &*cs.name() == ns_string!("timestamp")) @@ -1438,10 +1435,10 @@ impl crate::Device for super::Device { return Err(crate::DeviceError::ResourceCreationFailed); } }; - csb_desc.set_counter_set(Some(×tamp_counter)); + csb_desc.setCounterSet(Some(×tamp_counter)); let counter_sample_buffer = - match device.new_counter_sample_buffer_with_descriptor_error(&csb_desc) { + match device.newCounterSampleBufferWithDescriptor_error(&csb_desc) { Ok(buffer) => buffer, Err(err) => { log::error!("Failed to create counter sample buffer: {:?}", err); @@ -1471,7 +1468,7 @@ impl crate::Device for super::Device { unsafe fn create_fence(&self) -> DeviceResult { self.counters.fences.add(1); let shared_event = if self.shared.private_caps.supports_shared_event { - Some(self.shared.device.lock().new_shared_event().unwrap()) + Some(self.shared.device.lock().newSharedEvent().unwrap()) } else { None }; @@ -1534,20 +1531,20 @@ impl crate::Device for super::Device { return false; } let device = self.shared.device.lock(); - let shared_capture_manager = MTLCaptureManager::shared_capture_manager(); - let default_capture_scope = shared_capture_manager.new_capture_scope_with_device(&device); - shared_capture_manager.set_default_capture_scope(Some(&default_capture_scope)); + let shared_capture_manager = MTLCaptureManager::sharedCaptureManager(); + let default_capture_scope = shared_capture_manager.newCaptureScopeWithDevice(&device); + shared_capture_manager.setDefaultCaptureScope(Some(&default_capture_scope)); #[allow(deprecated)] - shared_capture_manager.start_capture_with_scope(&default_capture_scope); - default_capture_scope.begin_scope(); + shared_capture_manager.startCaptureWithScope(&default_capture_scope); + default_capture_scope.beginScope(); true } unsafe fn stop_capture(&self) { - let shared_capture_manager = MTLCaptureManager::shared_capture_manager(); - if let Some(default_capture_scope) = shared_capture_manager.default_capture_scope() { - default_capture_scope.end_scope(); + let shared_capture_manager = MTLCaptureManager::sharedCaptureManager(); + if let Some(default_capture_scope) = shared_capture_manager.defaultCaptureScope() { + default_capture_scope.endScope(); } - shared_capture_manager.stop_capture(); + shared_capture_manager.stopCapture(); } unsafe fn get_acceleration_structure_build_sizes( diff --git a/wgpu-hal/src/metal/mod.rs b/wgpu-hal/src/metal/mod.rs index 12b4262ef5..3e0609f857 100644 --- a/wgpu-hal/src/metal/mod.rs +++ b/wgpu-hal/src/metal/mod.rs @@ -439,11 +439,11 @@ impl crate::Queue for Queue { Some(&cmd_buf) => cmd_buf.raw.clone(), None => { let queue = self.raw.lock(); - queue.command_buffer_with_unretained_references().unwrap() + queue.commandBufferWithUnretainedReferences().unwrap() } }; - raw.set_label(Some(ns_string!("(wgpu internal) Signal"))); - raw.add_completed_handler(block.cast_mut()); + raw.setLabel(Some(ns_string!("(wgpu internal) Signal"))); + raw.addCompletedHandler(block.cast_mut()); signal_fence.maintain(); signal_fence @@ -451,7 +451,7 @@ impl crate::Queue for Queue { .push((signal_value, raw.clone())); if let Some(shared_event) = &signal_fence.shared_event { - raw.encode_signal_event_value(shared_event.as_ref(), signal_value); + raw.encodeSignalEvent_value(shared_event.as_ref(), signal_value); } // only return an extra one if it's extra match command_buffers.last() { @@ -477,18 +477,18 @@ impl crate::Queue for Queue { ) -> Result<(), crate::SurfaceError> { let queue = &self.raw.lock(); autoreleasepool(|_| { - let command_buffer = queue.command_buffer().unwrap(); - command_buffer.set_label(Some(ns_string!("(wgpu internal) Present"))); + let command_buffer = queue.commandBuffer().unwrap(); + command_buffer.setLabel(Some(ns_string!("(wgpu internal) Present"))); // https://developer.apple.com/documentation/quartzcore/cametallayer/1478157-presentswithtransaction?language=objc if !texture.present_with_transaction { - command_buffer.present_drawable(&texture.drawable); + command_buffer.presentDrawable(&texture.drawable); } command_buffer.commit(); if texture.present_with_transaction { - command_buffer.wait_until_scheduled(); + command_buffer.waitUntilScheduled(); texture.drawable.present(); } }); diff --git a/wgpu-hal/src/metal/surface.rs b/wgpu-hal/src/metal/surface.rs index 6f7cdb3c14..d5fd01f2d8 100644 --- a/wgpu-hal/src/metal/surface.rs +++ b/wgpu-hal/src/metal/surface.rs @@ -189,7 +189,7 @@ impl super::Surface { // Create a new sublayer. let new_layer = CAMetalLayer::new(); - root_layer.add_sublayer(&new_layer); + root_layer.addSublayer(&new_layer); #[cfg(target_os = "macos")] { @@ -208,13 +208,13 @@ impl super::Surface { // (as we may do, see above). let mask = CAAutoresizingMask::LayerWidthSizable | CAAutoresizingMask::LayerHeightSizable; - new_layer.set_autoresizing_mask(mask); + new_layer.setAutoresizingMask(mask); } // Specify the relative size that the auto resizing mask above // will keep (i.e. tell it to fill out its superlayer). let frame = root_layer.bounds(); - new_layer.set_frame(frame); + new_layer.setFrame(frame); // The gravity to use when the layer's `drawableSize` isn't the // same as the bounds rectangle. @@ -227,12 +227,12 @@ impl super::Surface { // Unfortunately, it also makes it harder to see changes to // `width` and `height` in `configure`. When debugging resize // issues, swap this for `kCAGravityTopLeft` instead. - new_layer.set_contents_gravity(unsafe { kCAGravityResize }); + new_layer.setContentsGravity(unsafe { kCAGravityResize }); // Set initial scale factor of the layer. This is kept in sync by // `configure` (on UIKit), and the delegate below (on AppKit). - let scale_factor = root_layer.contents_scale(); - new_layer.set_contents_scale(scale_factor); + let scale_factor = root_layer.contentsScale(); + new_layer.setContentsScale(scale_factor); let delegate = HalManagedMetalLayerDelegate::new(); let () = msg_send![&new_layer, setDelegate: delegate.0]; @@ -245,7 +245,7 @@ impl super::Surface { let (size, scale) = { let render_layer = self.render_layer.lock(); let bounds = render_layer.bounds(); - let contents_scale = render_layer.contents_scale(); + let contents_scale = render_layer.contentsScale(); (bounds.size, contents_scale) }; @@ -281,8 +281,8 @@ impl crate::Surface for super::Surface { let drawable_size = CGSize::new(config.extent.width as f64, config.extent.height as f64); match config.composite_alpha_mode { - wgt::CompositeAlphaMode::Opaque => render_layer.set_opaque(true), - wgt::CompositeAlphaMode::PostMultiplied => render_layer.set_opaque(false), + wgt::CompositeAlphaMode::Opaque => render_layer.setOpaque(true), + wgt::CompositeAlphaMode::PostMultiplied => render_layer.setOpaque(false), _ => (), } @@ -303,31 +303,31 @@ impl crate::Surface for super::Surface { #[cfg(not(target_os = "macos"))] { if let Some(superlayer) = render_layer.superlayer() { - let scale_factor = superlayer.contents_scale(); - render_layer.set_contents_scale(scale_factor); + let scale_factor = superlayer.contentsScale(); + render_layer.setContentsScale(scale_factor); } } let device_raw = device.shared.device.lock(); - render_layer.set_device(Some(&device_raw)); - render_layer.set_pixel_format(caps.map_format(config.format)); - render_layer.set_framebuffer_only(framebuffer_only); - render_layer.set_presents_with_transaction(self.present_with_transaction); + render_layer.setDevice(Some(&device_raw)); + render_layer.setPixelFormat(caps.map_format(config.format)); + render_layer.setFramebufferOnly(framebuffer_only); + render_layer.setPresentsWithTransaction(self.present_with_transaction); // opt-in to Metal EDR // EDR potentially more power used in display and more bandwidth, memory footprint. let wants_edr = config.format == wgt::TextureFormat::Rgba16Float; - if wants_edr != render_layer.wants_extended_dynamic_range_content() { - render_layer.set_wants_extended_dynamic_range_content(wants_edr); + if wants_edr != render_layer.wantsExtendedDynamicRangeContent() { + render_layer.setWantsExtendedDynamicRangeContent(wants_edr); } // this gets ignored on iOS for certain OS/device combinations (iphone5s iOS 10.3) - render_layer.set_maximum_drawable_count(config.maximum_frame_latency as usize + 1); - render_layer.set_drawable_size(drawable_size); + render_layer.setMaximumDrawableCount(config.maximum_frame_latency as usize + 1); + render_layer.setDrawableSize(drawable_size); if caps.can_set_next_drawable_timeout { - render_layer.set_allows_next_drawable_timeout(false); + render_layer.setAllowsNextDrawableTimeout(false); } if caps.can_set_display_sync { - render_layer.set_display_sync_enabled(display_sync); + render_layer.setDisplaySyncEnabled(display_sync); } Ok(()) @@ -345,7 +345,7 @@ impl crate::Surface for super::Surface { let render_layer = self.render_layer.lock(); let (drawable, texture) = match autoreleasepool(|_| { render_layer - .next_drawable() + .nextDrawable() .map(|drawable| (drawable.to_owned(), drawable.texture().to_owned())) }) { Some(pair) => pair,