10 Commits

Author SHA1 Message Date
b09f5c39f7 fixes: windows x86 compilation error missing VKAPI_PTR (#197)
This pr fixes windows x86 compilation error (xmake and meson.build).

In runtime/Sources/Renderer/RenderCore.cpp 
```cpp
void* VKAPI_PTR VulkanAllocationFunction(void*, std::size_t size, std::size_t alignment, VkSystemAllocationScope)
	{
		return MemManager::AlignedMalloc(alignment, size);
	}

	void* VKAPI_PTR VulkanReallocationFunction(void*, void* ptr, std::size_t size, std::size_t alignment, VkSystemAllocationScope)
	{
		return MemManager::AlignedRealloc(ptr, alignment, size);
	}

	void VKAPI_PTR VulkanFreeFunction(void*, void* ptr)
	{
		MemManager::Free(ptr);
	}
```
The log of the compilation error:  
- [meson failure
log](https://github.com/0verLighT/MacroLibX/actions/runs/21409805574/job/61643508435)
- [xmake failure
log](https://github.com/0verLighT/MacroLibX/actions/runs/21412208397/job/61651747515)

In the macrolibx VKAPI_PTR was missing, On windows x86, this caused a
compilation error.


This add some features:
- New CICD for windows meson (x64, x86, MYSYS2, clang-cl) and windows
xmake x86
- Fallback for meson.build dependency SDL2 in `subprojects/SDL2.wrap`
2026-01-28 07:17:01 +01:00
0verLighT
91b93a6f10 ci(xmake): add test on x86 architecture due to a Vulkan issue (VKAPI_PTR)
Signed-off-by: 0verLighT <alexandre@0verlight.com>
2026-01-27 21:07:41 +01:00
0verLighT
26c47c3a95 fix && ci (meson): trying to fix Vulkan issue in renderCore.cpp and add some windows test based from meson wrapdb CI
Signed-off-by: 0verLighT <alexandre@0verlight.com>
2026-01-27 20:47:11 +01:00
0verLighT
28142f764f ci(windows_meson): test ci setup meson for windows
chore: add folder subprojects for download sdl2 if it's not present in pkgconfig
Signed-off-by: 0verLighT <alexandre@0verlight.com>
2026-01-27 19:47:30 +01:00
26ccd5eeee Few doc fixes (#194)
Also, the doc says `@param img` but declaration has `mlx_image image`
which is a mismatch, I’m not sure what to do here, so I’m leaving it
untouched.

[This page](https://macrolibx.kbz8.me/guides/text/) of the docs should
be updated too as `mlx_set_font` and `mlx_set_font_scale` don't take a
`mlx_window` anymore.
2026-01-20 19:48:15 +01:00
Luna Mira Lage
849ecbaf1f Few doc fixes 2026-01-20 18:50:29 +01:00
b345fbc672 Indev (#191) 2026-01-11 14:09:00 +01:00
bb019f20a7 Merge branch 'master' into indev 2026-01-11 14:02:39 +01:00
33ae4c3a37 fixing windows compilation issues, bumping version 2026-01-11 14:01:37 +01:00
3e82487037 Indev (#189)
Co-authored-by: 0verLighT <alexandre@0verlight.com>
2026-01-11 00:33:12 +01:00
12 changed files with 157 additions and 20 deletions

View File

@@ -16,7 +16,7 @@ jobs:
fail-fast: false fail-fast: false
matrix: matrix:
os: [windows-latest] os: [windows-latest]
arch: [x64] arch: [x64, x86]
mode: [release] mode: [release]
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}

109
.github/workflows/windows_meson.yml vendored git.filemode.normal_file
View File

@@ -0,0 +1,109 @@
name : Windows (Meson)
on:
repository_dispatch:
types: [create-pull-request]
pull_request:
push:
paths-ignore:
- '.gitignore'
- 'LICENSE'
- 'README.md'
jobs:
VisualStudio:
if: "!contains(github.event.head_commit.message, 'ci skip')"
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
platform: ['x64', 'x86']
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0
# Install a 32-bit Python so building related stuff work.
- name: Setup x86 Python
if: matrix.platform == 'x86'
uses: actions/setup-python@v6
with:
architecture: 'x86'
python-version: '3.12'
- name: Install Meson & Ninja
run: |
python -m pip install meson ninja
- uses: ilammy/msvc-dev-cmd@v1
with:
arch: ${{matrix.platform}}
- name: Compile mlx
run: |
meson setup builddir
meson compile -C builddir
VisualStudio-clang-cl:
if: "!contains(github.event.head_commit.message, 'ci skip')"
runs-on: windows-latest
strategy:
fail-fast: false
env:
CC: clang-cl
CXX: clang-cl
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0
- name: Install Meson & Ninja
run: |
python -m pip install meson ninja
- uses: ilammy/msvc-dev-cmd@v1
- name: Compile mlx
run: |
meson setup builddir
meson compile -C builddir
MSYS2:
if: "!contains(github.event.head_commit.message, 'ci skip')"
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
platform: ['UCRT64', 'CLANG64']
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0
- uses: msys2/setup-msys2@v2
with:
msystem: ${{matrix.platform}}
install: >-
bison
dos2unix
flex
git
pacboy: >-
cc:p
cmake:p
ninja:p
pkgconf:p
python-certifi:p
python-pip:p
# Make sure Python is updated to >=3.11 (fix https://github.com/msys2/MINGW-packages/issues/17415).
update: true
- name: Install Meson
shell: msys2 {0}
run: |
python -m pip install meson
- name: Compile mlx
shell: msys2 {0}
run: |
meson setup builddir
meson compile -C builddir

2
.gitignore vendored
View File

@@ -23,3 +23,5 @@
objs/ objs/
build/ build/
example/Test example/Test
subprojects/*/
subprojects/.wraplock

View File

@@ -338,7 +338,7 @@ MLX_API mlx_image mlx_new_image(mlx_context mlx, int width, int height);
* @param mlx Internal MLX application * @param mlx Internal MLX application
* @param filename Path to the png file * @param filename Path to the png file
* @param width Get the width of the image * @param width Get the width of the image
* @param heigth Get the height of the image * @param height Get the height of the image
* *
* @return (mlx_image) An opaque handler to the internal image or MLX_NULL_HANDLE (0x0) in case of error * @return (mlx_image) An opaque handler to the internal image or MLX_NULL_HANDLE (0x0) in case of error
*/ */
@@ -407,7 +407,6 @@ MLX_API void mlx_string_put(mlx_context mlx, mlx_window win, int x, int y, mlx_c
* @brief Loads a font to be used by `mlx_string_put` * @brief Loads a font to be used by `mlx_string_put`
* *
* @param mlx Internal MLX application * @param mlx Internal MLX application
* @param win Internal window
* @param filepath Filepath to the font or "default" to reset to the embedded font * @param filepath Filepath to the font or "default" to reset to the embedded font
*/ */
MLX_API void mlx_set_font(mlx_context mlx, char* filepath); MLX_API void mlx_set_font(mlx_context mlx, char* filepath);
@@ -416,7 +415,6 @@ MLX_API void mlx_set_font(mlx_context mlx, char* filepath);
* @brief Loads a font to be used by `mlx_string_put` and scales it * @brief Loads a font to be used by `mlx_string_put` and scales it
* *
* @param mlx Internal MLX application * @param mlx Internal MLX application
* @param win Internal window
* @param filepath Filepath to the font or "default" to reset to the embedded font * @param filepath Filepath to the font or "default" to reset to the embedded font
* @param scale Scale to apply to the font * @param scale Scale to apply to the font
*/ */

View File

@@ -206,7 +206,7 @@
typedef void (*mlx_function)(void); typedef void (*mlx_function)(void);
#define MLX_VERSION MLX_MAKE_VERSION(2, 2, 3) #define MLX_VERSION MLX_MAKE_VERSION(2, 2, 4)
#define MLX_TARGET_VULKAN_API_VERSION MLX_MAKE_VERSION(1, 0, 0) #define MLX_TARGET_VULKAN_API_VERSION MLX_MAKE_VERSION(1, 0, 0)
// Checking common assumptions // Checking common assumptions

View File

@@ -1,6 +1,6 @@
project('MacroLibX', project('MacroLibX',
['c', 'cpp'], ['c', 'cpp'],
version : '2.2.3', version : '2.2.4',
license : 'MIT', license : 'MIT',
meson_version : '>= 1.9.0', meson_version : '>= 1.9.0',
default_options : ['warning_level=2', 'optimization=3', 'cpp_std=c++20']) default_options : ['warning_level=2', 'optimization=3', 'cpp_std=c++20'])

View File

@@ -17,8 +17,21 @@
#include <vulkan/vulkan.h> #include <vulkan/vulkan.h>
#if __has_include(<SDL2/SDL.h>)
#include <SDL2/SDL.h> #include <SDL2/SDL.h>
#elif __has_include(<SDL.h>)
#include <SDL.h>
#else
#error Failed to find SDL2 headers
#endif
#if __has_include(<SDL2/SDL_vulkan.h>)
#include <SDL2/SDL_vulkan.h> #include <SDL2/SDL_vulkan.h>
#elif __has_include(<SDL_vulkan.h>)
#include <SDL_vulkan.h>
#else
#error Failed to find SDL2 Vulkan headers
#endif
#include <functional> #include <functional>
#include <memory> #include <memory>

View File

@@ -479,7 +479,7 @@ extern "C"
MLX_CHECK_APPLICATION_POINTER(mlx); MLX_CHECK_APPLICATION_POINTER(mlx);
mlx::NonOwningPtr<mlx::GraphicsSupport> gs = mlx->app->GetGraphicsSupport(win); mlx::NonOwningPtr<mlx::GraphicsSupport> gs = mlx->app->GetGraphicsSupport(win);
if(!gs) if(!gs)
return nullptr; return VK_NULL_HANDLE;
return gs->GetRenderer().GetSwapchain().GetSurface(); return gs->GetRenderer().GetSwapchain().GetSurface();
} }
@@ -488,7 +488,7 @@ extern "C"
MLX_CHECK_APPLICATION_POINTER(mlx); MLX_CHECK_APPLICATION_POINTER(mlx);
mlx::NonOwningPtr<mlx::GraphicsSupport> gs = mlx->app->GetGraphicsSupport(win); mlx::NonOwningPtr<mlx::GraphicsSupport> gs = mlx->app->GetGraphicsSupport(win);
if(!gs || index > gs->GetRenderer().GetSwapchain().GetImagesCount()) if(!gs || index > gs->GetRenderer().GetSwapchain().GetImagesCount())
return nullptr; return VK_NULL_HANDLE;
return gs->GetRenderer().GetSwapchain().GetSwapchainImages()[index].Get(); return gs->GetRenderer().GetSwapchain().GetSwapchainImages()[index].Get();
} }
@@ -506,7 +506,7 @@ extern "C"
MLX_CHECK_APPLICATION_POINTER(mlx); MLX_CHECK_APPLICATION_POINTER(mlx);
mlx::NonOwningPtr<mlx::GraphicsSupport> gs = mlx->app->GetGraphicsSupport(win); mlx::NonOwningPtr<mlx::GraphicsSupport> gs = mlx->app->GetGraphicsSupport(win);
if(!gs || index > gs->GetRenderer().GetSwapchain().GetImagesCount()) if(!gs || index > gs->GetRenderer().GetSwapchain().GetImagesCount())
return nullptr; return VK_NULL_HANDLE;
return gs->GetRenderer().GetSwapchain().GetSwapchainImages()[index].GetImageView(); return gs->GetRenderer().GetSwapchain().GetSwapchainImages()[index].GetImageView();
} }

View File

@@ -21,7 +21,7 @@ namespace mlx
void* MemManager::AlignedMalloc(std::size_t alignment, std::size_t size) void* MemManager::AlignedMalloc(std::size_t alignment, std::size_t size)
{ {
#ifdef MLX_COMPILER_MSVC #ifdef MLX_PLAT_WINDOWS
void* ptr = _aligned_malloc(size, alignment); void* ptr = _aligned_malloc(size, alignment);
#else #else
if(alignment < sizeof(void*)) if(alignment < sizeof(void*))
@@ -66,7 +66,7 @@ namespace mlx
{ {
auto it = std::find_if(s_blocks.begin(), s_blocks.end(), [=](const Descriptor& rhs){ return ptr == rhs.ptr; }); auto it = std::find_if(s_blocks.begin(), s_blocks.end(), [=](const Descriptor& rhs){ return ptr == rhs.ptr; });
#ifdef MLX_COMPILER_MSVC #ifdef MLX_PLAT_WINDOWS
void* ptr2 = _aligned_realloc(ptr, size, alignment); void* ptr2 = _aligned_realloc(ptr, size, alignment);
if(it != s_blocks.end()) if(it != s_blocks.end())
s_blocks.erase(it); s_blocks.erase(it);
@@ -90,7 +90,7 @@ namespace mlx
auto it = std::find_if(s_blocks.begin(), s_blocks.end(), [=](const Descriptor& rhs){ return ptr == rhs.ptr; }); auto it = std::find_if(s_blocks.begin(), s_blocks.end(), [=](const Descriptor& rhs){ return ptr == rhs.ptr; });
if(it == s_blocks.end()) if(it == s_blocks.end())
return; return;
#ifdef MLX_COMPILER_MSVC #ifdef MLX_PLAT_WINDOWS
if(it->aligned) if(it->aligned)
_aligned_free(it->ptr); _aligned_free(it->ptr);
else else
@@ -105,7 +105,7 @@ namespace mlx
{ {
for(const Descriptor& desc : s_blocks) for(const Descriptor& desc : s_blocks)
{ {
#ifdef MLX_COMPILER_MSVC #ifdef MLX_PLAT_WINDOWS
if(desc.aligned) if(desc.aligned)
_aligned_free(desc.ptr); _aligned_free(desc.ptr);
else else

View File

@@ -55,17 +55,17 @@ namespace mlx
std::cout << std::endl; std::cout << std::endl;
} }
void* VulkanAllocationFunction(void*, std::size_t size, std::size_t alignment, VkSystemAllocationScope) void* VKAPI_PTR VulkanAllocationFunction(void*, std::size_t size, std::size_t alignment, VkSystemAllocationScope)
{ {
return MemManager::AlignedMalloc(alignment, size); return MemManager::AlignedMalloc(alignment, size);
} }
void* VulkanReallocationFunction(void*, void* ptr, std::size_t size, std::size_t alignment, VkSystemAllocationScope) void* VKAPI_PTR VulkanReallocationFunction(void*, void* ptr, std::size_t size, std::size_t alignment, VkSystemAllocationScope)
{ {
return MemManager::AlignedRealloc(ptr, alignment, size); return MemManager::AlignedRealloc(ptr, alignment, size);
} }
void VulkanFreeFunction(void*, void* ptr) void VKAPI_PTR VulkanFreeFunction(void*, void* ptr)
{ {
MemManager::Free(ptr); MemManager::Free(ptr);
} }

15
subprojects/sdl2.wrap git.filemode.normal_file
View File

@@ -0,0 +1,15 @@
[wrap-file]
directory = SDL2-2.32.8
source_url = https://github.com/libsdl-org/SDL/releases/download/release-2.32.8/SDL2-2.32.8.tar.gz
source_filename = SDL2-2.32.8.tar.gz
source_hash = 0ca83e9c9b31e18288c7ec811108e58bac1f1bb5ec6577ad386830eac51c787e
patch_filename = sdl2_2.32.8-1_patch.zip
patch_url = https://wrapdb.mesonbuild.com/v2/sdl2_2.32.8-1/get_patch
patch_hash = 5df17ea39ca418826db20e96bd821fa52b5718dac64b6225119fb6588c2744f0
source_fallback_url = https://github.com/mesonbuild/wrapdb/releases/download/sdl2_2.32.8-1/SDL2-2.32.8.tar.gz
wrapdb_version = 2.32.8-1
[provide]
sdl2 = sdl2_dep
sdl2main = sdl2main_dep
sdl2_test = sdl2_test_dep

4
third_party/kvf.h vendored
View File

@@ -526,7 +526,7 @@ int32_t kvfFindMemoryType(VkPhysicalDevice physical_device, uint32_t type_filter
VkPhysicalDeviceMemoryProperties mem_properties; VkPhysicalDeviceMemoryProperties mem_properties;
KVF_GET_INSTANCE_FUNCTION(vkGetPhysicalDeviceMemoryProperties)(physical_device, &mem_properties); KVF_GET_INSTANCE_FUNCTION(vkGetPhysicalDeviceMemoryProperties)(physical_device, &mem_properties);
for(int32_t i = 0; i < mem_properties.memoryTypeCount; i++) for(int32_t i = 0; i < (int32_t)mem_properties.memoryTypeCount; i++)
{ {
if((type_filter & (1 << i)) && (mem_properties.memoryTypes[i].propertyFlags & properties) == properties) if((type_filter & (1 << i)) && (mem_properties.memoryTypes[i].propertyFlags & properties) == properties)
return i; return i;
@@ -1166,7 +1166,7 @@ const char* kvfVerbaliseVkResult(VkResult result)
case VK_ERROR_OUT_OF_DATE_KHR: return "A surface has changed in such a way that it is no longer compatible with the swapchain"; case VK_ERROR_OUT_OF_DATE_KHR: return "A surface has changed in such a way that it is no longer compatible with the swapchain";
case VK_ERROR_INCOMPATIBLE_DISPLAY_KHR: return "The display used by a swapchain does not use the same presentable image layout"; case VK_ERROR_INCOMPATIBLE_DISPLAY_KHR: return "The display used by a swapchain does not use the same presentable image layout";
case VK_ERROR_NATIVE_WINDOW_IN_USE_KHR: return "The requested window is already connected to a VkSurfaceKHR, or to some other non-Vulkan API"; case VK_ERROR_NATIVE_WINDOW_IN_USE_KHR: return "The requested window is already connected to a VkSurfaceKHR, or to some other non-Vulkan API";
case VK_ERROR_VALIDATION_FAILED: return "A command failed because invalid usage was detected by the implementation or a validation layer."; case VK_ERROR_VALIDATION_FAILED_EXT: return "A command failed because invalid usage was detected by the implementation or a validation layer.";
default: return "Unknown Vulkan error"; default: return "Unknown Vulkan error";
} }