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> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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)
{
vkDeviceWaitIdle(Render_Core::get().getDevice().get());
vkDeviceWaitIdle(Render_Core::get().getDevice().get());
Texture* texture = static_cast<Texture*>(ptr);
texture->destroy();
}

View File

@@ -6,7 +6,7 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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()
{
vkDeviceWaitIdle(Render_Core::get().getDevice().get());
vkDeviceWaitIdle(Render_Core::get().getDevice().get());
_pixel_put_pipeline.destroy();
_text_put_pipeline->destroy();
_renderer->destroy();

View File

@@ -6,7 +6,7 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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
constexpr const bool enableValidationLayers = true;
#else
constexpr const bool enableValidationLayers = false;
#endif
constexpr const bool enableValidationLayers = true;
#else
constexpr const bool enableValidationLayers = false;
#endif
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>
{
public:
Render_Core() = default;
class Render_Core : public Singleton<Render_Core>
{
public:
Render_Core() = default;
void init();
void destroy();
void init();
void destroy();
inline Instance& getInstance() noexcept { return _instance; }
inline Device& getDevice() noexcept { return _device; }
inline Queues& getQueue() noexcept { return _queues; }
inline Instance& getInstance() noexcept { return _instance; }
inline Device& getDevice() noexcept { return _device; }
inline Queues& getQueue() noexcept { return _queues; }
inline GPUallocator& getAllocator() noexcept { return _allocator; }
inline ValidationLayers& getLayers() noexcept { return _layers; }
~Render_Core() = default;
private:
private:
ValidationLayers _layers;
Queues _queues;
Device _device;
Instance _instance;
Queues _queues;
Device _device;
Instance _instance;
GPUallocator _allocator;
bool _is_init = false;
};
bool _is_init = false;
};
}
#endif // __MLX_RENDER_CORE__

View File

@@ -6,7 +6,7 @@
/* By: maldavid <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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()
{
uint32_t layerCount;
vkEnumerateInstanceLayerProperties(&layerCount, nullptr);
{
uint32_t layerCount;
vkEnumerateInstanceLayerProperties(&layerCount, nullptr);
std::vector<VkLayerProperties> availableLayers(layerCount);
vkEnumerateInstanceLayerProperties(&layerCount, availableLayers.data());
std::vector<VkLayerProperties> availableLayers(layerCount);
vkEnumerateInstanceLayerProperties(&layerCount, availableLayers.data());
for(const char* layerName : validationLayers)
{
bool layerFound = false;
for(const char* layerName : validationLayers)
{
bool layerFound = false;
for(const auto& layerProperties : availableLayers)
{
if(std::strcmp(layerName, layerProperties.layerName) == 0)
{
layerFound = true;
break;
}
}
for(const auto& layerProperties : availableLayers)
{
if(std::strcmp(layerName, layerProperties.layerName) == 0)
{
layerFound = true;
break;
}
}
if(!layerFound)
return false;
}
return true;
}
if(!layerFound)
return false;
}
return true;
}
void ValidationLayers::destroy()
{
@@ -71,16 +71,16 @@ namespace mlx
VkResult ValidationLayers::createDebugUtilsMessengerEXT(const VkDebugUtilsMessengerCreateInfoEXT* pCreateInfo, const VkAllocationCallbacks* pAllocator)
{
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)
{
createInfo = {};
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.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.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.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;
}
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> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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");
VkPipelineShaderStageCreateInfo vertShaderStageInfo{};
vertShaderStageInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO;
vertShaderStageInfo.stage = VK_SHADER_STAGE_VERTEX_BIT;
vertShaderStageInfo.module = vshader;
vertShaderStageInfo.pName = "main";
vertShaderStageInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO;
vertShaderStageInfo.stage = VK_SHADER_STAGE_VERTEX_BIT;
vertShaderStageInfo.module = vshader;
vertShaderStageInfo.pName = "main";
VkPipelineShaderStageCreateInfo fragShaderStageInfo{};
fragShaderStageInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO;
fragShaderStageInfo.stage = VK_SHADER_STAGE_FRAGMENT_BIT;
fragShaderStageInfo.module = fshader;
fragShaderStageInfo.pName = "main";
VkPipelineShaderStageCreateInfo fragShaderStageInfo{};
fragShaderStageInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO;
fragShaderStageInfo.stage = VK_SHADER_STAGE_FRAGMENT_BIT;
fragShaderStageInfo.module = fshader;
fragShaderStageInfo.pName = "main";
std::vector<VkPipelineShaderStageCreateInfo> stages = {vertShaderStageInfo, fragShaderStageInfo};
auto bindingDescription = Vertex::getBindingDescription();
auto attributeDescriptions = Vertex::getAttributeDescriptions();
auto attributeDescriptions = Vertex::getAttributeDescriptions();
VkPipelineVertexInputStateCreateInfo vertexInputStateCreateInfo{};
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.pVertexAttributeDescriptions = attributeDescriptions.data();
VkPipelineInputAssemblyStateCreateInfo inputAssembly{};
inputAssembly.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO;
inputAssembly.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST;
inputAssembly.primitiveRestartEnable = VK_FALSE;
VkPipelineInputAssemblyStateCreateInfo inputAssembly{};
inputAssembly.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO;
inputAssembly.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST;
inputAssembly.primitiveRestartEnable = VK_FALSE;
VkDynamicState states[] = { VK_DYNAMIC_STATE_VIEWPORT, VK_DYNAMIC_STATE_SCISSOR };
@@ -219,54 +219,54 @@ namespace mlx
dynamicStates.dynamicStateCount = statesCount;
dynamicStates.pDynamicStates = states;
VkViewport viewport{};
viewport.x = 0.0f;
viewport.y = 0.0f;
viewport.width = (float)renderer.getSwapChain().getExtent().width;
viewport.height = (float)renderer.getSwapChain().getExtent().height;
viewport.minDepth = 0.0f;
viewport.maxDepth = 1.0f;
VkViewport viewport{};
viewport.x = 0.0f;
viewport.y = 0.0f;
viewport.width = (float)renderer.getSwapChain().getExtent().width;
viewport.height = (float)renderer.getSwapChain().getExtent().height;
viewport.minDepth = 0.0f;
viewport.maxDepth = 1.0f;
VkRect2D scissor{};
scissor.offset = { 0, 0 };
scissor.extent = renderer.getSwapChain().getExtent();
VkRect2D scissor{};
scissor.offset = { 0, 0 };
scissor.extent = renderer.getSwapChain().getExtent();
VkPipelineViewportStateCreateInfo viewportState{};
viewportState.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO;
viewportState.viewportCount = 1;
viewportState.pViewports = &viewport;
viewportState.scissorCount = 1;
viewportState.pScissors = &scissor;
VkPipelineViewportStateCreateInfo viewportState{};
viewportState.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO;
viewportState.viewportCount = 1;
viewportState.pViewports = &viewport;
viewportState.scissorCount = 1;
viewportState.pScissors = &scissor;
VkPipelineRasterizationStateCreateInfo rasterizer{};
rasterizer.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO;
rasterizer.depthClampEnable = VK_FALSE;
rasterizer.rasterizerDiscardEnable = VK_FALSE;
rasterizer.polygonMode = VK_POLYGON_MODE_FILL;
rasterizer.lineWidth = 1.0f;
rasterizer.cullMode = VK_CULL_MODE_NONE;
rasterizer.frontFace = VK_FRONT_FACE_CLOCKWISE;
rasterizer.depthBiasEnable = VK_FALSE;
VkPipelineRasterizationStateCreateInfo rasterizer{};
rasterizer.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO;
rasterizer.depthClampEnable = VK_FALSE;
rasterizer.rasterizerDiscardEnable = VK_FALSE;
rasterizer.polygonMode = VK_POLYGON_MODE_FILL;
rasterizer.lineWidth = 1.0f;
rasterizer.cullMode = VK_CULL_MODE_NONE;
rasterizer.frontFace = VK_FRONT_FACE_CLOCKWISE;
rasterizer.depthBiasEnable = VK_FALSE;
VkPipelineMultisampleStateCreateInfo multisampling{};
multisampling.sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO;
multisampling.sampleShadingEnable = VK_FALSE;
multisampling.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT;
VkPipelineMultisampleStateCreateInfo multisampling{};
multisampling.sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO;
multisampling.sampleShadingEnable = VK_FALSE;
multisampling.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT;
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.blendEnable = VK_FALSE;
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.blendEnable = VK_FALSE;
VkPipelineColorBlendStateCreateInfo colorBlending{};
colorBlending.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO;
colorBlending.logicOpEnable = VK_FALSE;
colorBlending.logicOp = VK_LOGIC_OP_COPY;
colorBlending.attachmentCount = 1;
colorBlending.pAttachments = &colorBlendAttachment;
colorBlending.blendConstants[0] = 0.0f;
colorBlending.blendConstants[1] = 0.0f;
colorBlending.blendConstants[2] = 0.0f;
colorBlending.blendConstants[3] = 0.0f;
VkPipelineColorBlendStateCreateInfo colorBlending{};
colorBlending.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO;
colorBlending.logicOpEnable = VK_FALSE;
colorBlending.logicOp = VK_LOGIC_OP_COPY;
colorBlending.attachmentCount = 1;
colorBlending.pAttachments = &colorBlendAttachment;
colorBlending.blendConstants[0] = 0.0f;
colorBlending.blendConstants[1] = 0.0f;
colorBlending.blendConstants[2] = 0.0f;
colorBlending.blendConstants[3] = 0.0f;
VkDescriptorSetLayout layouts[] = {
renderer.getVertDescriptorSetLayout().get(),
@@ -274,45 +274,44 @@ namespace mlx
};
VkPipelineLayoutCreateInfo pipelineLayoutInfo{};
pipelineLayoutInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO;
pipelineLayoutInfo.setLayoutCount = 2;
pipelineLayoutInfo.pSetLayouts = layouts;
pipelineLayoutInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO;
pipelineLayoutInfo.setLayoutCount = 2;
pipelineLayoutInfo.pSetLayouts = layouts;
pipelineLayoutInfo.pushConstantRangeCount = 1;
pipelineLayoutInfo.pPushConstantRanges = &push_constant;
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");
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");
VkGraphicsPipelineCreateInfo pipelineInfo{};
pipelineInfo.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO;
pipelineInfo.stageCount = stages.size();
pipelineInfo.pStages = stages.data();
pipelineInfo.pVertexInputState = &vertexInputStateCreateInfo;
pipelineInfo.pInputAssemblyState = &inputAssembly;
pipelineInfo.pViewportState = &viewportState;
pipelineInfo.pRasterizationState = &rasterizer;
pipelineInfo.pMultisampleState = &multisampling;
pipelineInfo.pColorBlendState = &colorBlending;
VkGraphicsPipelineCreateInfo pipelineInfo{};
pipelineInfo.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO;
pipelineInfo.stageCount = stages.size();
pipelineInfo.pStages = stages.data();
pipelineInfo.pVertexInputState = &vertexInputStateCreateInfo;
pipelineInfo.pInputAssemblyState = &inputAssembly;
pipelineInfo.pViewportState = &viewportState;
pipelineInfo.pRasterizationState = &rasterizer;
pipelineInfo.pMultisampleState = &multisampling;
pipelineInfo.pColorBlendState = &colorBlending;
pipelineInfo.pDynamicState = &dynamicStates;
pipelineInfo.layout = _pipelineLayout;
pipelineInfo.renderPass = renderer.getRenderPass().get();
pipelineInfo.subpass = 0;
pipelineInfo.basePipelineHandle = VK_NULL_HANDLE;
pipelineInfo.layout = _pipelineLayout;
pipelineInfo.renderPass = renderer.getRenderPass().get();
pipelineInfo.subpass = 0;
pipelineInfo.basePipelineHandle = VK_NULL_HANDLE;
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");
#ifdef DEBUG
core::error::report(e_kind::message, "Vulkan : created new graphic pipeline");
#endif
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");
#ifdef DEBUG
core::error::report(e_kind::message, "Vulkan : created new graphic pipeline");
#endif
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
{
vkDestroyPipeline(Render_Core::get().getDevice().get(), _graphicsPipeline, nullptr);
void GraphicPipeline::destroy() noexcept
{
vkDestroyPipeline(Render_Core::get().getDevice().get(), _graphicsPipeline, nullptr);
vkDestroyPipelineLayout(Render_Core::get().getDevice().get(), _pipelineLayout, nullptr);
}
}
}

View File

@@ -6,7 +6,7 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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()
{
vkDeviceWaitIdle(Render_Core::get().getDevice().get());
vkDeviceWaitIdle(Render_Core::get().getDevice().get());
_pipeline.destroy();
_uniform_buffer->destroy();

View File

@@ -6,7 +6,7 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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:
Renderer() = default;
void init();
void init();
bool beginFrame();
void endFrame();
bool beginFrame();
void endFrame();
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 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 RenderPass& getRenderPass() noexcept { return _pass; }
inline RenderPass& getRenderPass() noexcept { return _pass; }
inline GraphicPipeline& getPipeline() noexcept { return _pipeline; }
inline CmdBuffer& getCmdBuffer(int i) noexcept { return _cmd.getCmdBuffer(i); }
inline CmdBuffer& getActiveCmdBuffer() noexcept { return _cmd.getCmdBuffer(_current_frame_index); }
@@ -105,37 +105,37 @@ namespace mlx
inline DescriptorSet& getFragDescriptorSet() noexcept { return _frag_set; }
inline DescriptorSetLayout& getVertDescriptorSetLayout() noexcept { return _vert_layout; }
inline DescriptorSetLayout& getFragDescriptorSetLayout() noexcept { return _frag_layout; }
inline uint32_t getActiveImageIndex() noexcept { return _current_frame_index; }
inline uint32_t getImageIndex() noexcept { return _image_index; }
inline uint32_t getActiveImageIndex() noexcept { return _current_frame_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;
private:
GraphicPipeline _pipeline;
CmdManager _cmd;
RenderPass _pass;
Surface _surface;
SwapChain _swapchain;
RenderPass _pass;
Surface _surface;
SwapChain _swapchain;
std::array<Semaphore, MAX_FRAMES_IN_FLIGHT> _semaphores;
std::vector<FrameBuffer> _framebuffers;
DescriptorPool _desc_pool;
DescriptorSetLayout _vert_layout;
DescriptorSetLayout _frag_layout;
DescriptorSet _vert_set;
DescriptorSet _frag_set;
std::unique_ptr<UBO> _uniform_buffer;
class MLX_Window* _window = nullptr;
uint32_t _current_frame_index = 0;
uint32_t _image_index = 0;
bool _framebufferResized = false;
uint32_t _current_frame_index = 0;
uint32_t _image_index = 0;
bool _framebufferResized = false;
};
}

View File

@@ -6,7 +6,7 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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
{
vkDestroyFramebuffer(Render_Core::get().getDevice().get(), _framebuffer, nullptr);
vkDestroyFramebuffer(Render_Core::get().getDevice().get(), _framebuffer, nullptr);
_framebuffer = VK_NULL_HANDLE;
}
}

View File

@@ -6,7 +6,7 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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/renderer.h>
#include <renderer/renderpass/vk_framebuffer.h>
#include <vulkan/vulkan_core.h>
namespace mlx
{
@@ -85,5 +86,6 @@ namespace mlx
void RenderPass::destroy() noexcept
{
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> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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 end(class CmdBuffer& cmd);
inline VkRenderPass& operator()() noexcept { return _renderPass; }
inline VkRenderPass& get() noexcept { return _renderPass; }
inline VkRenderPass& operator()() noexcept { return _renderPass; }
inline VkRenderPass& get() noexcept { return _renderPass; }
private:
VkRenderPass _renderPass = VK_NULL_HANDLE;

View File

@@ -6,7 +6,7 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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
{
class SwapChain
{
friend class GraphicPipeline;
friend class RenderPass;
class SwapChain
{
friend class GraphicPipeline;
friend class RenderPass;
friend class Renderer;
public:
struct SwapChainSupportDetails
{
VkSurfaceCapabilitiesKHR capabilities;
std::vector<VkSurfaceFormatKHR> formats;
public:
struct SwapChainSupportDetails
{
VkSurfaceCapabilitiesKHR capabilities;
std::vector<VkSurfaceFormatKHR> formats;
std::vector<VkPresentModeKHR> presentModes;
};
};
public:
SwapChain() = default;
void init(class Renderer* renderer);
void recreate();
void destroy() noexcept;
void init(class Renderer* renderer);
void recreate();
void destroy() noexcept;
SwapChainSupportDetails querySwapChainSupport(VkPhysicalDevice device);
VkExtent2D chooseSwapExtent(const VkSurfaceCapabilitiesKHR& capabilities);
@@ -54,14 +54,14 @@ namespace mlx
~SwapChain() = default;
private:
private:
SwapChainSupportDetails _swapChainSupport;
VkSwapchainKHR _swapChain;
std::vector<Image> _images;
VkFormat _swapChainImageFormat;
VkExtent2D _extent;
class Renderer* _renderer = nullptr;
};
};
}
#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