Skip to content

Commit

Permalink
fix release builds
Browse files Browse the repository at this point in the history
  • Loading branch information
Avokadoen committed Dec 20, 2022
1 parent e943d17 commit 75e2721
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/RenderContext.zig
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const sync = @import("sync.zig");
const dmem = @import("device_memory.zig");
const application_ext_layers = @import("application_ext_layers.zig");

const is_debug_build = builtin.mode == .Debug;
pub const is_debug_build = builtin.mode == .Debug;
const max_frames_in_flight = 2;

const RenderContext = @This();
Expand Down Expand Up @@ -192,7 +192,7 @@ pub fn init(allocator: Allocator, window: glfw.Window) !RenderContext {
errdefer asset_handler.deinit(allocator);

// bind the glfw instance proc pointer
const vk_proc = @ptrCast(*const fn (instance: vk.Instance, procname: [*:0]const u8) ?glfw.VKProc, &glfw.getInstanceProcAddress);
const vk_proc = @ptrCast(*const fn (instance: vk.Instance, procname: [*:0]const u8) callconv(.C) vk.PfnVoidFunction, &glfw.getInstanceProcAddress);
const vkb = try BaseDispatch.load(vk_proc);

// get validation layers if we are in debug mode
Expand Down
12 changes: 8 additions & 4 deletions src/main.zig
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,17 @@ const VelocityComp = struct {
};

pub fn main() !void {
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
// create a gpa with default configuration
var alloc = if (RenderContext.is_debug_build) std.heap.GeneralPurposeAllocator(.{}){} else std.heap.c_allocator;
defer {
if (gpa.deinit()) {
std.log.err("leak detected", .{});
if (RenderContext.is_debug_build) {
const leak = alloc.deinit();
if (leak) {
std.debug.print("leak detected in gpa!", .{});
}
}
}
const allocator = gpa.allocator();
const allocator = if (RenderContext.is_debug_build) alloc.allocator() else alloc;

// var world = try ecez.WorldBuilder().WithComponents(.{ PositionComp, VelocityComp }).init(allocator, .{});
// defer world.deinit();
Expand Down

0 comments on commit 75e2721

Please sign in to comment.