From c851c470b4a8b42bcd2f275ba4c193c203c721e6 Mon Sep 17 00:00:00 2001 From: Gregory Wells Date: Tue, 29 Jul 2025 11:59:10 -0400 Subject: [PATCH] fnish metals new return codes --- projects/apis/metal/src/instance/metal_instance.h | 2 +- projects/apis/metal/src/instance/metal_instance.m | 2 +- .../graphics_pipeline/metal_graphics_pipeline.m | 4 ++-- projects/apis/metal/src/present/metal_present.m | 4 ++-- .../presentation_queue/metal_presentation_queue.m | 14 -------------- projects/core/gryphn_return_code.h | 2 +- .../gryphn_synced_presentation_queue.h | 3 +-- 7 files changed, 8 insertions(+), 23 deletions(-) diff --git a/projects/apis/metal/src/instance/metal_instance.h b/projects/apis/metal/src/instance/metal_instance.h index e3edc54..e251591 100644 --- a/projects/apis/metal/src/instance/metal_instance.h +++ b/projects/apis/metal/src/instance/metal_instance.h @@ -7,5 +7,5 @@ typedef struct gnPlatformInstance_t { NSView* metalContentView; } gnPlatformInstance; -gnReturnCode createMetalInstance(gnInstanceHandle instance, gnInstanceInfo instanceInfo); +gnReturnCode createMetalInstance(gnInstanceHandle instance, gnInstanceCreateInfo* instanceInfo); void destroyMetalInstance(gnInstance instance); diff --git a/projects/apis/metal/src/instance/metal_instance.m b/projects/apis/metal/src/instance/metal_instance.m index 041a4d6..3d33743 100644 --- a/projects/apis/metal/src/instance/metal_instance.m +++ b/projects/apis/metal/src/instance/metal_instance.m @@ -1,7 +1,7 @@ #include "metal_instance.h" // metal instances are kinda useless -gnReturnCode createMetalInstance(gnInstanceHandle instance, gnInstanceInfo instanceInfo) { +gnReturnCode createMetalInstance(gnInstanceHandle instance, gnInstanceCreateInfo* instanceInfo) { if (instance->instance == NULL) instance->instance = malloc(sizeof(gnPlatformInstance)); return GN_SUCCESS; } diff --git a/projects/apis/metal/src/pipelines/graphics_pipeline/metal_graphics_pipeline.m b/projects/apis/metal/src/pipelines/graphics_pipeline/metal_graphics_pipeline.m index 8805650..73f447e 100644 --- a/projects/apis/metal/src/pipelines/graphics_pipeline/metal_graphics_pipeline.m +++ b/projects/apis/metal/src/pipelines/graphics_pipeline/metal_graphics_pipeline.m @@ -87,7 +87,7 @@ gnReturnCode createMetalGraphicsPipeline(gnGraphicsPipeline graphicsPipeline, gn }); [shaderLib release]; free((void*)shaderCode); - return GN_FAILED_TO_CREATE_SHADER_MODULE; + return GN_FAILED_CREATE_OBJECT; } @@ -135,7 +135,7 @@ gnReturnCode createMetalGraphicsPipeline(gnGraphicsPipeline graphicsPipeline, gn [descriptor release]; [vertexDescriptor release]; [error release]; - if (graphicsPipeline->graphicsPipeline->graphicsPipeline == nil) return GN_FAILED_TO_CREATE_GRAPHICS_PIPELINE; + if (graphicsPipeline->graphicsPipeline->graphicsPipeline == nil) return GN_FAILED_CREATE_OBJECT; return GN_SUCCESS; } diff --git a/projects/apis/metal/src/present/metal_present.m b/projects/apis/metal/src/present/metal_present.m index 54e3fc2..88ab6ad 100644 --- a/projects/apis/metal/src/present/metal_present.m +++ b/projects/apis/metal/src/present/metal_present.m @@ -8,7 +8,7 @@ gnReturnCode metalPresent(gnOutputDeviceHandle device, gnPresentInfo info) { for (int i =0 ; i < info.presentationQueueCount; i++) { info.presentationQueues[i]->info.surface->windowSurface->layer.device = device->outputDevice->device; id drawable = [info.presentationQueues[i]->info.surface->windowSurface->layer nextDrawable]; - if (drawable == nil) return GN_FAILED_TO_CREATE_FRAMEBUFFER; + if (drawable == nil) return GN_UNKNOWN_ERROR; __block gnPresentationQueue presentationQueue = info.presentationQueues[i]; __block uint32_t imageIndex = info.imageIndices[i]; @@ -54,7 +54,7 @@ gnReturnCode metalPresentSync(gnOutputDeviceHandle device, gnPresentSyncInfo inf for (int i =0 ; i < info.presentationQueueCount; i++) { if (info.presentationQueues[i]->info.surface->windowSurface->layer.device == nil) info.presentationQueues[i]->info.surface->windowSurface->layer.device = device->outputDevice->device; id drawable = [info.presentationQueues[i]->info.surface->windowSurface->layer nextDrawable]; - if (drawable == nil) return GN_FAILED_TO_CREATE_FRAMEBUFFER; + if (drawable == nil) return GN_UNKNOWN_ERROR; __block gnPresentationQueue presentationQueue = info.presentationQueues[i]; __block uint32_t imageIndex = info.imageIndices[i]; diff --git a/projects/apis/metal/src/presentation_queue/metal_presentation_queue.m b/projects/apis/metal/src/presentation_queue/metal_presentation_queue.m index 8bfd306..c2e4807 100644 --- a/projects/apis/metal/src/presentation_queue/metal_presentation_queue.m +++ b/projects/apis/metal/src/presentation_queue/metal_presentation_queue.m @@ -5,20 +5,6 @@ #include "sync/semaphore/metal_semaphore.h" gnReturnCode createMetalPresentationQueue(gnPresentationQueueHandle presentationQueue, const gnDevice device, gnPresentationQueueInfo presentationInfo) { - if (presentationInfo.minImageCount > 3) { - gnDebuggerSetErrorMessage(device->instance->debugger, (gnMessageData){ - .message = gnCreateString("On Metal you cannot have more than 3 images in a presentation queue") - }); - return GN_UNSUPPORTED_IMAGE_COUNT; - } - - if (presentationInfo.minImageCount < 2) { - gnDebuggerSetErrorMessage(device->instance->debugger, (gnMessageData){ - .message = gnCreateString("On Metal you cannot have less than 2 images in a presentation queue") - }); - return GN_UNSUPPORTED_IMAGE_COUNT; - } - presentationQueue->presentationQueue = malloc(sizeof(struct gnPlatformPresentationQueue_t)); presentationQueue->presentationQueue->createdSize.x = presentationInfo.surface->windowSurface->layer.visibleRect.size.width; presentationQueue->presentationQueue->createdSize.y = presentationInfo.surface->windowSurface->layer.visibleRect.size.height; diff --git a/projects/core/gryphn_return_code.h b/projects/core/gryphn_return_code.h index e8ea558..ecdeade 100644 --- a/projects/core/gryphn_return_code.h +++ b/projects/core/gryphn_return_code.h @@ -9,7 +9,7 @@ typedef enum gnReturnCode { GN_FAILED_TO_ALLOCATE_MEMORY, GN_OUT_OUT_HOST_MEMEORY, GN_OUT_OUT_DEVICE_MEMORY, GN_OUT_OF_DATE_PRESENTATION_QUEUE, GN_SUBOPTIMAL_PRESENTATION_QUEUE, GN_SURFACE_IN_USE, GN_UNSUPPORTED_FORMAT, - GN_FAILED_TO_FIND_ENTRY_POINT, + GN_FAILED_TO_FIND_ENTRY_POINT, GN_FAILED_TO_LOAD_FUNCTION, GN_UNLOADED_EXTENSION = -1, diff --git a/projects/extensions/synchronization/gryphn_synced_presentation_queue.h b/projects/extensions/synchronization/gryphn_synced_presentation_queue.h index 22e72dd..c2ac10d 100644 --- a/projects/extensions/synchronization/gryphn_synced_presentation_queue.h +++ b/projects/extensions/synchronization/gryphn_synced_presentation_queue.h @@ -1,7 +1,6 @@ #pragma once #include "stdint.h" -#include "utils/gryphn_error_code.h" +#include "core/gryphn_return_code.h" #include "core/src/gryphn_handles.h" -#include "semaphore/gryphn_semaphore.h" gnReturnCode gnPresentationQueueGetImageAsync(gnPresentationQueueHandle presentationQueue, uint64_t timeout, gnSemaphoreHandle semaphore, uint32_t* imageIndex);