merge Indev to master (#28)

This commit is contained in:
kbz_8
2024-01-03 15:38:38 +01:00
committed by GitHub
51 changed files with 259 additions and 129 deletions

25
.github/workflows/greetings.yml vendored git.filemode.normal_file
View File

@@ -0,0 +1,25 @@
name: Greetings
on: [pull_request_target, issues]
jobs:
greeting:
runs-on: ubuntu-latest
permissions:
issues: write
pull-requests: write
steps:
- uses: actions/first-interaction@v1
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
issue-message: |
Hello! Thank you for filing an issue.
If this is a bug report, please include relevant logs to help us debug the problem (OS, MLX version, drivers installed, GPU type and vendor, ...)
pr-message: |
Hello! Thank you for your contribution.
If you are fixing a bug, please reference the issue number in the description.
If you are implementing a feature request, please explain all your changes in your pull request.

View File

@@ -37,6 +37,6 @@ jobs:
- name: Build MacroLibX
run: make -j && make fclean && make -j DEBUG=true
# Build the test
- name: Build Test
run: cd test && bash ./build.sh
# Build the example
- name: Build Example
run: cd example && bash ./build.sh

View File

@@ -37,7 +37,7 @@ jobs:
- name: Build MacroLibX
run: make TOOLCHAIN=gcc -j && make fclean && make TOOLCHAIN=gcc DEBUG=true -j
# Build the test
- name: Build Test
run: cd test && bash ./build.sh
# Build the example
- name: Build Example
run: cd example && bash ./build.sh

View File

@@ -43,7 +43,7 @@ jobs:
- name: Build MacroLibX
run: make -j && make fclean && make DEBUG=true -j
# Build the test
- name: Build Test
run: cd test && bash ./build.sh
# Build the example
- name: Build Example
run: cd example && bash ./build.sh

View File

@@ -58,6 +58,6 @@ jobs:
- name: Build MacroLibX
run: xmake --yes
# Build the test
- name: Build Test
# Build the example
- name: Build Example
run: xmake build --yes Test

View File

@@ -1,5 +1,5 @@
MIT License
Copyright (c) 2022-2023 kbz_8
Copyright (c) 2022-2024 kbz_8
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

View File

Before

Width:  |  Height:  |  Size: 6.2 KiB

After

Width:  |  Height:  |  Size: 6.2 KiB

BIN
example/Test git.filemode.executable_file

Binary file not shown.

View File

@@ -6,7 +6,7 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/04 17:55:21 by maldavid #+# #+# */
/* Updated: 2023/12/31 01:13:40 by maldavid ### ########.fr */
/* Updated: 2024/01/03 12:29:31 by maldavid ### ########.fr */
/* */
/* ************************************************************************** */

View File

@@ -6,7 +6,7 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/10 08:49:17 by maldavid #+# #+# */
/* Updated: 2023/12/16 20:20:35 by maldavid ### ########.fr */
/* Updated: 2024/01/03 15:33:35 by maldavid ### ########.fr */
/* */
/* ************************************************************************** */
@@ -93,6 +93,51 @@
#define MLX_FUNC_SIG "Unknown function"
#endif
#ifndef __cplusplus // if we compile in C
#ifdef __STDC__
#ifdef __STDC_VERSION__
#if __STDC_VERSION__ == 199409L
#define MLX_C_VERSION 1994
#elif __STDC_VERSION__ == 199901L
#define MLX_C_VERSION 1999
#elif __STDC_VERSION__ == 201112L
#define MLX_C_VERSION 2011
#elif __STDC_VERSION__ == 201710L
#define MLX_C_VERSION 2017
#elif __STDC_VERSION__ == 202311L
#define MLX_C_VERSION 2023
#else
#define MLX_C_VERSION 0
#endif
#else
#define MLX_C_VERSION 0
#endif
#else
#define MLX_C_VERSION 0
#endif
#else
#define MLX_C_VERSION 0
#endif
#if defined(MLX_PLAT_WINDOWS)
#define VK_USE_PLATFORM_WIN32_KHR
#ifdef __cplusplus
constexpr const char* VULKAN_LIB_NAME = "vulkan-1.dll";
#endif
#elif defined(MLX_PLAT_MACOS)
#define VK_USE_PLATFORM_MACOS_MVK
#define VK_USE_PLATFORM_METAL_EXT
#ifdef __cplusplus
constexpr const char* VULKAN_LIB_NAME = "libvulkan.dylib / libvulkan.1.dylib / libMoltenVK.dylib";
#endif
#else
#define VK_USE_PLATFORM_XLIB_KHR
#define VK_USE_PLATFORM_WAYLAND_KHR
#ifdef __cplusplus
constexpr const char* VULKAN_LIB_NAME = "libvulkan.so / libvulkan.so.1";
#endif
#endif
// Checking common assumptions
#ifdef __cplusplus
#include <climits>
@@ -109,8 +154,48 @@
static_assert(sizeof(uint16_t) == 2, "uint16_t is not of the correct size");
static_assert(sizeof(uint32_t) == 4, "uint32_t is not of the correct size");
static_assert(sizeof(uint64_t) == 8, "uint64_t is not of the correct size");
#elif MLX_C_VERSION >= 2011
#if MLX_C_VERSION < 2023
#include <assert.h>
#endif
#include <limits.h>
#include <stdint.h>
static_assert(CHAR_BIT == 8, "CHAR_BIT is expected to be 8");
static_assert(sizeof(int8_t) == 1, "int8_t is not of the correct size" );
static_assert(sizeof(int16_t) == 2, "int16_t is not of the correct size");
static_assert(sizeof(int32_t) == 4, "int32_t is not of the correct size");
static_assert(sizeof(int64_t) == 8, "int64_t is not of the correct size");
static_assert(sizeof(uint8_t) == 1, "uint8_t is not of the correct size" );
static_assert(sizeof(uint16_t) == 2, "uint16_t is not of the correct size");
static_assert(sizeof(uint32_t) == 4, "uint32_t is not of the correct size");
static_assert(sizeof(uint64_t) == 8, "uint64_t is not of the correct size");
#elif defined(MLX_COMPILER_GCC)
#define STATIC_ASSERT(cnd, descr) \
({ \
extern int __attribute__((error("static assert failed: (" #cnd ") (" #descr ")"))) compile_time_check(void); \
((cnd) ? 0 : compile_time_check()), 0; \
})
#include <limits.h>
#include <stdint.h>
STATIC_ASSERT(CHAR_BIT == 8, "CHAR_BIT is expected to be 8");
STATIC_ASSERT(sizeof(int8_t) == 1, "int8_t is not of the correct size" );
STATIC_ASSERT(sizeof(int16_t) == 2, "int16_t is not of the correct size");
STATIC_ASSERT(sizeof(int32_t) == 4, "int32_t is not of the correct size");
STATIC_ASSERT(sizeof(int64_t) == 8, "int64_t is not of the correct size");
STATIC_ASSERT(sizeof(uint8_t) == 1, "uint8_t is not of the correct size" );
STATIC_ASSERT(sizeof(uint16_t) == 2, "uint16_t is not of the correct size");
STATIC_ASSERT(sizeof(uint32_t) == 4, "uint32_t is not of the correct size");
STATIC_ASSERT(sizeof(uint64_t) == 8, "uint64_t is not of the correct size");
#else
#define STATIC_ASSERT(COND, MSG) typedef char static_assertion___##MSG[(COND)?1:-1]
#include <limits.h>
#include <stdint.h>

View File

@@ -3,13 +3,23 @@
# Update volk
rm -f ../third_party/volk.c
rm -f ../third_party/volk.h
wget https://api.github.com/repos/zeux/volk/zipball/1.3.270 -O volk.zip
tag_name=$(curl -sL https://api.github.com/repos/zeux/Volk/releases/latest | jq -r '.tag_name')
wget https://api.github.com/repos/zeux/volk/zipball/$tag_name -O volk.zip
unzip -o volk.zip -d ../third_party/
mv ../third_party/zeux-volk*/volk.h ../third_party
mv ../third_party/zeux-volk*/volk.c ../third_party
rm -rf ../third_party/zeux-volk*
rm volk.zip
# Update VMA
rm -f ../third_party/vma.h
tag_name=$(curl -sL https://api.github.com/repos/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator/releases/latest | jq -r '.tag_name')
wget https://api.github.com/repos/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator/zipball/$tag_name -O vma.zip
unzip -o vma.zip -d ../third_party/
mv ../third_party/GPUOpen-LibrariesAndSDKs-VulkanMemoryAllocator*/include/vk_mem_alloc.h ../third_party/vma.h
rm -rf ../third_party/GPUOpen-LibrariesAndSDKs-VulkanMemoryAllocator*
rm vma.zip
# Update Vulkan headers
rm -rf ../third_party/vulkan
rm -rf ../third_party/vk_video

View File

@@ -6,16 +6,16 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/06 23:18:52 by maldavid #+# #+# */
/* Updated: 2023/12/12 21:12:44 by kbz_8 ### ########.fr */
/* Updated: 2024/01/03 15:26:56 by maldavid ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef __MLX_VK_BUFFER__
#define __MLX_VK_BUFFER__
#include <mlx_profile.h>
#include <volk.h>
#include <renderer/core/render_core.h>
#include <mlx_profile.h>
namespace mlx
{

View File

@@ -6,17 +6,17 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/01/25 15:05:05 by maldavid #+# #+# */
/* Updated: 2023/12/11 19:47:47 by kbz_8 ### ########.fr */
/* Updated: 2024/01/03 15:27:02 by maldavid ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef __VK_IBO__
#define __VK_IBO__
#include <mlx_profile.h>
#include <volk.h>
#include "vk_buffer.h"
#include <renderer/renderer.h>
#include <mlx_profile.h>
namespace mlx
{

View File

@@ -6,7 +6,7 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/04/02 17:48:52 by maldavid #+# #+# */
/* Updated: 2023/12/08 19:07:00 by kbz_8 ### ########.fr */
/* Updated: 2024/01/03 15:27:35 by maldavid ### ########.fr */
/* */
/* ************************************************************************** */
@@ -15,8 +15,8 @@
#include <array>
#include <volk.h>
#include <mlx_profile.h>
#include <volk.h>
#include <renderer/core/render_core.h>
#include <renderer/command/vk_cmd_pool.h>
#include <renderer/command/vk_cmd_buffer.h>

View File

@@ -6,7 +6,7 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/06 18:26:06 by maldavid #+# #+# */
/* Updated: 2023/12/24 12:58:36 by kbz_8 ### ########.fr */
/* Updated: 2024/01/03 13:12:58 by maldavid ### ########.fr */
/* */
/* ************************************************************************** */
@@ -32,8 +32,9 @@ namespace mlx
allocInfo.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY;
allocInfo.commandBufferCount = 1;
if(vkAllocateCommandBuffers(Render_Core::get().getDevice().get(), &allocInfo, &_cmd_buffer) != VK_SUCCESS)
core::error::report(e_kind::fatal_error, "Vulkan : failed to allocate command buffer");
VkResult res = vkAllocateCommandBuffers(Render_Core::get().getDevice().get(), &allocInfo, &_cmd_buffer);
if(res != VK_SUCCESS)
core::error::report(e_kind::fatal_error, "Vulkan : failed to allocate command buffer, %s", RCore::verbaliseResultVk(res));
#ifdef DEBUG
core::error::report(e_kind::message, "Vulkan : created new command buffer");
#endif
@@ -85,8 +86,9 @@ namespace mlx
VkFence fence;
vkCreateFence(device, &fenceCreateInfo, nullptr, &fence);
vkResetFences(device, 1, &fence);
if(vkQueueSubmit(Render_Core::get().getQueue().getGraphic(), 1, &submitInfo, fence) != VK_SUCCESS)
core::error::report(e_kind::fatal_error, "Vulkan error : failed to submit a single time command buffer");
VkResult res = vkQueueSubmit(Render_Core::get().getQueue().getGraphic(), 1, &submitInfo, fence);
if(res != VK_SUCCESS)
core::error::report(e_kind::fatal_error, "Vulkan error : failed to submit a single time command buffer, %s", RCore::verbaliseResultVk(res));
_state = state::submitted;
vkWaitForFences(device, 1, &fence, VK_TRUE, UINT64_MAX);
vkDestroyFence(device, fence, nullptr);
@@ -120,8 +122,9 @@ namespace mlx
submitInfo.signalSemaphoreCount = (semaphores == nullptr ? 0 : signalSemaphores.size());
submitInfo.pSignalSemaphores = signalSemaphores.data();
if(vkQueueSubmit(Render_Core::get().getQueue().getGraphic(), 1, &submitInfo, _fence.get()) != VK_SUCCESS)
core::error::report(e_kind::fatal_error, "Vulkan error : failed to submit draw command buffer");
VkResult res = vkQueueSubmit(Render_Core::get().getQueue().getGraphic(), 1, &submitInfo, _fence.get());
if(res != VK_SUCCESS)
core::error::report(e_kind::fatal_error, "Vulkan error : failed to submit draw command buffer, %s", RCore::verbaliseResultVk(res));
_state = state::submitted;
}

View File

@@ -6,16 +6,16 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/06 18:25:42 by maldavid #+# #+# */
/* Updated: 2023/12/23 01:24:34 by kbz_8 ### ########.fr */
/* Updated: 2024/01/03 15:27:20 by maldavid ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef __MLX_VK_CMD_BUFFER__
#define __MLX_VK_CMD_BUFFER__
#include <mlx_profile.h>
#include <volk.h>
#include <renderer/core/vk_fence.h>
#include <mlx_profile.h>
namespace mlx
{

View File

@@ -6,7 +6,7 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/06 18:24:33 by maldavid #+# #+# */
/* Updated: 2023/11/18 17:23:38 by maldavid ### ########.fr */
/* Updated: 2024/01/03 13:13:25 by maldavid ### ########.fr */
/* */
/* ************************************************************************** */
@@ -22,8 +22,9 @@ namespace mlx
poolInfo.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT;
poolInfo.queueFamilyIndex = Render_Core::get().getQueue().getFamilies().graphicsFamily.value();
if(vkCreateCommandPool(Render_Core::get().getDevice().get(), &poolInfo, nullptr, &_cmd_pool) != VK_SUCCESS)
core::error::report(e_kind::fatal_error, "Vulkan : failed to create command pool");
VkResult res = vkCreateCommandPool(Render_Core::get().getDevice().get(), &poolInfo, nullptr, &_cmd_pool);
if(res != VK_SUCCESS)
core::error::report(e_kind::fatal_error, "Vulkan : failed to create command pool, %s", RCore::verbaliseResultVk(res));
}
void CmdPool::destroy() noexcept

View File

@@ -6,15 +6,15 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/06 18:24:12 by maldavid #+# #+# */
/* Updated: 2023/12/08 19:07:22 by kbz_8 ### ########.fr */
/* Updated: 2024/01/03 15:27:26 by maldavid ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef __MLX_VK_CMD_POOL__
#define __MLX_VK_CMD_POOL__
#include <volk.h>
#include <mlx_profile.h>
#include <volk.h>
namespace mlx
{

View File

@@ -6,7 +6,7 @@
/* By: kbz_8 <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/10/20 22:02:37 by kbz_8 #+# #+# */
/* Updated: 2023/12/27 21:31:04 by maldavid ### ########.fr */
/* Updated: 2024/01/03 13:09:40 by maldavid ### ########.fr */
/* */
/* ************************************************************************** */
@@ -76,18 +76,20 @@ namespace mlx
allocatorCreateInfo.instance = Render_Core::get().getInstance().get();
allocatorCreateInfo.pVulkanFunctions = &vma_vulkan_func;
if(vmaCreateAllocator(&allocatorCreateInfo, &_allocator) != VK_SUCCESS)
core::error::report(e_kind::fatal_error, "Vulkan : failed to create graphics memory allocator");
VkResult res = vmaCreateAllocator(&allocatorCreateInfo, &_allocator);
if(res != VK_SUCCESS)
core::error::report(e_kind::fatal_error, "Graphics allocator : failed to create graphics memory allocator, %s", RCore::verbaliseResultVk(res));
#ifdef DEBUG
core::error::report(e_kind::message, "Vulkan : created new allocator");
core::error::report(e_kind::message, "Graphics allocator : created new allocator");
#endif
}
VmaAllocation GPUallocator::createBuffer(const VkBufferCreateInfo* binfo, const VmaAllocationCreateInfo* vinfo, VkBuffer& buffer, const char* name) noexcept
{
VmaAllocation allocation;
if(vmaCreateBuffer(_allocator, binfo, vinfo, &buffer, &allocation, nullptr) != VK_SUCCESS)
core::error::report(e_kind::fatal_error, "Vulkan : failed to allocate a buffer");
VkResult res = vmaCreateBuffer(_allocator, binfo, vinfo, &buffer, &allocation, nullptr);
if(res != VK_SUCCESS)
core::error::report(e_kind::fatal_error, "Graphics allocator : failed to allocate a buffer, %s", RCore::verbaliseResultVk(res));
if(name != nullptr)
vmaSetAllocationName(_allocator, allocation, name);
#ifdef DEBUG
@@ -110,8 +112,9 @@ namespace mlx
VmaAllocation GPUallocator::createImage(const VkImageCreateInfo* iminfo, const VmaAllocationCreateInfo* vinfo, VkImage& image, const char* name) noexcept
{
VmaAllocation allocation;
if(vmaCreateImage(_allocator, iminfo, vinfo, &image, &allocation, nullptr) != VK_SUCCESS)
core::error::report(e_kind::fatal_error, "Vulkan : failed to allocate an image");
VkResult res = vmaCreateImage(_allocator, iminfo, vinfo, &image, &allocation, nullptr);
if(res != VK_SUCCESS)
core::error::report(e_kind::fatal_error, "Graphics allocator : failed to allocate an image, %s", RCore::verbaliseResultVk(res));
if(name != nullptr)
vmaSetAllocationName(_allocator, allocation, name);
#ifdef DEBUG
@@ -133,8 +136,9 @@ namespace mlx
void GPUallocator::mapMemory(VmaAllocation allocation, void** data) noexcept
{
if(vmaMapMemory(_allocator, allocation, data) != VK_SUCCESS)
core::error::report(e_kind::fatal_error, "Graphics allocator : unable to map GPU memory to CPU memory");
VkResult res = vmaMapMemory(_allocator, allocation, data);
if(res != VK_SUCCESS)
core::error::report(e_kind::fatal_error, "Graphics allocator : unable to map GPU memory to CPU memory, %s", RCore::verbaliseResultVk(res));
}
void GPUallocator::unmapMemory(VmaAllocation allocation) noexcept

View File

@@ -6,16 +6,16 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/10/20 02:13:03 by maldavid #+# #+# */
/* Updated: 2023/12/16 18:53:51 by maldavid ### ########.fr */
/* Updated: 2024/01/03 15:25:56 by maldavid ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef __MLX_VK_MEMORY__
#define __MLX_VK_MEMORY__
#include <mlx_profile.h>
#include <volk.h>
#include <vma.h>
#include <mlx_profile.h>
namespace mlx
{

View File

@@ -6,30 +6,21 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/12/17 23:33:34 by maldavid #+# #+# */
/* Updated: 2023/12/15 20:32:01 by maldavid ### ########.fr */
/* Updated: 2024/01/03 15:22:38 by maldavid ### ########.fr */
/* */
/* ************************************************************************** */
#define VOLK_IMPLEMENTATION
#if defined(_WIN32) || defined(_WIN64)
#define VK_USE_PLATFORM_WIN32_KHR
#elif defined(__APPLE__) || defined(__MACH__)
#define VK_USE_PLATFORM_MACOS_MVK
#define VK_USE_PLATFORM_METAL_EXT
#else
#define VK_USE_PLATFORM_XLIB_KHR
#define VK_USE_PLATFORM_WAYLAND_KHR
#endif
#include "render_core.h"
#include <mlx_profile.h>
#include <renderer/core/render_core.h>
#include <mutex>
#ifdef DEBUG
#ifndef MLX_COMPILER_MSVC
#warning "MLX is being compiled in debug mode, this activates Vulkan's validation layers and debug messages which may impact rendering performances"
#else
#ifdef MLX_COMPILER_MSVC
#pragma NOTE("MLX is being compiled in debug mode, this activates Vulkan's validation layers and debug messages which may impact rendering performances")
#else
#warning "MLX is being compiled in debug mode, this activates Vulkan's validation layers and debug messages which may impact rendering performances"
#endif
#endif
@@ -88,7 +79,8 @@ namespace mlx
void Render_Core::init()
{
volkInitialize();
if(volkInitialize() != VK_SUCCESS)
core::error::report(e_kind::fatal_error, "Vulkan loader : cannot load %s, are you sure Vulkan is installed on your system ?", VULKAN_LIB_NAME);
_instance.init();
volkLoadInstance(_instance.get());

View File

@@ -6,13 +6,14 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/08 19:16:32 by maldavid #+# #+# */
/* Updated: 2023/12/31 00:42:42 by maldavid ### ########.fr */
/* Updated: 2024/01/03 15:26:08 by maldavid ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef __MLX_RENDER_CORE__
#define __MLX_RENDER_CORE__
#include <mlx_profile.h>
#include <volk.h>
#include <optional>
@@ -25,7 +26,6 @@
#include <utils/singleton.h>
#include <core/errors.h>
#include <mlx_profile.h>
namespace mlx
{

View File

@@ -6,16 +6,16 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/08 19:13:42 by maldavid #+# #+# */
/* Updated: 2023/12/08 19:07:49 by kbz_8 ### ########.fr */
/* Updated: 2024/01/03 15:26:14 by maldavid ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef __MLX_VK_DEVICE__
#define __MLX_VK_DEVICE__
#include <mlx_profile.h>
#include <volk.h>
#include "vk_queues.h"
#include <mlx_profile.h>
namespace mlx
{

View File

@@ -6,15 +6,15 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/04/02 17:52:09 by maldavid #+# #+# */
/* Updated: 2023/12/16 17:27:28 by maldavid ### ########.fr */
/* Updated: 2024/01/03 15:26:21 by maldavid ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef __MLX_VK_FENCE__
#define __MLX_VK_FENCE__
#include <volk.h>
#include <mlx_profile.h>
#include <volk.h>
namespace mlx
{

View File

@@ -6,16 +6,16 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/08 19:03:04 by maldavid #+# #+# */
/* Updated: 2023/12/08 19:08:14 by kbz_8 ### ########.fr */
/* Updated: 2024/01/03 15:26:26 by maldavid ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef __MLX_VK_INSTANCE__
#define __MLX_VK_INSTANCE__
#include <mlx_profile.h>
#include <volk.h>
#include <vector>
#include <mlx_profile.h>
namespace mlx
{

View File

@@ -6,17 +6,17 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/08 19:01:49 by maldavid #+# #+# */
/* Updated: 2023/12/08 19:08:25 by kbz_8 ### ########.fr */
/* Updated: 2024/01/03 15:26:31 by maldavid ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef __MLX_VK_QUEUES__
#define __MLX_VK_QUEUES__
#include <mlx_profile.h>
#include <volk.h>
#include <optional>
#include <cstdint>
#include <mlx_profile.h>
namespace mlx
{

View File

@@ -6,16 +6,16 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/08 18:59:38 by maldavid #+# #+# */
/* Updated: 2023/12/08 19:08:36 by kbz_8 ### ########.fr */
/* Updated: 2024/01/03 15:26:39 by maldavid ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef __MLX_VK_SEMAPHORE__
#define __MLX_VK_SEMAPHORE__
#include <mlx_profile.h>
#include <volk.h>
#include <vector>
#include <mlx_profile.h>
namespace mlx
{

View File

@@ -6,16 +6,16 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/08 18:57:55 by maldavid #+# #+# */
/* Updated: 2023/12/08 19:08:49 by kbz_8 ### ########.fr */
/* Updated: 2024/01/03 15:26:43 by maldavid ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef __MLX_VK_SURFACE__
#define __MLX_VK_SURFACE__
#include <mlx_profile.h>
#include <volk.h>
#include <vector>
#include <mlx_profile.h>
namespace mlx
{

View File

@@ -6,7 +6,7 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/12/19 14:05:25 by maldavid #+# #+# */
/* Updated: 2023/12/31 00:41:39 by maldavid ### ########.fr */
/* Updated: 2024/01/03 13:11:27 by maldavid ### ########.fr */
/* */
/* ************************************************************************** */
@@ -27,8 +27,9 @@ namespace mlx
VkDebugUtilsMessengerCreateInfoEXT createInfo{};
populateDebugMessengerCreateInfo(createInfo);
if(createDebugUtilsMessengerEXT(&createInfo, nullptr) != VK_SUCCESS)
core::error::report(e_kind::warning, "Vulkan : failed to set up debug messenger");
VkResult res = createDebugUtilsMessengerEXT(&createInfo, nullptr);
if(res != VK_SUCCESS)
core::error::report(e_kind::warning, "Vulkan : failed to set up debug messenger, %s", RCore::verbaliseResultVk(res));
#ifdef DEBUG
else
core::error::report(e_kind::message, "Vulkan : enabled validation layers");

View File

@@ -6,15 +6,15 @@
/* By: maldavid <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/12/19 14:04:25 by maldavid #+# #+# */
/* Updated: 2023/12/31 00:38:25 by maldavid ### ########.fr */
/* Updated: 2024/01/03 15:26:49 by maldavid ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef __VK_VALIDATION_LAYERS__
#define __VK_VALIDATION_LAYERS__
#include <volk.h>
#include <mlx_profile.h>
#include <volk.h>
namespace mlx
{

View File

@@ -6,7 +6,7 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/01/23 18:34:23 by maldavid #+# #+# */
/* Updated: 2023/11/18 17:23:05 by maldavid ### ########.fr */
/* Updated: 2024/01/03 13:13:54 by maldavid ### ########.fr */
/* */
/* ************************************************************************** */
@@ -23,8 +23,9 @@ namespace mlx
poolInfo.pPoolSizes = size;
poolInfo.maxSets = 8192;
if(vkCreateDescriptorPool(Render_Core::get().getDevice().get(), &poolInfo, nullptr, &_pool) != VK_SUCCESS)
core::error::report(e_kind::fatal_error, "Vulkan : failed to create descriptor pool");
VkResult res = vkCreateDescriptorPool(Render_Core::get().getDevice().get(), &poolInfo, nullptr, &_pool);
if(res != VK_SUCCESS)
core::error::report(e_kind::fatal_error, "Vulkan : failed to create descriptor pool, %s", RCore::verbaliseResultVk(res));
}
void DescriptorPool::destroy() noexcept

View File

@@ -6,16 +6,16 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/01/23 18:32:43 by maldavid #+# #+# */
/* Updated: 2023/12/08 19:09:20 by kbz_8 ### ########.fr */
/* Updated: 2024/01/03 15:27:45 by maldavid ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef __VK_DESCRIPTOR_POOL__
#define __VK_DESCRIPTOR_POOL__
#include <mlx_profile.h>
#include <volk.h>
#include <cstddef>
#include <mlx_profile.h>
namespace mlx
{

View File

@@ -6,11 +6,12 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/01/23 18:40:44 by maldavid #+# #+# */
/* Updated: 2023/12/24 09:37:55 by kbz_8 ### ########.fr */
/* Updated: 2024/01/03 13:14:24 by maldavid ### ########.fr */
/* */
/* ************************************************************************** */
#include "vk_descriptor_set.h"
#include "renderer/core/render_core.h"
#include "vk_descriptor_pool.h"
#include "vk_descriptor_set_layout.h"
#include <renderer/buffers/vk_ubo.h>
@@ -36,8 +37,9 @@ namespace mlx
allocInfo.descriptorSetCount = static_cast<uint32_t>(MAX_FRAMES_IN_FLIGHT);
allocInfo.pSetLayouts = layouts.data();
if(vkAllocateDescriptorSets(device, &allocInfo, _desc_set.data()) != VK_SUCCESS)
core::error::report(e_kind::fatal_error, "Vulkan : failed to allocate descriptor set");
VkResult res = vkAllocateDescriptorSets(device, &allocInfo, _desc_set.data());
if(res != VK_SUCCESS)
core::error::report(e_kind::fatal_error, "Vulkan : failed to allocate descriptor set, %s", RCore::verbaliseResultVk(res));
#ifdef DEBUG
core::error::report(e_kind::message, "Vulkan : created new descriptor set");
#endif

View File

@@ -6,16 +6,16 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/01/23 18:39:36 by maldavid #+# #+# */
/* Updated: 2023/12/23 18:47:49 by kbz_8 ### ########.fr */
/* Updated: 2024/01/03 15:27:50 by maldavid ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef __VK_DESCRIPTOR_SET__
#define __VK_DESCRIPTOR_SET__
#include <mlx_profile.h>
#include <volk.h>
#include <array>
#include <mlx_profile.h>
#include <renderer/core/render_core.h>
namespace mlx

View File

@@ -6,7 +6,7 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/01/23 18:37:28 by maldavid #+# #+# */
/* Updated: 2023/12/10 22:25:59 by kbz_8 ### ########.fr */
/* Updated: 2024/01/03 13:14:58 by maldavid ### ########.fr */
/* */
/* ************************************************************************** */
@@ -34,8 +34,9 @@ namespace mlx
layoutInfo.bindingCount = _bindings.size();
layoutInfo.pBindings = bindings.data();
if(vkCreateDescriptorSetLayout(Render_Core::get().getDevice().get(), &layoutInfo, nullptr, &_layout) != VK_SUCCESS)
core::error::report(e_kind::fatal_error, "Vulkan : failed to create descriptor set layout");
VkResult res = vkCreateDescriptorSetLayout(Render_Core::get().getDevice().get(), &layoutInfo, nullptr, &_layout);
if(res != VK_SUCCESS)
core::error::report(e_kind::fatal_error, "Vulkan : failed to create descriptor set layout, %s", RCore::verbaliseResultVk(res));
}
void DescriptorSetLayout::destroy() noexcept

View File

@@ -6,18 +6,18 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/01/23 18:36:22 by maldavid #+# #+# */
/* Updated: 2023/12/08 19:09:44 by kbz_8 ### ########.fr */
/* Updated: 2024/01/03 15:27:55 by maldavid ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef __VK_DESCRIPTOR_SET_LAYOUT__
#define __VK_DESCRIPTOR_SET_LAYOUT__
#include <mlx_profile.h>
#include <volk.h>
#include <cstddef>
#include <vector>
#include <map>
#include <mlx_profile.h>
namespace mlx
{

View File

@@ -6,7 +6,7 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/01/25 11:59:07 by maldavid #+# #+# */
/* Updated: 2023/12/22 23:35:07 by kbz_8 ### ########.fr */
/* Updated: 2024/01/03 13:16:21 by maldavid ### ########.fr */
/* */
/* ************************************************************************** */
@@ -182,8 +182,9 @@ namespace mlx
viewInfo.subresourceRange.baseArrayLayer = 0;
viewInfo.subresourceRange.layerCount = 1;
if(vkCreateImageView(Render_Core::get().getDevice().get(), &viewInfo, nullptr, &_image_view) != VK_SUCCESS)
core::error::report(e_kind::fatal_error, "Vulkan : failed to create an image view");
VkResult res = vkCreateImageView(Render_Core::get().getDevice().get(), &viewInfo, nullptr, &_image_view);
if(res != VK_SUCCESS)
core::error::report(e_kind::fatal_error, "Vulkan : failed to create an image view, %s", RCore::verbaliseResultVk(res));
}
void Image::createSampler() noexcept
@@ -201,8 +202,9 @@ namespace mlx
info.anisotropyEnable = VK_FALSE;
info.maxAnisotropy = 1.0f;
if(vkCreateSampler(Render_Core::get().getDevice().get(), &info, nullptr, &_sampler) != VK_SUCCESS)
core::error::report(e_kind::fatal_error, "Vulkan : failed to create an image");
VkResult res = vkCreateSampler(Render_Core::get().getDevice().get(), &info, nullptr, &_sampler);
if(res != VK_SUCCESS)
core::error::report(e_kind::fatal_error, "Vulkan : failed to create an image, %s", RCore::verbaliseResultVk(res));
}
void Image::copyFromBuffer(Buffer& buffer)

View File

@@ -6,20 +6,20 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/01/25 11:54:21 by maldavid #+# #+# */
/* Updated: 2023/12/22 23:31:02 by kbz_8 ### ########.fr */
/* Updated: 2024/01/03 15:28:07 by maldavid ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef __MLX_VK_IMAGE__
#define __MLX_VK_IMAGE__
#include <mlx_profile.h>
#include <volk.h>
#include <cstddef>
#include <vector>
#include <vma.h>
#include <renderer/command/vk_cmd_buffer.h>
#include <renderer/command/vk_cmd_pool.h>
#include <mlx_profile.h>
namespace mlx
{

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/12/22 22:00:37 by kbz_8 ### ########.fr */
/* Updated: 2024/01/03 13:16:57 by maldavid ### ########.fr */
/* */
/* ************************************************************************** */
@@ -305,8 +305,9 @@ namespace mlx
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");
VkResult res = vkCreateGraphicsPipelines(Render_Core::get().getDevice().get(), VK_NULL_HANDLE, 1, &pipelineInfo, nullptr, &_graphicsPipeline);
if(res != VK_SUCCESS)
core::error::report(e_kind::fatal_error, "Vulkan : failed to create a graphics pipeline, %s", RCore::verbaliseResultVk(res));
#ifdef DEBUG
core::error::report(e_kind::message, "Vulkan : created new graphic pipeline");
#endif

View File

@@ -6,15 +6,15 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/12/18 21:23:52 by maldavid #+# #+# */
/* Updated: 2023/12/08 19:10:51 by kbz_8 ### ########.fr */
/* Updated: 2024/01/03 15:28:13 by maldavid ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef __PIPELINE__
#define __PIPELINE__
#include <volk.h>
#include <mlx_profile.h>
#include <volk.h>
#include <renderer/command/vk_cmd_buffer.h>
namespace mlx

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/20 07:24:26 by maldavid ### ########.fr */
/* Updated: 2024/01/03 13:17:27 by maldavid ### ########.fr */
/* */
/* ************************************************************************** */
@@ -33,8 +33,9 @@ namespace mlx
framebufferInfo.height = _height;
framebufferInfo.layers = 1;
if(vkCreateFramebuffer(Render_Core::get().getDevice().get(), &framebufferInfo, nullptr, &_framebuffer) != VK_SUCCESS)
core::error::report(e_kind::fatal_error, "Vulkan : failed to create a framebuffer");
VkResult res = vkCreateFramebuffer(Render_Core::get().getDevice().get(), &framebufferInfo, nullptr, &_framebuffer);
if(res != VK_SUCCESS)
core::error::report(e_kind::fatal_error, "Vulkan : failed to create a framebuffer, %s", RCore::verbaliseResultVk(res));
#ifdef DEBUG
core::error::report(e_kind::message, "Vulkan : created new framebuffer");
#endif

View File

@@ -6,15 +6,15 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/06 18:19:44 by maldavid #+# #+# */
/* Updated: 2023/12/08 19:11:04 by kbz_8 ### ########.fr */
/* Updated: 2024/01/03 15:28:19 by maldavid ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef __MLX_VK_FRAMEBUFFER__
#define __MLX_VK_FRAMEBUFFER__
#include <volk.h>
#include <mlx_profile.h>
#include <volk.h>
namespace mlx
{

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/12/24 15:31:02 by kbz_8 ### ########.fr */
/* Updated: 2024/01/03 13:17:56 by maldavid ### ########.fr */
/* */
/* ************************************************************************** */
@@ -70,8 +70,9 @@ namespace mlx
renderPassInfo.dependencyCount = static_cast<uint32_t>(subpassesDeps.size());
renderPassInfo.pDependencies = subpassesDeps.data();
if(vkCreateRenderPass(Render_Core::get().getDevice().get(), &renderPassInfo, nullptr, &_renderPass) != VK_SUCCESS)
core::error::report(e_kind::fatal_error, "Vulkan : failed to create render pass");
VkResult res = vkCreateRenderPass(Render_Core::get().getDevice().get(), &renderPassInfo, nullptr, &_renderPass);
if(res != VK_SUCCESS)
core::error::report(e_kind::fatal_error, "Vulkan : failed to create render pass, %s", RCore::verbaliseResultVk(res));
#ifdef DEBUG
core::error::report(e_kind::message, "Vulkan : created new render pass");
#endif

View File

@@ -6,15 +6,15 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/06 18:22:00 by maldavid #+# #+# */
/* Updated: 2023/12/24 13:01:56 by kbz_8 ### ########.fr */
/* Updated: 2024/01/03 15:28:25 by maldavid ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef __MLX_VK_RENDER_PASS__
#define __MLX_VK_RENDER_PASS__
#include <volk.h>
#include <mlx_profile.h>
#include <volk.h>
namespace mlx
{

View File

@@ -6,7 +6,7 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/06 18:22:28 by maldavid #+# #+# */
/* Updated: 2023/12/15 21:49:19 by maldavid ### ########.fr */
/* Updated: 2024/01/03 13:18:25 by maldavid ### ########.fr */
/* */
/* ************************************************************************** */
@@ -59,8 +59,9 @@ namespace mlx
else
createInfo.imageSharingMode = VK_SHARING_MODE_EXCLUSIVE;
if(vkCreateSwapchainKHR(device, &createInfo, nullptr, &_swapChain) != VK_SUCCESS)
core::error::report(e_kind::fatal_error, "Vulkan : failed to create the swapchain");
VkResult res = vkCreateSwapchainKHR(device, &createInfo, nullptr, &_swapChain);
if(res != VK_SUCCESS)
core::error::report(e_kind::fatal_error, "Vulkan : failed to create the swapchain, %s", RCore::verbaliseResultVk(res));
std::vector<VkImage> tmp;
vkGetSwapchainImagesKHR(device, _swapChain, &imageCount, nullptr);

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/12/08 19:11:30 by kbz_8 ### ########.fr */
/* Updated: 2024/01/03 15:28:39 by maldavid ### ########.fr */
/* */
/* ************************************************************************** */
@@ -14,8 +14,8 @@
#define __MLX_VK_SWAPCHAIN__
#include <vector>
#include <volk.h>
#include <mlx_profile.h>
#include <volk.h>
#include <renderer/images/vk_image.h>
namespace mlx

View File

@@ -1,4 +1,4 @@
{
name
Memcheck:Leak
fun:*alloc

View File

@@ -6,13 +6,12 @@
-- By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ --
-- +#+#+#+#+#+ +#+ --
-- Created: 2023/12/07 15:21:38 by kbz_8 #+# #+# --
-- Updated: 2023/12/07 15:21:38 by kbz_8 ### ########.fr --
-- Updated: 2024/01/02 23:40:20 by kbz_8 ### ########.fr --
-- --
--------------------------------------------------------------------------------
-- Global settings
add_requires("vulkan-headers")
add_requires("libsdl", {configs = { sdlmain = false }})
add_rules("mode.debug", "mode.release")
@@ -55,7 +54,7 @@ target("mlx")
add_files("src/**.cpp")
add_packages("libsdl", "vulkan-headers")
add_packages("libsdl")
if is_mode("debug") then
add_defines("DEBUG")
@@ -71,7 +70,7 @@ target("Test")
add_deps("mlx")
add_files("test/main.c")
add_files("example/main.c")
add_defines("SDL_MAIN_HANDLED")