$ jj diff --git diff --git a/build.zig b/build.zig index 3d0c38ec64..c57cda7abd 100644 --- a/build.zig +++ b/build.zig @@ -23,6 +23,13 @@ .optimize = optimize, }); + const dep_vma = b.dependency("vulkan_vma", .{}); + const vma_translate = b.addTranslateC(.{ + .root_source_file = dep_vma.path("include/vk_mem_alloc.h"), + .target = target, + .optimize = optimize, + }); + const zglfw_mod = dep_zglfw.module("root"); zglfw_mod.addImport("vulkan", dep_vk_kickstart.module("vulkan")); @@ -39,9 +46,16 @@ .{ .name = "vulkan", .module = dep_vk_kickstart.module("vulkan") }, .{ .name = "zglfw", .module = zglfw_mod }, .{ .name = "vk_kickstart", .module = dep_vk_kickstart.module("vk-kickstart") }, + .{ .name = "vma", .module = vma_translate.createModule() }, }, + .link_libcpp = true, }), }); + exe.root_module.addIncludePath(dep_vma.path("include")); + exe.root_module.addCSourceFile(.{ + .file = b.path("src/vma_impl.cpp"), + .flags = &.{"--std=c++17"}, + }); if (target.result.os.tag != .emscripten) { exe.root_module.linkLibrary(dep_zglfw.artifact("glfw")); diff --git a/build.zig.zon b/build.zig.zon index b2b7b32a08..fc360232ea 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -4,10 +4,6 @@ .fingerprint = 0x82952f5c6d322a7c, // Changing this has security and trust implications. .minimum_zig_version = "0.17.0-dev.284+cd23f7a81", .dependencies = .{ - .sokol = .{ - .url = "git+https://github.com/floooh/sokol-zig.git#6ca71321c91e842fb32a8140802a546e50d8a086", - .hash = "sokol-0.1.0-pb1HK9lgNwAAB5SLJlpJQ09PZ2CVydxkNs0KaptLaTUD", - }, .zmath = .{ .url = "git+https://github.com/zig-gamedev/zmath.git#9e42b04a24c970a297b365f3d3022f92dbf3219d", .hash = "zmath-0.11.0-dev-wjwivTwtAwDOjG2_KGP-HLtHrONfsFfHttalmxFAGVAK", @@ -20,14 +16,14 @@ .url = "https://github.com/KhronosGroup/Vulkan-Headers/archive/refs/tags/v1.4.350.tar.gz", .hash = "N-V-__8AAPnEbQK6L3hGtJefy0xZjeg7KOxIEj8_obZC2_lF", }, - // .vulkan = .{ - // .url = "git+https://github.com/Snektron/vulkan-zig#be16fc99f7f794cba90334978c6c5aadeda8094f", - // .hash = "vulkan-0.0.0-r7Ytx-V9AwCwHxS2TaZ-KJCp_3axidu3ASZUg3B512-k", - // }, .vk_kickstart = .{ .url = "git+https://github.com/mikastiv/vk-kickstart.git#64663eb42181aa4783584a4690ddff98cbfc2e81", .hash = "vk_kickstart-0.1.0-YDdE9ChKAQDOe_GDNH3-1WKNy7TtSeksA0OTCTv419Cy", }, + .vulkan_vma = .{ + .url = "git+https://github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator.git#a1d434708c217b2a6c7b365f1fe41fa03a562e59", + .hash = "N-V-__8AAAVPPwDox3fRB8szj8h2nd82xYnHf0oX_NSYDemV", + }, }, .paths = .{ "build.zig", diff --git a/src/VulkanRenderer/VulkanContext.zig b/src/VulkanRenderer/VulkanContext.zig index 3219b3df7f..954966ece2 100644 --- a/src/VulkanRenderer/VulkanContext.zig +++ b/src/VulkanRenderer/VulkanContext.zig @@ -3,6 +3,7 @@ const vk = @import("vulkan"); const vkk = @import("vk_kickstart"); +const vma = @import("vma"); const glfw = @import("zglfw"); pub const VulkanContext = struct { diff --git a/src/vma_impl.cpp b/src/vma_impl.cpp new file mode 100644 index 0000000000..a2023d33b2 --- /dev/null +++ b/src/vma_impl.cpp @@ -0,0 +1,2 @@ +#define VMA_IMPLEMENTATION +#include "vk_mem_alloc.h"