vulkan creation and destruction of shader modules

This commit is contained in:
Greg Wells
2025-05-27 14:06:26 -04:00
parent df977592df
commit 4709450e94
6 changed files with 48 additions and 5 deletions

View File

@@ -0,0 +1,30 @@
#include "vulkan_shader_module.h"
#include "output_device/vulkan_output_devices.h"
gnReturnCode gnCreateShaderModuleFn(struct gnShaderModule_t *module, struct gnOutputDevice_t *device, struct gnShaderModuleInfo_t shaderModuleInfo) {
module->shaderModule = malloc(sizeof(struct gnPlatformShaderModule_t));
VkShaderModuleCreateInfo createInfo = {};
createInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO;
createInfo.codeSize = shaderModuleInfo.size;
createInfo.pCode = shaderModuleInfo.code;
if (vkCreateShaderModule(device->outputDevice->device, &createInfo, NULL, &module->shaderModule->shaderModule) != VK_SUCCESS) {
return GN_FAILED_TO_CREATE_SHADER_MODULE;
}
module->shaderModule->shaderStageInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO;
if (shaderModuleInfo.stage == GN_VERTEX_SHADER_MODULE)
module->shaderModule->shaderStageInfo.stage = VK_SHADER_STAGE_VERTEX_BIT;
else if (shaderModuleInfo.stage == GN_FRAGMENT_SHADER_MODULE)
module->shaderModule->shaderStageInfo.stage = VK_SHADER_STAGE_FRAGMENT_BIT;
module->shaderModule->shaderStageInfo.module = module->shaderModule->shaderModule;
module->shaderModule->shaderStageInfo.pName = shaderModuleInfo.entryPoint.value;
return GN_SUCCESS;
}
void gnDestroyShaderModuleFn(struct gnShaderModule_t* module) {
vkDestroyShaderModule(module->device->outputDevice->device, module->shaderModule->shaderModule, NULL);
}

View File

@@ -0,0 +1,8 @@
#pragma once
#include <core/shader_module/gryphn_shader_module.h>
#include <vulkan/vulkan.h>
typedef struct gnPlatformShaderModule_t {
VkShaderModule shaderModule;
VkPipelineShaderStageCreateInfo shaderStageInfo;
} gnPlatformShaderModule;