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 323f479..4f64ca7 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 @@ -1,4 +1,6 @@ #include "vulkan_graphics_pipeline.h" +#include "core/debugger/gryphn_debugger.h" +#include "output_device/vulkan_output_devices.h" VkDynamicState vkGryphnDynamicStateToVulkanDynamicState(enum gnDynamicState_e state) { switch (state) { @@ -146,10 +148,32 @@ gnReturnCode gnCreateGraphicsPipelineFn(struct gnGraphicsPipeline_t* graphicsPip .blendConstants[3] = 0.0f }; + if (info.uniformLayout == NULL) { + VkPipelineLayoutCreateInfo pipelineLayoutInfo = { + .sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO, + .setLayoutCount = 0, + pipelineLayoutInfo.pSetLayouts = NULL, + pipelineLayoutInfo.pushConstantRangeCount = 0, + pipelineLayoutInfo.pPushConstantRanges = NULL + }; + + if (vkCreatePipelineLayout(device->outputDevice->device, &pipelineLayoutInfo, NULL, &graphicsPipeline->graphicsPipeline->pipelineLayout) != VK_SUCCESS) { + return GN_FAILED_TO_CREATE_UNIFORM_LAYOUT; + } + + graphicsPipeline->graphicsPipeline->createdPipelineLayout = gnTrue; + } else { + graphicsPipeline->graphicsPipeline->createdPipelineLayout = gnFalse; + gnDebuggerSetErrorMessage(device->instance->debugger, (gnMessageData){ + .message = gnCreateString("Graphics pipelines can not currently accept uniform layouts") + }); + } + free(dynamicStates); return GN_SUCCESS; } void gnDestroyGraphicsPipelineFn(struct gnGraphicsPipeline_t *graphicsPipeline) { - + if (graphicsPipeline->graphicsPipeline->createdPipelineLayout) + vkDestroyPipelineLayout(graphicsPipeline->device->outputDevice->device, graphicsPipeline->graphicsPipeline->pipelineLayout, NULL); } diff --git a/rendering_api/vulkan/src/pipelines/graphics_pipeline/vulkan_graphics_pipeline.h b/rendering_api/vulkan/src/pipelines/graphics_pipeline/vulkan_graphics_pipeline.h index 1ce3f20..c41fe98 100644 --- a/rendering_api/vulkan/src/pipelines/graphics_pipeline/vulkan_graphics_pipeline.h +++ b/rendering_api/vulkan/src/pipelines/graphics_pipeline/vulkan_graphics_pipeline.h @@ -14,4 +14,7 @@ typedef struct gnPlatformGraphicsPipeline_t { VkPipelineRasterizationStateCreateInfo rasterizer; VkPipelineColorBlendAttachmentState colorBlendAttachment; VkPipelineColorBlendStateCreateInfo colorBlending; + + gnBool createdPipelineLayout; + VkPipelineLayout pipelineLayout; } gnPlatformGraphicsPipeline; diff --git a/src/core/pipelines/graphics_pipeline/gryphn_graphics_pipeline.h b/src/core/pipelines/graphics_pipeline/gryphn_graphics_pipeline.h index c5cc48f..d76d625 100644 --- a/src/core/pipelines/graphics_pipeline/gryphn_graphics_pipeline.h +++ b/src/core/pipelines/graphics_pipeline/gryphn_graphics_pipeline.h @@ -1,5 +1,6 @@ #pragma once #include +#include typedef enum gnDynamicState_e { GN_DYNAMIC_VIEWPORT, @@ -76,6 +77,8 @@ typedef struct gnGraphicsPipelineInfo_t { enum gnFillMode_e fillMode; struct gnCullMode_t cullMode; struct gnColorBlending_t colorBlending; + + struct gnUniformLayout_t* uniformLayout; } gnGraphicsPipelineInfo; struct gnPlatformGraphicsPipeline_t; diff --git a/src/core/pipelines/gryphn_uniform_layout.h b/src/core/pipelines/gryphn_uniform_layout.h new file mode 100644 index 0000000..f3c37eb --- /dev/null +++ b/src/core/pipelines/gryphn_uniform_layout.h @@ -0,0 +1,5 @@ +#pragma once + +typedef struct gnUniformLayout_t { + +} gnUniformLayout; diff --git a/src/utils/gryphn_error_code.h b/src/utils/gryphn_error_code.h index f51fa99..35e147d 100644 --- a/src/utils/gryphn_error_code.h +++ b/src/utils/gryphn_error_code.h @@ -19,7 +19,8 @@ typedef enum gnReturnCode_t { GN_FAILED_TO_CREATE_IMAGE_VIEW, GN_FAILED_TO_CREATE_SHADER_MODULE, GN_FAILED_TO_CONVERT_SHADER_CODE, - GN_FAILED_TO_FIND_ENTRY_POINT + GN_FAILED_TO_FIND_ENTRY_POINT, + GN_FAILED_TO_CREATE_UNIFORM_LAYOUT // GN_UNKNOWN_FRAMEBUFFER_ATTACHMENT, // GN_UNKNOWN_FUNCTION, @@ -52,5 +53,6 @@ static const char* gnErrorCodeToCString(enum gnReturnCode_t returnCode) { case GN_FAILED_TO_CREATE_SHADER_MODULE: return "GN_FAILED_TO_CREATE_SHADER_MODULE"; case GN_FAILED_TO_CONVERT_SHADER_CODE: return "GN_FAILED_TO_CONVERT_SHADER_CODE"; case GN_FAILED_TO_FIND_ENTRY_POINT: return "GN_FAILED_TO_FIND_ENTRY_POINT"; + case GN_FAILED_TO_CREATE_UNIFORM_LAYOUT: return "GN_FAILED_TO_CREATE_UNIFORM_LAYOUT"; } }