shader+graphics pipeline handles

This commit is contained in:
Greg Wells
2025-06-04 09:57:14 -04:00
parent f20d701353
commit 9faa96d5f5
8 changed files with 44 additions and 38 deletions

View File

@@ -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;
}

View File

@@ -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 = {

View File

@@ -11,3 +11,5 @@ GN_HANDLE(gnPresentationQueue);
GN_HANDLE(gnTexture);
GN_HANDLE(gnRenderPassDescriptor);
GN_HANDLE(gnOutputDevice);
GN_HANDLE(gnShaderModule);
GN_HANDLE(gnGraphicsPipeline);

View File

@@ -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);

View File

@@ -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);
}

View File

@@ -4,6 +4,7 @@
#include <core/renderpass/gryphn_render_pass_descriptor.h>
#include <core/shader_module/gryphn_shader_module.h>
#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);

View File

@@ -1,12 +1,13 @@
#include <core/gryphn_platform_functions.h>
#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);
}

View File

@@ -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);