diff --git a/graphics/src/graphics_context.h b/graphics/src/graphics_context.h index 5e2ce736..dcd9e776 100644 --- a/graphics/src/graphics_context.h +++ b/graphics/src/graphics_context.h @@ -20,7 +20,6 @@ #include #include "utilities/entity.h" -#include "utilities/stack.h" #include "utilities/vector.h" #include "vma/vk_mem_alloc.h" #include "vulkan/vulkan_core.h" @@ -55,8 +54,6 @@ #define FONT_CHARACTERS_COUNT (94U) #define FONTS_MAX_COUNT (32U) -RSE_STACK_DEFINE(required_dynamic_states_t, VkDynamicState, 16U); - struct graphics_context_t; enum QUEUE_FAMILY_INDEX { @@ -124,6 +121,11 @@ struct shader_modules_t VkShaderStageFlagBits shaders_stages[MAX_SHADER_MODULES_COUNT]; }; +struct required_dynamic_states_t { + size_t dynamic_states_count; + VkDynamicState dynamic_states[MAX_DYNAMIC_STATES_COUNT]; +}; + struct pipeline_infos_t { size_t pipeline_create_infos_count; diff --git a/graphics/src/pipeline_builder.c b/graphics/src/pipeline_builder.c index 2395cb1a..e69c66a9 100644 --- a/graphics/src/pipeline_builder.c +++ b/graphics/src/pipeline_builder.c @@ -102,11 +102,13 @@ static rse_err_t pipeline_add_viewport_state(struct pipeline_t* pipeline) pipeline->viewport_state.pScissors = NULL; /* This is set during rendering */ if (pipeline->viewport_state.pViewports == NULL || pipeline->viewport_state.viewportCount == 0U) { - RSE_STACK_PUSH(pipeline->required_dynamic_states, VK_DYNAMIC_STATE_VIEWPORT); + pipeline->required_dynamic_states.dynamic_states[pipeline->required_dynamic_states.dynamic_states_count++] = + VK_DYNAMIC_STATE_VIEWPORT; } if (pipeline->viewport_state.pScissors == NULL || pipeline->viewport_state.scissorCount == 0U) { - RSE_STACK_PUSH(pipeline->required_dynamic_states, VK_DYNAMIC_STATE_SCISSOR); + pipeline->required_dynamic_states.dynamic_states[pipeline->required_dynamic_states.dynamic_states_count++] = + VK_DYNAMIC_STATE_SCISSOR; } return RSE_ERROR_NO_ERROR; @@ -346,12 +348,13 @@ rse_err_t pipelines_build(struct graphics_context_t* context, struct pipeline_in rse_err_t status = RSE_ERROR_NO_ERROR; - if (VK_SUCCESS != vkCreateGraphicsPipelines(context->vulkan_handles.device, - VK_NULL_HANDLE, - pipelines_infos_list->pipeline_create_infos_count, - pipelines_infos_list->create_infos, - NULL, - &context->pipelines_data.pipelines[context->pipelines_data.pipelines_count])) { + if (VK_SUCCESS != + vkCreateGraphicsPipelines(context->vulkan_handles.device, + VK_NULL_HANDLE, + pipelines_infos_list->pipeline_create_infos_count, + pipelines_infos_list->create_infos, + NULL, + &context->pipelines_data.pipelines[context->pipelines_data.pipelines_count])) { SDL_LogCritical(SDL_LOG_CATEGORY_GPU, "Failed to create graphics pipelines"); status = RSE_ERROR_INTERNAL_ERROR; } @@ -375,9 +378,10 @@ rse_err_t pipeline_add(const struct graphics_context_t* context, VkPipelineVertexInputStateCreateInfo* vertex_bindings_ci = NULL; VkPipelineDynamicStateCreateInfo* dynamic_states_ci = NULL; - while (RSE_STACK_IS_EMPTY(pipeline->required_dynamic_states) == 0) { + while (pipeline->required_dynamic_states.dynamic_states_count > 0) { dynamic_state_found = 0; - VkDynamicState dynamic_state = RSE_STACK_POP(pipeline->required_dynamic_states); + VkDynamicState dynamic_state = + pipeline->required_dynamic_states.dynamic_states[pipeline->required_dynamic_states.dynamic_states_count--]; for (iter = 0U; iter < pipeline->dynamic_states_count; ++iter) { if (pipeline->dynamic_states[iter] == dynamic_state) { dynamic_state_found = 1; diff --git a/utilities/stack.h b/utilities/stack.h deleted file mode 100644 index 85dac1b8..00000000 --- a/utilities/stack.h +++ /dev/null @@ -1,45 +0,0 @@ -/** - * @file stack.h - * @author Piotr Krygier (everyonecancode@gmail.com) - * @brief - * @version 0.1 - * @date 2024-05-01 - * - * @copyright Copyright (c) 2024 - * - */ - -#ifndef STACK_H -#define STACK_H - -#define RSE_STACK_DEFINE(name, type, size) \ - struct name { \ - type data[size]; \ - int top; \ - } - -#define RSE_STACK_PUSH(stack, value) \ - stack.data[++stack.top] = value - -#define RSE_STACK_POP(stack) \ - stack.data[stack.top--] - -#define RSE_STACK_TOP(stack) \ - stack.data[stack.top] - -#define RSE_STACK_IS_EMPTY(stack) \ - (stack.top == -1) - -#define RSE_STACK_IS_FULL(stack, size) \ - (stack.top == size - 1) - -#define RSE_STACK_INIT(stack) \ - (stack.top = -1) - -#define RSE_STACK_SIZE(stack) \ - (stack.top + 1) - -#define RSE_STACK_CLEAR(stack) \ - (stack.top = -1) - -#endif // STACK_H