Skip to content

Commit

Permalink
Fix accelerator structure descriptor methods
Browse files Browse the repository at this point in the history
These return a +0 autoreleased pointer, so we have to retain them
ourselves before we put them in the strong smart pointer created by
`foreign_obj_type!`.
  • Loading branch information
madsmtm authored and grovesNL committed May 23, 2024
1 parent 6b7e39d commit 2094924
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions src/accelerator_structure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,9 @@ impl PrimitiveAccelerationStructureDescriptor {
pub fn descriptor() -> Self {
unsafe {
let class = class!(MTLPrimitiveAccelerationStructureDescriptor);
msg_send![class, descriptor]
let ptr: *mut Object = msg_send![class, descriptor];
let ptr: *mut Object = msg_send![ptr, retain];
Self::from_ptr(ptr as _)
}
}
}
Expand Down Expand Up @@ -150,7 +152,9 @@ impl AccelerationStructureTriangleGeometryDescriptor {
pub fn descriptor() -> Self {
unsafe {
let class = class!(MTLAccelerationStructureTriangleGeometryDescriptor);
msg_send![class, descriptor]
let ptr: *mut Object = msg_send![class, descriptor];
let ptr: *mut Object = msg_send![ptr, retain];
Self::from_ptr(ptr as _)
}
}
}
Expand Down Expand Up @@ -209,7 +213,9 @@ impl AccelerationStructureBoundingBoxGeometryDescriptor {
pub fn descriptor() -> Self {
unsafe {
let class = class!(MTLAccelerationStructureBoundingBoxGeometryDescriptor);
msg_send![class, descriptor]
let ptr: *mut Object = msg_send![class, descriptor];
let ptr: *mut Object = msg_send![ptr, retain];
Self::from_ptr(ptr as _)
}
}
}
Expand All @@ -236,7 +242,9 @@ impl InstanceAccelerationStructureDescriptor {
pub fn descriptor() -> Self {
unsafe {
let class = class!(MTLInstanceAccelerationStructureDescriptor);
msg_send![class, descriptor]
let ptr: *mut Object = msg_send![class, descriptor];
let ptr: *mut Object = msg_send![ptr, retain];
Self::from_ptr(ptr as _)
}
}
}
Expand Down Expand Up @@ -282,7 +290,9 @@ impl IndirectInstanceAccelerationStructureDescriptor {
pub fn descriptor() -> Self {
unsafe {
let class = class!(MTLIndirectInstanceAccelerationStructureDescriptor);
msg_send![class, descriptor]
let ptr: *mut Object = msg_send![class, descriptor];
let ptr: *mut Object = msg_send![ptr, retain];
Self::from_ptr(ptr as _)
}
}
}
Expand Down

0 comments on commit 2094924

Please sign in to comment.