diff --git a/rendering_api/metal/src/core/pipelines/graphics_pipeline/metal_graphics_pipeline.m b/rendering_api/metal/src/core/pipelines/graphics_pipeline/metal_graphics_pipeline.m index af98c30..fdc3dda 100644 --- a/rendering_api/metal/src/core/pipelines/graphics_pipeline/metal_graphics_pipeline.m +++ b/rendering_api/metal/src/core/pipelines/graphics_pipeline/metal_graphics_pipeline.m @@ -51,10 +51,10 @@ gnReturnCode gnCreateGraphicsPipelineFn(struct gnGraphicsPipeline_t* graphicsPip } for (int i = 0; i < info.shaderModuleCount; i++) { - if (info.shaderModules[i].info.stage == GN_VERTEX_SHADER_MODULE) { - [descriptor setVertexFunction:info.shaderModules[i].shaderModule->function]; - } else if (info.shaderModules[i].info.stage == GN_FRAGMENT_SHADER_MODULE) { - [descriptor setFragmentFunction:info.shaderModules[i].shaderModule->function]; + if (info.shaderModules[i]->info.stage == GN_VERTEX_SHADER_MODULE) { + [descriptor setVertexFunction:info.shaderModules[i]->shaderModule->function]; + } else if (info.shaderModules[i]->info.stage == GN_FRAGMENT_SHADER_MODULE) { + [descriptor setFragmentFunction:info.shaderModules[i]->shaderModule->function]; } else { return GN_UNSUPPORTED_SHADER_MODULE; } diff --git a/rendering_api/vulkan/src/pipelines/graphics_pipeline/vulkan_graphics_pipeline.c b/rendering_api/vulkan/src/pipelines/graphics_pipeline/vulkan_graphics_pipeline.c index 687ffee..c448373 100644 --- a/rendering_api/vulkan/src/pipelines/graphics_pipeline/vulkan_graphics_pipeline.c +++ b/rendering_api/vulkan/src/pipelines/graphics_pipeline/vulkan_graphics_pipeline.c @@ -173,7 +173,7 @@ gnReturnCode gnCreateGraphicsPipelineFn(struct gnGraphicsPipeline_t* graphicsPip VkPipelineShaderStageCreateInfo* modules = malloc(sizeof(VkPipelineShaderStageCreateInfo) * info.shaderModuleCount); for (int i = 0; i < info.shaderModuleCount; i++) { - modules[i] = info.shaderModules[i].shaderModule->shaderStageInfo; + modules[i] = info.shaderModules[i]->shaderModule->shaderStageInfo; } VkGraphicsPipelineCreateInfo pipelineInfo = { diff --git a/src/core/gryphn_handles.h b/src/core/gryphn_handles.h index 9ad17ea..3ae3131 100644 --- a/src/core/gryphn_handles.h +++ b/src/core/gryphn_handles.h @@ -11,3 +11,5 @@ GN_HANDLE(gnPresentationQueue); GN_HANDLE(gnTexture); GN_HANDLE(gnRenderPassDescriptor); GN_HANDLE(gnOutputDevice); +GN_HANDLE(gnShaderModule); +GN_HANDLE(gnGraphicsPipeline); diff --git a/src/core/gryphn_platform_functions.h b/src/core/gryphn_platform_functions.h index 2794313..01d259c 100644 --- a/src/core/gryphn_platform_functions.h +++ b/src/core/gryphn_platform_functions.h @@ -63,14 +63,14 @@ typedef struct gnDeviceFunctions_t { gnReturnCode (*_gnPresentationQueueGetImage)(gnPresentationQueueHandle presentationQueue, uint64_t timeout, struct gnSemaphore_t* semaphore, uint32_t* imageIndex); void (*_gnDestroyPresentationQueue)(gnPresentationQueueHandle presentationQueue); - gnReturnCode (*_gnCreateShaderModule)(struct gnShaderModule_t* module, gnOutputDeviceHandle device, struct gnShaderModuleInfo_t shaderModuleInfo); - void (*_gnDestroyShaderModule)(struct gnShaderModule_t* module); + gnReturnCode (*_gnCreateShaderModule)(gnShaderModuleHandle module, gnOutputDeviceHandle device, struct gnShaderModuleInfo_t shaderModuleInfo); + void (*_gnDestroyShaderModule)(gnShaderModuleHandle module); gnReturnCode (*_gnCreateRenderPassDescriptor)(gnRenderPassDescriptorHandle renderPass, gnOutputDeviceHandle device, struct gnRenderPassDescriptorInfo_t info); void (*_gnDestroyRenderPassDescriptor)(gnRenderPassDescriptorHandle renderPass); - gnReturnCode (*_gnCreateGraphicsPipeline)(struct gnGraphicsPipeline_t* pipeline, gnOutputDeviceHandle device, struct gnGraphicsPipelineInfo_t pipelineInfo); - void (*_gnDestroyGraphicsPipeline)(struct gnGraphicsPipeline_t* pipeline); + gnReturnCode (*_gnCreateGraphicsPipeline)(gnGraphicsPipelineHandle pipeline, gnOutputDeviceHandle device, struct gnGraphicsPipelineInfo_t pipelineInfo); + void (*_gnDestroyGraphicsPipeline)(gnGraphicsPipelineHandle pipeline); gnReturnCode (*_gnCreateFramebuffer)(struct gnFramebuffer_t* framebuffer, gnOutputDeviceHandle device, struct gnFramebufferInfo_t framebufferInfo); void (*_gnDestroyFramebuffer)(struct gnFramebuffer_t* framebuffer); diff --git a/src/core/pipelines/graphics_pipeline/gryphn_graphics_pipeline.c b/src/core/pipelines/graphics_pipeline/gryphn_graphics_pipeline.c index f140fc2..c98179c 100644 --- a/src/core/pipelines/graphics_pipeline/gryphn_graphics_pipeline.c +++ b/src/core/pipelines/graphics_pipeline/gryphn_graphics_pipeline.c @@ -1,12 +1,13 @@ #include "gryphn_graphics_pipeline.h" #include "core/gryphn_platform_functions.h" -gnReturnCode gnCreateGraphicsPipeline(struct gnGraphicsPipeline_t* graphicsPipeline, struct gnOutputDevice_t* device, struct gnGraphicsPipelineInfo_t info) { - graphicsPipeline->device = device; - graphicsPipeline->info = info; - return graphicsPipeline->device->deviceFunctions->_gnCreateGraphicsPipeline(graphicsPipeline, device, info); +gnReturnCode gnCreateGraphicsPipeline(gnGraphicsPipelineHandle* graphicsPipeline, struct gnOutputDevice_t* device, struct gnGraphicsPipelineInfo_t info) { + *graphicsPipeline = malloc(sizeof(struct gnGraphicsPipeline_t)); + (*graphicsPipeline)->device = device; + (*graphicsPipeline)->info = info; + return device->deviceFunctions->_gnCreateGraphicsPipeline(*graphicsPipeline, device, info); } -void gnDestroyGraphicsPipeline(struct gnGraphicsPipeline_t* graphicsPipeline) { +void gnDestroyGraphicsPipeline(gnGraphicsPipelineHandle graphicsPipeline) { graphicsPipeline->device->deviceFunctions->_gnDestroyGraphicsPipeline(graphicsPipeline); } diff --git a/src/core/pipelines/graphics_pipeline/gryphn_graphics_pipeline.h b/src/core/pipelines/graphics_pipeline/gryphn_graphics_pipeline.h index 04ab854..d703641 100644 --- a/src/core/pipelines/graphics_pipeline/gryphn_graphics_pipeline.h +++ b/src/core/pipelines/graphics_pipeline/gryphn_graphics_pipeline.h @@ -4,6 +4,7 @@ #include #include #include "utils/math/gryphn_vec2.h" +#include "core/gryphn_handles.h" typedef enum gnDynamicState_e { GN_DYNAMIC_VIEWPORT, @@ -84,19 +85,19 @@ typedef struct gnGraphicsPipelineInfo_t { struct gnUniformLayout_t* uniformLayout; uint32_t subpassIndex; - struct gnRenderPassDescriptor_t* renderPassDescriptor; + gnRenderPassDescriptorHandle renderPassDescriptor; uint32_t shaderModuleCount; - struct gnShaderModule_t* shaderModules; + gnShaderModuleHandle* shaderModules; } gnGraphicsPipelineInfo; -struct gnPlatformGraphicsPipeline_t; - -typedef struct gnGraphicsPipeline_t { +#ifdef GN_REVEAL_IMPL +struct gnGraphicsPipeline_t { struct gnPlatformGraphicsPipeline_t* graphicsPipeline; - struct gnOutputDevice_t* device; - struct gnGraphicsPipelineInfo_t info; -} gnGraphicsPipeline; + gnOutputDeviceHandle device; + gnGraphicsPipelineInfo info; +}; +#endif -gnReturnCode gnCreateGraphicsPipeline(struct gnGraphicsPipeline_t* graphicsPipeline, struct gnOutputDevice_t* device, struct gnGraphicsPipelineInfo_t info); -void gnDestroyGraphicsPipeline(struct gnGraphicsPipeline_t* graphicsPipeline); +gnReturnCode gnCreateGraphicsPipeline(gnGraphicsPipelineHandle* graphicsPipeline, gnOutputDeviceHandle device, struct gnGraphicsPipelineInfo_t info); +void gnDestroyGraphicsPipeline(gnGraphicsPipelineHandle graphicsPipeline); diff --git a/src/core/shader_module/gryphn_shader_module.c b/src/core/shader_module/gryphn_shader_module.c index f8a7992..3eae456 100644 --- a/src/core/shader_module/gryphn_shader_module.c +++ b/src/core/shader_module/gryphn_shader_module.c @@ -1,12 +1,13 @@ #include #include "gryphn_shader_module.h" -gnReturnCode gnCreateShaderModule(struct gnShaderModule_t* module, struct gnOutputDevice_t* device, struct gnShaderModuleInfo_t shaderModuleInfo) { - module->device = device; - module->info = shaderModuleInfo; - return device->deviceFunctions->_gnCreateShaderModule(module, device, shaderModuleInfo); +gnReturnCode gnCreateShaderModule(gnShaderModuleHandle* module, gnOutputDeviceHandle device, struct gnShaderModuleInfo_t shaderModuleInfo) { + *module = malloc(sizeof(struct gnShaderModule_t)); + (*module)->device = device; + (*module)->info = shaderModuleInfo; + return device->deviceFunctions->_gnCreateShaderModule(*module, device, shaderModuleInfo); } -void gnDestroyShaderModule(struct gnShaderModule_t* module) { +void gnDestroyShaderModule(gnShaderModuleHandle module) { module->device->deviceFunctions->_gnDestroyShaderModule(module); } diff --git a/src/core/shader_module/gryphn_shader_module.h b/src/core/shader_module/gryphn_shader_module.h index 767638a..070a177 100644 --- a/src/core/shader_module/gryphn_shader_module.h +++ b/src/core/shader_module/gryphn_shader_module.h @@ -1,7 +1,8 @@ #pragma once #include "stdint.h" #include "utils/strings/gryphn_string.h" -#include "core/output_device/gryphn_output_device.h" +#include "utils/gryphn_error_code.h" +#include "core/gryphn_handles.h" typedef enum gnShaderModuleStage_e { GN_VERTEX_SHADER_MODULE, GN_FRAGMENT_SHADER_MODULE @@ -14,13 +15,13 @@ typedef struct gnShaderModuleInfo_t { gnString entryPoint; } gnShaderModuleInfo; -struct gnPlatformShaderModule_t; - -typedef struct gnShaderModule_t { +#ifdef GN_REVEAL_IMPL +struct gnShaderModule_t { struct gnPlatformShaderModule_t* shaderModule; - struct gnShaderModuleInfo_t info; - struct gnOutputDevice_t* device; -} gnShaderModule; + gnShaderModuleInfo info; + gnOutputDeviceHandle device; +}; +#endif -gnReturnCode gnCreateShaderModule(struct gnShaderModule_t* module, struct gnOutputDevice_t* device, struct gnShaderModuleInfo_t shaderModuleInfo); -void gnDestroyShaderModule(struct gnShaderModule_t* module); +gnReturnCode gnCreateShaderModule(gnShaderModuleHandle* module, gnOutputDeviceHandle device, struct gnShaderModuleInfo_t shaderModuleInfo); +void gnDestroyShaderModule(gnShaderModuleHandle module);