Skip to content

Commit ed8e93b

Browse files
committed
GPU Metal: create the device events
The event slots were only placement-constructed as nil ids, so the first StreamWaitForEvents threw "object cannot be nil" from encodeWaitForEvent. Create an MTLSharedEvent per slot, as the CUDA backend creates its events, and release them on exit.
1 parent ea9484d commit ed8e93b

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

‎GPU/GPUTracking/Base/metal/GPUReconstructionMetal.mm‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,12 @@
137137

138138
for (uint32_t i = 0; i < mEvents.size(); i++) {
139139
auto* events = (id<MTLSharedEvent>*)mEvents[i].data();
140-
new (events) id<MTLSharedEvent>[ mEvents[i].size() ];
140+
for (uint32_t j = 0; j < mEvents[i].size(); j++) {
141+
events[j] = [mInternals->device newSharedEvent];
142+
if (events[j] == nil) {
143+
GPUErrorReturn("Error creating Metal event");
144+
}
145+
}
141146
}
142147

143148
return (0);
@@ -148,6 +153,13 @@
148153
// Tear down Metal
149154
SynchronizeGPU();
150155

156+
for (uint32_t i = 0; i < mEvents.size(); i++) {
157+
auto* events = (id<MTLSharedEvent>*)mEvents[i].data();
158+
for (uint32_t j = 0; j < mEvents[i].size(); j++) {
159+
[events[j] release];
160+
}
161+
}
162+
151163
if (mMaster == nullptr) {
152164
if (mDeviceMemoryBase) {
153165
[mInternals->mem_gpu release];

0 commit comments

Comments
 (0)