Skip to content

Commit bb64822

Browse files
committed
Fix setLabel calls
1 parent 943f2a7 commit bb64822

File tree

1 file changed

+8
-18
lines changed

1 file changed

+8
-18
lines changed

wgpu-hal/src/metal/device.rs

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
use objc2::{msg_send, msg_send_id, rc::Retained, runtime::ProtocolObject};
1+
use objc2::{msg_send_id, rc::Retained, runtime::ProtocolObject};
22
use objc2_foundation::{ns_string, NSError, NSRange, NSString};
33
use objc2_metal::{
44
MTLBuffer, MTLCaptureManager, MTLCaptureScope, MTLCommandBuffer, MTLCommandBufferStatus,
55
MTLCompileOptions, MTLComputePipelineDescriptor, MTLComputePipelineState,
66
MTLCounterSampleBufferDescriptor, MTLCounterSet, MTLDepthClipMode, MTLDepthStencilDescriptor,
77
MTLDevice, MTLFunction, MTLLanguageVersion, MTLLibrary, MTLMutability,
88
MTLPipelineBufferDescriptorArray, MTLPixelFormat, MTLPrimitiveTopologyClass,
9-
MTLRenderPipelineDescriptor, MTLResourceOptions, MTLSamplerAddressMode, MTLSamplerDescriptor,
10-
MTLSamplerMipFilter, MTLSize, MTLStencilDescriptor, MTLStorageMode, MTLTexture,
11-
MTLTextureDescriptor, MTLTextureType, MTLTriangleFillMode, MTLVertexDescriptor,
9+
MTLRenderPipelineDescriptor, MTLResource, MTLResourceOptions, MTLSamplerAddressMode,
10+
MTLSamplerDescriptor, MTLSamplerMipFilter, MTLSize, MTLStencilDescriptor, MTLStorageMode,
11+
MTLTexture, MTLTextureDescriptor, MTLTextureType, MTLTriangleFillMode, MTLVertexDescriptor,
1212
MTLVertexStepFunction,
1313
};
1414
use parking_lot::Mutex;
@@ -332,7 +332,7 @@ impl crate::Device for super::Device {
332332
.newBufferWithLength_options(desc.size as usize, options)
333333
.unwrap();
334334
if let Some(label) = desc.label {
335-
set_buffer_label(&raw, Some(&NSString::from_str(label)));
335+
raw.setLabel(Some(&NSString::from_str(label)));
336336
}
337337
Ok(super::Buffer {
338338
raw,
@@ -403,7 +403,7 @@ impl crate::Device for super::Device {
403403
.newTextureWithDescriptor(&descriptor)
404404
.ok_or(crate::DeviceError::OutOfMemory)?;
405405
if let Some(label) = desc.label {
406-
set_texture_label(&raw, Some(&NSString::from_str(label)));
406+
raw.setLabel(Some(&NSString::from_str(label)));
407407
}
408408

409409
Ok(super::Texture {
@@ -474,7 +474,7 @@ impl crate::Device for super::Device {
474474
)
475475
.unwrap();
476476
if let Some(label) = desc.label {
477-
set_texture_label(&raw, Some(&NSString::from_str(label)));
477+
raw.setLabel(Some(&NSString::from_str(label)));
478478
}
479479
raw
480480
})
@@ -1155,7 +1155,7 @@ impl crate::Device for super::Device {
11551155
.newBufferWithLength_options(size as usize, options)
11561156
.unwrap();
11571157
if let Some(label) = desc.label {
1158-
set_buffer_label(&raw_buffer, Some(&NSString::from_str(label)));
1158+
raw_buffer.setLabel(Some(&NSString::from_str(label)));
11591159
}
11601160
Ok(super::QuerySet {
11611161
raw_buffer,
@@ -1313,16 +1313,6 @@ impl crate::Device for super::Device {
13131313
}
13141314
}
13151315

1316-
// TODO: `label` is not exposed on `MTLBuffer`, is this always correct?
1317-
fn set_buffer_label(buffer: &ProtocolObject<dyn MTLBuffer>, label: Option<&NSString>) {
1318-
unsafe { msg_send![buffer, setLabel: label] }
1319-
}
1320-
1321-
// TODO: `label` is not exposed on `MTLTexture`, is this always correct?
1322-
fn set_texture_label(buffer: &ProtocolObject<dyn MTLTexture>, label: Option<&NSString>) {
1323-
unsafe { msg_send![buffer, setLabel: label] }
1324-
}
1325-
13261316
// TODO: `newComputePipelineStateWithDescriptor:error:` is not exposed on
13271317
// `MTLDevice`, is this always correct?
13281318
fn new_compute_pipeline_state_with_descriptor(

0 commit comments

Comments
 (0)