fixing spaces in indentaions

This commit is contained in:
Kbz-8
2023-11-20 07:28:03 +01:00
parent 35f5f41258
commit 9fdb514541
13 changed files with 3010 additions and 3036 deletions

View File

@@ -6,7 +6,7 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */ /* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/04 22:10:52 by maldavid #+# #+# */ /* Created: 2022/10/04 22:10:52 by maldavid #+# #+# */
/* Updated: 2023/11/16 13:47:50 by maldavid ### ########.fr */ /* Updated: 2023/11/20 07:17:18 by maldavid ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@@ -60,7 +60,7 @@ namespace mlx::core
void Application::destroyTexture(void* ptr) void Application::destroyTexture(void* ptr)
{ {
vkDeviceWaitIdle(Render_Core::get().getDevice().get()); vkDeviceWaitIdle(Render_Core::get().getDevice().get());
Texture* texture = static_cast<Texture*>(ptr); Texture* texture = static_cast<Texture*>(ptr);
texture->destroy(); texture->destroy();
} }

View File

@@ -6,7 +6,7 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */ /* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2023/04/02 15:13:55 by maldavid #+# #+# */ /* Created: 2023/04/02 15:13:55 by maldavid #+# #+# */
/* Updated: 2023/11/14 06:59:12 by maldavid ### ########.fr */ /* Updated: 2023/11/20 07:18:35 by maldavid ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@@ -73,7 +73,7 @@ namespace mlx
GraphicsSupport::~GraphicsSupport() GraphicsSupport::~GraphicsSupport()
{ {
vkDeviceWaitIdle(Render_Core::get().getDevice().get()); vkDeviceWaitIdle(Render_Core::get().getDevice().get());
_pixel_put_pipeline.destroy(); _pixel_put_pipeline.destroy();
_text_put_pipeline->destroy(); _text_put_pipeline->destroy();
_renderer->destroy(); _renderer->destroy();

View File

@@ -6,7 +6,7 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */ /* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/08 19:16:32 by maldavid #+# #+# */ /* Created: 2022/10/08 19:16:32 by maldavid #+# #+# */
/* Updated: 2023/11/14 05:00:44 by maldavid ### ########.fr */ /* Updated: 2023/11/20 07:20:43 by maldavid ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@@ -33,39 +33,39 @@ namespace mlx
} }
#ifdef DEBUG #ifdef DEBUG
constexpr const bool enableValidationLayers = true; constexpr const bool enableValidationLayers = true;
#else #else
constexpr const bool enableValidationLayers = false; constexpr const bool enableValidationLayers = false;
#endif #endif
const std::vector<const char*> validationLayers = { "VK_LAYER_KHRONOS_validation" }; const std::vector<const char*> validationLayers = { "VK_LAYER_KHRONOS_validation" };
constexpr const int MAX_FRAMES_IN_FLIGHT = 3; constexpr const int MAX_FRAMES_IN_FLIGHT = 3;
class Render_Core : public Singleton<Render_Core> class Render_Core : public Singleton<Render_Core>
{ {
public: public:
Render_Core() = default; Render_Core() = default;
void init(); void init();
void destroy(); void destroy();
inline Instance& getInstance() noexcept { return _instance; } inline Instance& getInstance() noexcept { return _instance; }
inline Device& getDevice() noexcept { return _device; } inline Device& getDevice() noexcept { return _device; }
inline Queues& getQueue() noexcept { return _queues; } inline Queues& getQueue() noexcept { return _queues; }
inline GPUallocator& getAllocator() noexcept { return _allocator; } inline GPUallocator& getAllocator() noexcept { return _allocator; }
inline ValidationLayers& getLayers() noexcept { return _layers; } inline ValidationLayers& getLayers() noexcept { return _layers; }
~Render_Core() = default; ~Render_Core() = default;
private: private:
ValidationLayers _layers; ValidationLayers _layers;
Queues _queues; Queues _queues;
Device _device; Device _device;
Instance _instance; Instance _instance;
GPUallocator _allocator; GPUallocator _allocator;
bool _is_init = false; bool _is_init = false;
}; };
} }
#endif // __MLX_RENDER_CORE__ #endif // __MLX_RENDER_CORE__

View File

@@ -6,7 +6,7 @@
/* By: maldavid <marvin@42.fr> +#+ +:+ +#+ */ /* By: maldavid <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2022/12/19 14:05:25 by maldavid #+# #+# */ /* Created: 2022/12/19 14:05:25 by maldavid #+# #+# */
/* Updated: 2023/11/08 20:15:36 by maldavid ### ########.fr */ /* Updated: 2023/11/20 07:21:57 by maldavid ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@@ -35,31 +35,31 @@ namespace mlx
} }
bool ValidationLayers::checkValidationLayerSupport() bool ValidationLayers::checkValidationLayerSupport()
{ {
uint32_t layerCount; uint32_t layerCount;
vkEnumerateInstanceLayerProperties(&layerCount, nullptr); vkEnumerateInstanceLayerProperties(&layerCount, nullptr);
std::vector<VkLayerProperties> availableLayers(layerCount); std::vector<VkLayerProperties> availableLayers(layerCount);
vkEnumerateInstanceLayerProperties(&layerCount, availableLayers.data()); vkEnumerateInstanceLayerProperties(&layerCount, availableLayers.data());
for(const char* layerName : validationLayers) for(const char* layerName : validationLayers)
{ {
bool layerFound = false; bool layerFound = false;
for(const auto& layerProperties : availableLayers) for(const auto& layerProperties : availableLayers)
{ {
if(std::strcmp(layerName, layerProperties.layerName) == 0) if(std::strcmp(layerName, layerProperties.layerName) == 0)
{ {
layerFound = true; layerFound = true;
break; break;
} }
} }
if(!layerFound) if(!layerFound)
return false; return false;
} }
return true; return true;
} }
void ValidationLayers::destroy() void ValidationLayers::destroy()
{ {
@@ -71,16 +71,16 @@ namespace mlx
VkResult ValidationLayers::createDebugUtilsMessengerEXT(const VkDebugUtilsMessengerCreateInfoEXT* pCreateInfo, const VkAllocationCallbacks* pAllocator) VkResult ValidationLayers::createDebugUtilsMessengerEXT(const VkDebugUtilsMessengerCreateInfoEXT* pCreateInfo, const VkAllocationCallbacks* pAllocator)
{ {
auto func = (PFN_vkCreateDebugUtilsMessengerEXT)vkGetInstanceProcAddr(Render_Core::get().getInstance().get(), "vkCreateDebugUtilsMessengerEXT"); auto func = (PFN_vkCreateDebugUtilsMessengerEXT)vkGetInstanceProcAddr(Render_Core::get().getInstance().get(), "vkCreateDebugUtilsMessengerEXT");
return func != nullptr ? func(Render_Core::get().getInstance().get(), pCreateInfo, pAllocator, &_debugMessenger) : VK_ERROR_EXTENSION_NOT_PRESENT; return func != nullptr ? func(Render_Core::get().getInstance().get(), pCreateInfo, pAllocator, &_debugMessenger) : VK_ERROR_EXTENSION_NOT_PRESENT;
} }
void ValidationLayers::populateDebugMessengerCreateInfo(VkDebugUtilsMessengerCreateInfoEXT& createInfo) void ValidationLayers::populateDebugMessengerCreateInfo(VkDebugUtilsMessengerCreateInfoEXT& createInfo)
{ {
createInfo = {}; createInfo = {};
createInfo.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_MESSENGER_CREATE_INFO_EXT; createInfo.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_MESSENGER_CREATE_INFO_EXT;
createInfo.messageSeverity = VK_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT | VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT | VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT; createInfo.messageSeverity = VK_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT | VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT | VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT;
createInfo.messageType = VK_DEBUG_UTILS_MESSAGE_TYPE_GENERAL_BIT_EXT | VK_DEBUG_UTILS_MESSAGE_TYPE_VALIDATION_BIT_EXT | VK_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT; createInfo.messageType = VK_DEBUG_UTILS_MESSAGE_TYPE_GENERAL_BIT_EXT | VK_DEBUG_UTILS_MESSAGE_TYPE_VALIDATION_BIT_EXT | VK_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT;
createInfo.pfnUserCallback = ValidationLayers::debugCallback; createInfo.pfnUserCallback = ValidationLayers::debugCallback;
} }
VKAPI_ATTR VkBool32 VKAPI_CALL ValidationLayers::debugCallback(VkDebugUtilsMessageSeverityFlagBitsEXT messageSeverity, VkDebugUtilsMessageTypeFlagsEXT messageType, const VkDebugUtilsMessengerCallbackDataEXT* pCallbackData, void* pUserData) VKAPI_ATTR VkBool32 VKAPI_CALL ValidationLayers::debugCallback(VkDebugUtilsMessageSeverityFlagBitsEXT messageSeverity, VkDebugUtilsMessageTypeFlagsEXT messageType, const VkDebugUtilsMessengerCallbackDataEXT* pCallbackData, void* pUserData)

View File

@@ -6,7 +6,7 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */ /* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2022/12/18 21:27:38 by maldavid #+# #+# */ /* Created: 2022/12/18 21:27:38 by maldavid #+# #+# */
/* Updated: 2023/11/18 16:57:57 by maldavid ### ########.fr */ /* Updated: 2023/11/20 07:24:09 by maldavid ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@@ -183,21 +183,21 @@ namespace mlx
core::error::report(e_kind::fatal_error, "Vulkan : failed to create a fragment shader module"); core::error::report(e_kind::fatal_error, "Vulkan : failed to create a fragment shader module");
VkPipelineShaderStageCreateInfo vertShaderStageInfo{}; VkPipelineShaderStageCreateInfo vertShaderStageInfo{};
vertShaderStageInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; vertShaderStageInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO;
vertShaderStageInfo.stage = VK_SHADER_STAGE_VERTEX_BIT; vertShaderStageInfo.stage = VK_SHADER_STAGE_VERTEX_BIT;
vertShaderStageInfo.module = vshader; vertShaderStageInfo.module = vshader;
vertShaderStageInfo.pName = "main"; vertShaderStageInfo.pName = "main";
VkPipelineShaderStageCreateInfo fragShaderStageInfo{}; VkPipelineShaderStageCreateInfo fragShaderStageInfo{};
fragShaderStageInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; fragShaderStageInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO;
fragShaderStageInfo.stage = VK_SHADER_STAGE_FRAGMENT_BIT; fragShaderStageInfo.stage = VK_SHADER_STAGE_FRAGMENT_BIT;
fragShaderStageInfo.module = fshader; fragShaderStageInfo.module = fshader;
fragShaderStageInfo.pName = "main"; fragShaderStageInfo.pName = "main";
std::vector<VkPipelineShaderStageCreateInfo> stages = {vertShaderStageInfo, fragShaderStageInfo}; std::vector<VkPipelineShaderStageCreateInfo> stages = {vertShaderStageInfo, fragShaderStageInfo};
auto bindingDescription = Vertex::getBindingDescription(); auto bindingDescription = Vertex::getBindingDescription();
auto attributeDescriptions = Vertex::getAttributeDescriptions(); auto attributeDescriptions = Vertex::getAttributeDescriptions();
VkPipelineVertexInputStateCreateInfo vertexInputStateCreateInfo{}; VkPipelineVertexInputStateCreateInfo vertexInputStateCreateInfo{};
vertexInputStateCreateInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; vertexInputStateCreateInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO;
@@ -206,10 +206,10 @@ namespace mlx
vertexInputStateCreateInfo.vertexAttributeDescriptionCount = static_cast<uint32_t>(attributeDescriptions.size()); vertexInputStateCreateInfo.vertexAttributeDescriptionCount = static_cast<uint32_t>(attributeDescriptions.size());
vertexInputStateCreateInfo.pVertexAttributeDescriptions = attributeDescriptions.data(); vertexInputStateCreateInfo.pVertexAttributeDescriptions = attributeDescriptions.data();
VkPipelineInputAssemblyStateCreateInfo inputAssembly{}; VkPipelineInputAssemblyStateCreateInfo inputAssembly{};
inputAssembly.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; inputAssembly.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO;
inputAssembly.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST; inputAssembly.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST;
inputAssembly.primitiveRestartEnable = VK_FALSE; inputAssembly.primitiveRestartEnable = VK_FALSE;
VkDynamicState states[] = { VK_DYNAMIC_STATE_VIEWPORT, VK_DYNAMIC_STATE_SCISSOR }; VkDynamicState states[] = { VK_DYNAMIC_STATE_VIEWPORT, VK_DYNAMIC_STATE_SCISSOR };
@@ -219,54 +219,54 @@ namespace mlx
dynamicStates.dynamicStateCount = statesCount; dynamicStates.dynamicStateCount = statesCount;
dynamicStates.pDynamicStates = states; dynamicStates.pDynamicStates = states;
VkViewport viewport{}; VkViewport viewport{};
viewport.x = 0.0f; viewport.x = 0.0f;
viewport.y = 0.0f; viewport.y = 0.0f;
viewport.width = (float)renderer.getSwapChain().getExtent().width; viewport.width = (float)renderer.getSwapChain().getExtent().width;
viewport.height = (float)renderer.getSwapChain().getExtent().height; viewport.height = (float)renderer.getSwapChain().getExtent().height;
viewport.minDepth = 0.0f; viewport.minDepth = 0.0f;
viewport.maxDepth = 1.0f; viewport.maxDepth = 1.0f;
VkRect2D scissor{}; VkRect2D scissor{};
scissor.offset = { 0, 0 }; scissor.offset = { 0, 0 };
scissor.extent = renderer.getSwapChain().getExtent(); scissor.extent = renderer.getSwapChain().getExtent();
VkPipelineViewportStateCreateInfo viewportState{}; VkPipelineViewportStateCreateInfo viewportState{};
viewportState.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; viewportState.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO;
viewportState.viewportCount = 1; viewportState.viewportCount = 1;
viewportState.pViewports = &viewport; viewportState.pViewports = &viewport;
viewportState.scissorCount = 1; viewportState.scissorCount = 1;
viewportState.pScissors = &scissor; viewportState.pScissors = &scissor;
VkPipelineRasterizationStateCreateInfo rasterizer{}; VkPipelineRasterizationStateCreateInfo rasterizer{};
rasterizer.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; rasterizer.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO;
rasterizer.depthClampEnable = VK_FALSE; rasterizer.depthClampEnable = VK_FALSE;
rasterizer.rasterizerDiscardEnable = VK_FALSE; rasterizer.rasterizerDiscardEnable = VK_FALSE;
rasterizer.polygonMode = VK_POLYGON_MODE_FILL; rasterizer.polygonMode = VK_POLYGON_MODE_FILL;
rasterizer.lineWidth = 1.0f; rasterizer.lineWidth = 1.0f;
rasterizer.cullMode = VK_CULL_MODE_NONE; rasterizer.cullMode = VK_CULL_MODE_NONE;
rasterizer.frontFace = VK_FRONT_FACE_CLOCKWISE; rasterizer.frontFace = VK_FRONT_FACE_CLOCKWISE;
rasterizer.depthBiasEnable = VK_FALSE; rasterizer.depthBiasEnable = VK_FALSE;
VkPipelineMultisampleStateCreateInfo multisampling{}; VkPipelineMultisampleStateCreateInfo multisampling{};
multisampling.sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; multisampling.sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO;
multisampling.sampleShadingEnable = VK_FALSE; multisampling.sampleShadingEnable = VK_FALSE;
multisampling.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT; multisampling.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT;
VkPipelineColorBlendAttachmentState colorBlendAttachment{}; VkPipelineColorBlendAttachmentState colorBlendAttachment{};
colorBlendAttachment.colorWriteMask = VK_COLOR_COMPONENT_R_BIT | VK_COLOR_COMPONENT_G_BIT | VK_COLOR_COMPONENT_B_BIT | VK_COLOR_COMPONENT_A_BIT; colorBlendAttachment.colorWriteMask = VK_COLOR_COMPONENT_R_BIT | VK_COLOR_COMPONENT_G_BIT | VK_COLOR_COMPONENT_B_BIT | VK_COLOR_COMPONENT_A_BIT;
colorBlendAttachment.blendEnable = VK_FALSE; colorBlendAttachment.blendEnable = VK_FALSE;
VkPipelineColorBlendStateCreateInfo colorBlending{}; VkPipelineColorBlendStateCreateInfo colorBlending{};
colorBlending.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO; colorBlending.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO;
colorBlending.logicOpEnable = VK_FALSE; colorBlending.logicOpEnable = VK_FALSE;
colorBlending.logicOp = VK_LOGIC_OP_COPY; colorBlending.logicOp = VK_LOGIC_OP_COPY;
colorBlending.attachmentCount = 1; colorBlending.attachmentCount = 1;
colorBlending.pAttachments = &colorBlendAttachment; colorBlending.pAttachments = &colorBlendAttachment;
colorBlending.blendConstants[0] = 0.0f; colorBlending.blendConstants[0] = 0.0f;
colorBlending.blendConstants[1] = 0.0f; colorBlending.blendConstants[1] = 0.0f;
colorBlending.blendConstants[2] = 0.0f; colorBlending.blendConstants[2] = 0.0f;
colorBlending.blendConstants[3] = 0.0f; colorBlending.blendConstants[3] = 0.0f;
VkDescriptorSetLayout layouts[] = { VkDescriptorSetLayout layouts[] = {
renderer.getVertDescriptorSetLayout().get(), renderer.getVertDescriptorSetLayout().get(),
@@ -274,45 +274,44 @@ namespace mlx
}; };
VkPipelineLayoutCreateInfo pipelineLayoutInfo{}; VkPipelineLayoutCreateInfo pipelineLayoutInfo{};
pipelineLayoutInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; pipelineLayoutInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO;
pipelineLayoutInfo.setLayoutCount = 2; pipelineLayoutInfo.setLayoutCount = 2;
pipelineLayoutInfo.pSetLayouts = layouts; pipelineLayoutInfo.pSetLayouts = layouts;
pipelineLayoutInfo.pushConstantRangeCount = 1; pipelineLayoutInfo.pushConstantRangeCount = 1;
pipelineLayoutInfo.pPushConstantRanges = &push_constant; pipelineLayoutInfo.pPushConstantRanges = &push_constant;
if(vkCreatePipelineLayout(Render_Core::get().getDevice().get(), &pipelineLayoutInfo, nullptr, &_pipelineLayout) != VK_SUCCESS) if(vkCreatePipelineLayout(Render_Core::get().getDevice().get(), &pipelineLayoutInfo, nullptr, &_pipelineLayout) != VK_SUCCESS)
core::error::report(e_kind::fatal_error, "Vulkan : failed to create a graphics pipeline layout"); core::error::report(e_kind::fatal_error, "Vulkan : failed to create a graphics pipeline layout");
VkGraphicsPipelineCreateInfo pipelineInfo{}; VkGraphicsPipelineCreateInfo pipelineInfo{};
pipelineInfo.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; pipelineInfo.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO;
pipelineInfo.stageCount = stages.size(); pipelineInfo.stageCount = stages.size();
pipelineInfo.pStages = stages.data(); pipelineInfo.pStages = stages.data();
pipelineInfo.pVertexInputState = &vertexInputStateCreateInfo; pipelineInfo.pVertexInputState = &vertexInputStateCreateInfo;
pipelineInfo.pInputAssemblyState = &inputAssembly; pipelineInfo.pInputAssemblyState = &inputAssembly;
pipelineInfo.pViewportState = &viewportState; pipelineInfo.pViewportState = &viewportState;
pipelineInfo.pRasterizationState = &rasterizer; pipelineInfo.pRasterizationState = &rasterizer;
pipelineInfo.pMultisampleState = &multisampling; pipelineInfo.pMultisampleState = &multisampling;
pipelineInfo.pColorBlendState = &colorBlending; pipelineInfo.pColorBlendState = &colorBlending;
pipelineInfo.pDynamicState = &dynamicStates; pipelineInfo.pDynamicState = &dynamicStates;
pipelineInfo.layout = _pipelineLayout; pipelineInfo.layout = _pipelineLayout;
pipelineInfo.renderPass = renderer.getRenderPass().get(); pipelineInfo.renderPass = renderer.getRenderPass().get();
pipelineInfo.subpass = 0; pipelineInfo.subpass = 0;
pipelineInfo.basePipelineHandle = VK_NULL_HANDLE; pipelineInfo.basePipelineHandle = VK_NULL_HANDLE;
if(vkCreateGraphicsPipelines(Render_Core::get().getDevice().get(), VK_NULL_HANDLE, 1, &pipelineInfo, nullptr, &_graphicsPipeline) != VK_SUCCESS) if(vkCreateGraphicsPipelines(Render_Core::get().getDevice().get(), VK_NULL_HANDLE, 1, &pipelineInfo, nullptr, &_graphicsPipeline) != VK_SUCCESS)
core::error::report(e_kind::fatal_error, "Vulkan : failed to create a graphics pipeline"); core::error::report(e_kind::fatal_error, "Vulkan : failed to create a graphics pipeline");
#ifdef DEBUG #ifdef DEBUG
core::error::report(e_kind::message, "Vulkan : created new graphic pipeline"); core::error::report(e_kind::message, "Vulkan : created new graphic pipeline");
#endif #endif
vkDestroyShaderModule(Render_Core::get().getDevice().get(), fshader, nullptr); vkDestroyShaderModule(Render_Core::get().getDevice().get(), fshader, nullptr);
vkDestroyShaderModule(Render_Core::get().getDevice().get(), vshader, nullptr); vkDestroyShaderModule(Render_Core::get().getDevice().get(), vshader, nullptr);
} }
void GraphicPipeline::destroy() noexcept void GraphicPipeline::destroy() noexcept
{ {
vkDestroyPipeline(Render_Core::get().getDevice().get(), _graphicsPipeline, nullptr); vkDestroyPipeline(Render_Core::get().getDevice().get(), _graphicsPipeline, nullptr);
vkDestroyPipelineLayout(Render_Core::get().getDevice().get(), _pipelineLayout, nullptr); vkDestroyPipelineLayout(Render_Core::get().getDevice().get(), _pipelineLayout, nullptr);
} }
} }

View File

@@ -6,7 +6,7 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */ /* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2022/12/18 17:25:16 by maldavid #+# #+# */ /* Created: 2022/12/18 17:25:16 by maldavid #+# #+# */
/* Updated: 2023/11/18 17:08:19 by maldavid ### ########.fr */ /* Updated: 2023/11/20 07:25:47 by maldavid ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@@ -130,7 +130,7 @@ namespace mlx
void Renderer::destroy() void Renderer::destroy()
{ {
vkDeviceWaitIdle(Render_Core::get().getDevice().get()); vkDeviceWaitIdle(Render_Core::get().getDevice().get());
_pipeline.destroy(); _pipeline.destroy();
_uniform_buffer->destroy(); _uniform_buffer->destroy();

View File

@@ -6,7 +6,7 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */ /* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2022/12/18 17:14:45 by maldavid #+# #+# */ /* Created: 2022/12/18 17:14:45 by maldavid #+# #+# */
/* Updated: 2023/11/18 16:56:09 by maldavid ### ########.fr */ /* Updated: 2023/11/20 07:26:12 by maldavid ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@@ -82,22 +82,22 @@ namespace mlx
public: public:
Renderer() = default; Renderer() = default;
void init(); void init();
bool beginFrame(); bool beginFrame();
void endFrame(); void endFrame();
void destroy(); void destroy();
inline class MLX_Window* getWindow() { return _window; }
inline void setWindow(class MLX_Window* window) { _window = window; }
inline Surface& getSurface() noexcept { return _surface; } inline class MLX_Window* getWindow() { return _window; }
inline void setWindow(class MLX_Window* window) { _window = window; }
inline Surface& getSurface() noexcept { return _surface; }
inline CmdPool& getCmdPool() noexcept { return _cmd.getCmdPool(); } inline CmdPool& getCmdPool() noexcept { return _cmd.getCmdPool(); }
inline UBO* getUniformBuffer() noexcept { return _uniform_buffer.get(); } inline UBO* getUniformBuffer() noexcept { return _uniform_buffer.get(); }
inline SwapChain& getSwapChain() noexcept { return _swapchain; } inline SwapChain& getSwapChain() noexcept { return _swapchain; }
inline Semaphore& getSemaphore(int i) noexcept { return _semaphores[i]; } inline Semaphore& getSemaphore(int i) noexcept { return _semaphores[i]; }
inline RenderPass& getRenderPass() noexcept { return _pass; } inline RenderPass& getRenderPass() noexcept { return _pass; }
inline GraphicPipeline& getPipeline() noexcept { return _pipeline; } inline GraphicPipeline& getPipeline() noexcept { return _pipeline; }
inline CmdBuffer& getCmdBuffer(int i) noexcept { return _cmd.getCmdBuffer(i); } inline CmdBuffer& getCmdBuffer(int i) noexcept { return _cmd.getCmdBuffer(i); }
inline CmdBuffer& getActiveCmdBuffer() noexcept { return _cmd.getCmdBuffer(_current_frame_index); } inline CmdBuffer& getActiveCmdBuffer() noexcept { return _cmd.getCmdBuffer(_current_frame_index); }
@@ -105,37 +105,37 @@ namespace mlx
inline DescriptorSet& getFragDescriptorSet() noexcept { return _frag_set; } inline DescriptorSet& getFragDescriptorSet() noexcept { return _frag_set; }
inline DescriptorSetLayout& getVertDescriptorSetLayout() noexcept { return _vert_layout; } inline DescriptorSetLayout& getVertDescriptorSetLayout() noexcept { return _vert_layout; }
inline DescriptorSetLayout& getFragDescriptorSetLayout() noexcept { return _frag_layout; } inline DescriptorSetLayout& getFragDescriptorSetLayout() noexcept { return _frag_layout; }
inline uint32_t getActiveImageIndex() noexcept { return _current_frame_index; } inline uint32_t getActiveImageIndex() noexcept { return _current_frame_index; }
inline uint32_t getImageIndex() noexcept { return _image_index; } inline uint32_t getImageIndex() noexcept { return _image_index; }
constexpr inline void requireFrameBufferResize(int index) noexcept { _framebufferResized = true; } constexpr inline void requireFrameBufferResize(int index) noexcept { _framebufferResized = true; }
~Renderer() = default; ~Renderer() = default;
private: private:
GraphicPipeline _pipeline; GraphicPipeline _pipeline;
CmdManager _cmd; CmdManager _cmd;
RenderPass _pass; RenderPass _pass;
Surface _surface; Surface _surface;
SwapChain _swapchain; SwapChain _swapchain;
std::array<Semaphore, MAX_FRAMES_IN_FLIGHT> _semaphores; std::array<Semaphore, MAX_FRAMES_IN_FLIGHT> _semaphores;
std::vector<FrameBuffer> _framebuffers; std::vector<FrameBuffer> _framebuffers;
DescriptorPool _desc_pool; DescriptorPool _desc_pool;
DescriptorSetLayout _vert_layout; DescriptorSetLayout _vert_layout;
DescriptorSetLayout _frag_layout; DescriptorSetLayout _frag_layout;
DescriptorSet _vert_set; DescriptorSet _vert_set;
DescriptorSet _frag_set; DescriptorSet _frag_set;
std::unique_ptr<UBO> _uniform_buffer; std::unique_ptr<UBO> _uniform_buffer;
class MLX_Window* _window = nullptr; class MLX_Window* _window = nullptr;
uint32_t _current_frame_index = 0; uint32_t _current_frame_index = 0;
uint32_t _image_index = 0; uint32_t _image_index = 0;
bool _framebufferResized = false; bool _framebufferResized = false;
}; };
} }

View File

@@ -6,7 +6,7 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */ /* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/06 18:18:06 by maldavid #+# #+# */ /* Created: 2022/10/06 18:18:06 by maldavid #+# #+# */
/* Updated: 2023/11/18 17:20:23 by maldavid ### ########.fr */ /* Updated: 2023/11/20 07:24:26 by maldavid ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@@ -42,7 +42,7 @@ namespace mlx
void FrameBuffer::destroy() noexcept void FrameBuffer::destroy() noexcept
{ {
vkDestroyFramebuffer(Render_Core::get().getDevice().get(), _framebuffer, nullptr); vkDestroyFramebuffer(Render_Core::get().getDevice().get(), _framebuffer, nullptr);
_framebuffer = VK_NULL_HANDLE; _framebuffer = VK_NULL_HANDLE;
} }
} }

View File

@@ -6,7 +6,7 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */ /* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/06 18:21:36 by maldavid #+# #+# */ /* Created: 2022/10/06 18:21:36 by maldavid #+# #+# */
/* Updated: 2023/11/18 15:58:26 by maldavid ### ########.fr */ /* Updated: 2023/11/20 07:24:40 by maldavid ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@@ -14,6 +14,7 @@
#include <renderer/core/render_core.h> #include <renderer/core/render_core.h>
#include <renderer/renderer.h> #include <renderer/renderer.h>
#include <renderer/renderpass/vk_framebuffer.h> #include <renderer/renderpass/vk_framebuffer.h>
#include <vulkan/vulkan_core.h>
namespace mlx namespace mlx
{ {
@@ -85,5 +86,6 @@ namespace mlx
void RenderPass::destroy() noexcept void RenderPass::destroy() noexcept
{ {
vkDestroyRenderPass(Render_Core::get().getDevice().get(), _renderPass, nullptr); vkDestroyRenderPass(Render_Core::get().getDevice().get(), _renderPass, nullptr);
_renderPass = VK_NULL_HANDLE;
} }
} }

View File

@@ -6,7 +6,7 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */ /* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/06 18:22:00 by maldavid #+# #+# */ /* Created: 2022/10/06 18:22:00 by maldavid #+# #+# */
/* Updated: 2023/11/18 15:58:12 by maldavid ### ########.fr */ /* Updated: 2023/11/20 07:24:48 by maldavid ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@@ -26,8 +26,8 @@ namespace mlx
void begin(class CmdBuffer& cmd, class FrameBuffer& fb); void begin(class CmdBuffer& cmd, class FrameBuffer& fb);
void end(class CmdBuffer& cmd); void end(class CmdBuffer& cmd);
inline VkRenderPass& operator()() noexcept { return _renderPass; } inline VkRenderPass& operator()() noexcept { return _renderPass; }
inline VkRenderPass& get() noexcept { return _renderPass; } inline VkRenderPass& get() noexcept { return _renderPass; }
private: private:
VkRenderPass _renderPass = VK_NULL_HANDLE; VkRenderPass _renderPass = VK_NULL_HANDLE;

View File

@@ -6,7 +6,7 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */ /* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/06 18:23:27 by maldavid #+# #+# */ /* Created: 2022/10/06 18:23:27 by maldavid #+# #+# */
/* Updated: 2023/11/18 17:15:18 by maldavid ### ########.fr */ /* Updated: 2023/11/20 07:25:30 by maldavid ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@@ -19,26 +19,26 @@
namespace mlx namespace mlx
{ {
class SwapChain class SwapChain
{ {
friend class GraphicPipeline; friend class GraphicPipeline;
friend class RenderPass; friend class RenderPass;
friend class Renderer; friend class Renderer;
public: public:
struct SwapChainSupportDetails struct SwapChainSupportDetails
{ {
VkSurfaceCapabilitiesKHR capabilities; VkSurfaceCapabilitiesKHR capabilities;
std::vector<VkSurfaceFormatKHR> formats; std::vector<VkSurfaceFormatKHR> formats;
std::vector<VkPresentModeKHR> presentModes; std::vector<VkPresentModeKHR> presentModes;
}; };
public: public:
SwapChain() = default; SwapChain() = default;
void init(class Renderer* renderer); void init(class Renderer* renderer);
void recreate(); void recreate();
void destroy() noexcept; void destroy() noexcept;
SwapChainSupportDetails querySwapChainSupport(VkPhysicalDevice device); SwapChainSupportDetails querySwapChainSupport(VkPhysicalDevice device);
VkExtent2D chooseSwapExtent(const VkSurfaceCapabilitiesKHR& capabilities); VkExtent2D chooseSwapExtent(const VkSurfaceCapabilitiesKHR& capabilities);
@@ -54,14 +54,14 @@ namespace mlx
~SwapChain() = default; ~SwapChain() = default;
private: private:
SwapChainSupportDetails _swapChainSupport; SwapChainSupportDetails _swapChainSupport;
VkSwapchainKHR _swapChain; VkSwapchainKHR _swapChain;
std::vector<Image> _images; std::vector<Image> _images;
VkFormat _swapChainImageFormat; VkFormat _swapChainImageFormat;
VkExtent2D _extent; VkExtent2D _extent;
class Renderer* _renderer = nullptr; class Renderer* _renderer = nullptr;
}; };
} }
#endif // __MLX_VK_SWAPCHAIN__ #endif // __MLX_VK_SWAPCHAIN__

File diff suppressed because it is too large Load Diff

View File

@@ -1,27 +0,0 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* endian.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/04/06 15:33:15 by maldavid #+# #+# */
/* Updated: 2023/04/06 15:35:25 by maldavid ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef __MLX_ENDIAN__
#define __MLX_ENDIAN__
namespace mlx
{
inline bool isSystemBigEndian()
{
const int value = 0x01;
const void* address = static_cast<const void*>(&value);
const unsigned char* least_significant_address = static_cast<const unsigned char*>(address);
return (*least_significant_address != 0x01);
}
}
#endif