Remove stack implementation

There is no need for stack implementation to be used here.
Simple C operations are enough for now

Signed-off-by: Piotr Krygier <piotrkrygier@everyonecancode@xyz>
This commit is contained in:
Piotr Krygier
2026-02-10 09:18:10 +01:00
parent 3dcf7fec56
commit 55e0ee261e
3 changed files with 19 additions and 58 deletions
+5 -3
View File
@@ -20,7 +20,6 @@
#include <vulkan/vulkan.h> #include <vulkan/vulkan.h>
#include "utilities/entity.h" #include "utilities/entity.h"
#include "utilities/stack.h"
#include "utilities/vector.h" #include "utilities/vector.h"
#include "vma/vk_mem_alloc.h" #include "vma/vk_mem_alloc.h"
#include "vulkan/vulkan_core.h" #include "vulkan/vulkan_core.h"
@@ -55,8 +54,6 @@
#define FONT_CHARACTERS_COUNT (94U) #define FONT_CHARACTERS_COUNT (94U)
#define FONTS_MAX_COUNT (32U) #define FONTS_MAX_COUNT (32U)
RSE_STACK_DEFINE(required_dynamic_states_t, VkDynamicState, 16U);
struct graphics_context_t; struct graphics_context_t;
enum QUEUE_FAMILY_INDEX { enum QUEUE_FAMILY_INDEX {
@@ -124,6 +121,11 @@ struct shader_modules_t
VkShaderStageFlagBits shaders_stages[MAX_SHADER_MODULES_COUNT]; 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 struct pipeline_infos_t
{ {
size_t pipeline_create_infos_count; size_t pipeline_create_infos_count;
+9 -5
View File
@@ -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 */ pipeline->viewport_state.pScissors = NULL; /* This is set during rendering */
if (pipeline->viewport_state.pViewports == NULL || pipeline->viewport_state.viewportCount == 0U) { 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) { 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; return RSE_ERROR_NO_ERROR;
@@ -346,7 +348,8 @@ rse_err_t pipelines_build(struct graphics_context_t* context, struct pipeline_in
rse_err_t status = RSE_ERROR_NO_ERROR; rse_err_t status = RSE_ERROR_NO_ERROR;
if (VK_SUCCESS != vkCreateGraphicsPipelines(context->vulkan_handles.device, if (VK_SUCCESS !=
vkCreateGraphicsPipelines(context->vulkan_handles.device,
VK_NULL_HANDLE, VK_NULL_HANDLE,
pipelines_infos_list->pipeline_create_infos_count, pipelines_infos_list->pipeline_create_infos_count,
pipelines_infos_list->create_infos, pipelines_infos_list->create_infos,
@@ -375,9 +378,10 @@ rse_err_t pipeline_add(const struct graphics_context_t* context,
VkPipelineVertexInputStateCreateInfo* vertex_bindings_ci = NULL; VkPipelineVertexInputStateCreateInfo* vertex_bindings_ci = NULL;
VkPipelineDynamicStateCreateInfo* dynamic_states_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; 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) { for (iter = 0U; iter < pipeline->dynamic_states_count; ++iter) {
if (pipeline->dynamic_states[iter] == dynamic_state) { if (pipeline->dynamic_states[iter] == dynamic_state) {
dynamic_state_found = 1; dynamic_state_found = 1;
-45
View File
@@ -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