sync primative handles

This commit is contained in:
Greg Wells
2025-06-05 22:19:38 -04:00
parent 4349f76ede
commit d5d339105d
17 changed files with 78 additions and 69 deletions

View File

@@ -8,9 +8,9 @@
#include "core/texture/metal_texture.h"
#import <QuartzCore/CAMetalLayer.h>
gnReturnCode gnPresentFn(struct gnOutputDevice_t* device, struct gnPresentInfo_t info) {
gnReturnCode gnPresentFn(gnOutputDeviceHandle device, struct gnPresentInfo_t info) {
for (int i = 0; i < info.waitCount; i++) {
while (!info.waitSemaphores[i].semaphore->eventTriggered) {}
while (!info.waitSemaphores[i]->semaphore->eventTriggered) {}
}
for (int i =0 ; i < info.presentationQueueCount; i++) {

View File

@@ -6,19 +6,19 @@
gnReturnCode gnSubmitFn(struct gnOutputDevice_t* device, struct gnSubmitInfo_t info) {
for (int i = 0; i < info.waitCount; i++) {
while (!info.waitSemaphores[i].semaphore->eventTriggered) {}
while (!info.waitSemaphores[i]->semaphore->eventTriggered) {}
}
__block gnSemaphore* semsToSignal = info.signalSemaphores;
__block int semsToSignalCount = info.signalCount;
__block gnFence* fenceToSignal = info.fence;
__block gnFence fenceToSignal = info.fence;
for (int i = 0; i < info.commandBufferCount; i++) {
id<MTLCommandBuffer> commandBuffer = info.commandBuffers[i]->commandBuffer->commandBuffer;
[info.commandBuffers[i]->commandBuffer->commandBuffer addCompletedHandler:^(id<MTLCommandBuffer> buffer) {
for (int c = 0; c < semsToSignalCount; c++) {
semsToSignal[c].semaphore->eventTriggered = gnTrue;
semsToSignal[c]->semaphore->eventTriggered = gnTrue;
}
}];
fenceToSignal->signaled = gnTrue;

View File

@@ -4,5 +4,5 @@
typedef struct gnPlatformSemaphore_t {
id<MTLEvent> event;
gnBool eventTriggered;
bool eventTriggered;
} gnPlatformSemaphore;

View File

@@ -7,7 +7,7 @@
gnReturnCode gnPresentFn(struct gnOutputDevice_t* device, struct gnPresentInfo_t info) {
VkSemaphore* waitSemaphores = malloc(sizeof(VkSemaphore) * info.waitCount);
for (int i = 0; i < info.waitCount; i++) waitSemaphores[i] = info.waitSemaphores[i].semaphore->semaphore;
for (int i = 0; i < info.waitCount; i++) waitSemaphores[i] = info.waitSemaphores[i]->semaphore->semaphore;
VkSwapchainKHR* swapchains = malloc(sizeof(VkSwapchainKHR) * info.presentationQueueCount);
for (int i = 0; i < info.presentationQueueCount; i++) swapchains[i] = info.presentationQueues[i]->presentationQueue->swapChain;

View File

@@ -17,14 +17,14 @@ gnReturnCode gnSubmitFn(struct gnOutputDevice_t* device, struct gnSubmitInfo_t i
VkSemaphore* waitSemaphores = malloc(sizeof(VkSemaphore) * info.waitCount);
VkPipelineStageFlags* waitStages = malloc(sizeof(VkPipelineStageFlags) * info.waitCount);
for (int i = 0; i < info.waitCount; i++) waitSemaphores[i] = info.waitSemaphores[i].semaphore->semaphore;
for (int i = 0; i < info.waitCount; i++) waitSemaphores[i] = info.waitSemaphores[i]->semaphore->semaphore;
for (int i = 0; i < info.waitCount; i++) waitStages[i] = vkGryphnWaitStage(info.waitStages[i]);
VkCommandBuffer* commandBuffers = malloc(sizeof(VkCommandBuffer) * info.commandBufferCount);
for (int i = 0; i < info.commandBufferCount; i++) commandBuffers[i] = info.commandBuffers[i]->commandBuffer->buffer;
VkSemaphore* signalSemaphores = malloc(sizeof(VkSemaphore) * info.signalCount);
for (int i = 0; i < info.signalCount; i++) signalSemaphores[i] = info.signalSemaphores[i].semaphore->semaphore;
for (int i = 0; i < info.signalCount; i++) signalSemaphores[i] = info.signalSemaphores[i]->semaphore->semaphore;
VkSubmitInfo submitInfo = {
.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO,