From 3a69ed70ff57d9505f7e397e7609f009b875ab9f Mon Sep 17 00:00:00 2001 From: Greg Wells Date: Thu, 5 Jun 2025 22:22:35 -0400 Subject: [PATCH] framebuffer handles --- src/core/framebuffer/gryphn_framebuffer.c | 9 +++++---- src/core/framebuffer/gryphn_framebuffer.h | 10 ++++++---- src/core/gryphn_handles.h | 1 + src/core/gryphn_platform_functions.h | 4 ++-- src/core/renderpass/gryphn_render_pass.h | 5 +++-- 5 files changed, 17 insertions(+), 12 deletions(-) diff --git a/src/core/framebuffer/gryphn_framebuffer.c b/src/core/framebuffer/gryphn_framebuffer.c index 466ff1d..fbd80e5 100644 --- a/src/core/framebuffer/gryphn_framebuffer.c +++ b/src/core/framebuffer/gryphn_framebuffer.c @@ -1,11 +1,12 @@ #include "gryphn_framebuffer.h" #include "core/gryphn_platform_functions.h" -gnReturnCode gnCreateFramebuffer(struct gnFramebuffer_t* framebuffer, struct gnOutputDevice_t* device, struct gnFramebufferInfo_t framebufferInfo) { - framebuffer->device = device; - return device->deviceFunctions->_gnCreateFramebuffer(framebuffer, device, framebufferInfo); +gnReturnCode gnCreateFramebuffer(gnFramebuffer* framebuffer, gnOutputDeviceHandle device, gnFramebufferInfo framebufferInfo) { + *framebuffer = malloc(sizeof(struct gnFramebuffer_t)); + (*framebuffer)->device = device; + return device->deviceFunctions->_gnCreateFramebuffer(*framebuffer, device, framebufferInfo); } -void gnDestroyFramebuffer(struct gnFramebuffer_t *framebuffer) { +void gnDestroyFramebuffer(gnFramebuffer framebuffer) { framebuffer->device->deviceFunctions->_gnDestroyFramebuffer(framebuffer); } diff --git a/src/core/framebuffer/gryphn_framebuffer.h b/src/core/framebuffer/gryphn_framebuffer.h index 455fa7b..5d3d668 100644 --- a/src/core/framebuffer/gryphn_framebuffer.h +++ b/src/core/framebuffer/gryphn_framebuffer.h @@ -10,10 +10,12 @@ typedef struct gnFramebufferInfo_t { gnUInt2 size; } gnFramebufferInfo; -typedef struct gnFramebuffer_t { +#ifdef GN_REVEAL_IMPL +struct gnFramebuffer_t { struct gnPlatformFramebuffer_t* framebuffer; gnOutputDeviceHandle device; -} gnFramebuffer; +}; +#endif -gnReturnCode gnCreateFramebuffer(struct gnFramebuffer_t* framebuffer, gnOutputDeviceHandle device, struct gnFramebufferInfo_t framebufferInfo); -void gnDestroyFramebuffer(struct gnFramebuffer_t* framebuffer); +gnReturnCode gnCreateFramebuffer(gnFramebuffer* framebuffer, gnOutputDeviceHandle device, gnFramebufferInfo framebufferInfo); +void gnDestroyFramebuffer(gnFramebuffer framebuffer); diff --git a/src/core/gryphn_handles.h b/src/core/gryphn_handles.h index 0ccef3d..9794775 100644 --- a/src/core/gryphn_handles.h +++ b/src/core/gryphn_handles.h @@ -17,3 +17,4 @@ GN_HANDLE(gnCommandPool); GN_HANDLE(gnCommandBuffer); GN_HANDLE(gnSemaphore); GN_HANDLE(gnFence); +GN_HANDLE(gnFramebuffer); diff --git a/src/core/gryphn_platform_functions.h b/src/core/gryphn_platform_functions.h index 90b0ea2..7e6890a 100644 --- a/src/core/gryphn_platform_functions.h +++ b/src/core/gryphn_platform_functions.h @@ -72,8 +72,8 @@ typedef struct gnDeviceFunctions_t { gnReturnCode (*_gnCreateGraphicsPipeline)(gnGraphicsPipelineHandle pipeline, gnOutputDeviceHandle device, gnGraphicsPipelineInfo pipelineInfo); void (*_gnDestroyGraphicsPipeline)(gnGraphicsPipelineHandle pipeline); - gnReturnCode (*_gnCreateFramebuffer)(struct gnFramebuffer_t* framebuffer, gnOutputDeviceHandle device, gnFramebufferInfo framebufferInfo); - void (*_gnDestroyFramebuffer)(struct gnFramebuffer_t* framebuffer); + gnReturnCode (*_gnCreateFramebuffer)(gnFramebuffer framebuffer, gnOutputDeviceHandle device, gnFramebufferInfo framebufferInfo); + void (*_gnDestroyFramebuffer)(gnFramebuffer framebuffer); gnReturnCode (*_gnCreateCommandPool)(gnCommandPoolHandle commandPool, gnOutputDeviceHandle device, gnCommandPoolInfo info); void (*_gnDestroyCommandPool)(gnCommandPoolHandle commandPool); diff --git a/src/core/renderpass/gryphn_render_pass.h b/src/core/renderpass/gryphn_render_pass.h index dc64e44..ef6fd1f 100644 --- a/src/core/renderpass/gryphn_render_pass.h +++ b/src/core/renderpass/gryphn_render_pass.h @@ -1,10 +1,11 @@ #pragma once -#include "core/framebuffer/gryphn_framebuffer.h" #include "utils/types/gryphn_color.h" +#include "utils/math/gryphn_vec2.h" +#include "core/gryphn_handles.h" typedef struct gnRenderPassInfo_t { gnRenderPassDescriptorHandle renderPassDescriptor; - struct gnFramebuffer_t* framebuffer; + gnFramebuffer framebuffer; gnUInt2 offset; gnUInt2 size; uint32_t clearValueCount;