redo some syncronization stuff

This commit is contained in:
Gregory Wells
2025-08-04 08:58:25 -04:00
parent 0d26f03dbb
commit 80fbb3e691
6 changed files with 24 additions and 16 deletions

View File

@@ -10,5 +10,6 @@ typedef struct gnPlatformFence_t {
gnReturnCode createMetalFence(gnFence fence, gnDevice device);
void waitForMetalFence(gnFence fence, uint64_t timeout);
void signalMetalFence(gnFence fence);
void resetMetalFence(gnFence fence);
void destroyMetalFence(gnFence fence);

View File

@@ -2,16 +2,20 @@
#include "devices/metal_output_devices.h"
gnReturnCode createMetalFence(gnFence fence, gnDevice device) {
if (device == GN_NULL_HANDLE) return GN_INVALID_HANDLE;
fence->fence = malloc(sizeof(gnPlatformFence));
fence->fence->event = [device->outputDevice->device newSharedEvent];
fence->fence->currentValue = 0;
fence->fence->event = [[device->outputDevice->device newSharedEvent] retain];
return GN_SUCCESS;
}
void waitForMetalFence(gnFence fence, uint64_t timeout) {
[fence->fence->event waitUntilSignaledValue:fence->fence->currentValue timeoutMS:timeout];
[fence->fence->event waitUntilSignaledValue:1 timeoutMS:timeout];
}
void signalMetalFence(gnFence fence) {
[fence->fence->event setSignaledValue:1];
}
void resetMetalFence(gnFence fence) {
fence->fence->currentValue++;
[fence->fence->event setSignaledValue:0];
}
void destroyMetalFence(gnFence fence) {
[fence->fence->event release];