Skip to content

Commit

Permalink
[progress #146] fix run step for default mode done
Browse files Browse the repository at this point in the history
  • Loading branch information
tiawl committed Apr 8, 2024
1 parent fdcde59 commit ccc8a21
Show file tree
Hide file tree
Showing 3 changed files with 186 additions and 123 deletions.
50 changes: 34 additions & 16 deletions src/binding/imgui/vk.zig
Original file line number Diff line number Diff line change
Expand Up @@ -36,21 +36,20 @@ pub const Frame = struct

pub const InitInfo = struct
{
Instance: vk.Instance,
PhysicalDevice: vk.PhysicalDevice,
Device: vk.Device,
QueueFamily: u32,
Queue: vk.Queue,
PipelineCache: vk.Pipeline.Cache,
DescriptorPool: vk.Descriptor.Pool,
Subpass: u32,
MinImageCount: u32,
ImageCount: u32,
MSAASamples: c_uint,
UseDynamicRendering: bool,
ColorAttachmentFormat: i32,
Allocator: [*c] const vk.AllocationCallbacks,
CheckVkResultFn: ?*const fn (c_int) callconv (c.call_conv) void,
instance: vk.Instance,
physical_device: vk.PhysicalDevice,
device: vk.Device,
queue_family: u32,
queue: vk.Queue,
pipeline_cache: vk.Pipeline.Cache,
descriptor_pool: vk.Descriptor.Pool,
render_pass: vk.RenderPass,
subpass: u32,
min_image_count: u32,
image_count: u32,
msaa_samples: c_uint,
use_dynamic_rendering: bool,
check_vk_result_fn: ?*const fn (c_int) callconv (c.call_conv) void,
};

fn loader (function_name: [*c] const u8, instance: ?*anyopaque)
Expand All @@ -67,7 +66,26 @@ pub fn load () !void

pub fn init (init_info: *imgui.vk.InitInfo) !void
{
if (!c.cImGui_ImplVulkan_Init (@ptrCast (init_info)))
var c_init_info = c.ImGui_ImplVulkan_InitInfo
{
.Instance = @ptrFromInt (@intFromEnum (init_info.instance)),
.PhysicalDevice = @ptrFromInt (@intFromEnum (init_info.physical_device)),
.Device = @ptrFromInt (@intFromEnum (init_info.device)),
.QueueFamily = init_info.queue_family,
.Queue = @ptrFromInt (@intFromEnum (init_info.queue)),
.DescriptorPool = @ptrFromInt (@intFromEnum (init_info.descriptor_pool)),
.RenderPass = @ptrFromInt (@intFromEnum (init_info.render_pass)),
.MinImageCount = init_info.min_image_count,
.ImageCount = init_info.image_count,
.MSAASamples = init_info.msaa_samples,
.PipelineCache = @ptrFromInt (@intFromEnum (init_info.pipeline_cache)),
.Subpass = init_info.subpass,
.UseDynamicRendering = init_info.use_dynamic_rendering,
.Allocator = null,
.CheckVkResultFn = init_info.check_vk_result_fn,
};

if (!c.cImGui_ImplVulkan_Init (&c_init_info))
return error.ImGuiVulkanInitFailure;
}

Expand Down
29 changes: 14 additions & 15 deletions src/imgui/context.zig
Original file line number Diff line number Diff line change
Expand Up @@ -111,21 +111,20 @@ pub const Context = struct
{
var init_info = imgui.vk.InitInfo
{
.Instance = renderer.instance,
.PhysicalDevice = renderer.physical_device,
.Device = renderer.logical_device,
.QueueFamily = renderer.graphics_family,
.Queue = renderer.graphics_queue,
.PipelineCache = .NULL_HANDLE,
.DescriptorPool = renderer.descriptor_pool,
.Subpass = 0,
.MinImageCount = 2,
.ImageCount = 2,
.MSAASamples = @intFromEnum (vk.Sample.Count.Bit.@"1"),
.UseDynamicRendering = false,
.ColorAttachmentFormat = @intFromEnum (vk.Format.UNDEFINED),
.Allocator = null,
.CheckVkResultFn = check_vk_result,
.instance = renderer.instance,
.physical_device = renderer.physical_device,
.device = renderer.logical_device,
.queue_family = renderer.graphics_family,
.queue = renderer.graphics_queue,
.pipeline_cache = .NULL_HANDLE,
.descriptor_pool = renderer.descriptor_pool,
.render_pass = renderer.render_pass,
.subpass = 0,
.min_image_count = 2,
.image_count = 2,
.msaa_samples = @intFromEnum (vk.Sample.Count.Bit.@"1"),
.use_dynamic_rendering = false,
.check_vk_result_fn = check_vk_result,
};

try imgui.vk.load ();
Expand Down
Loading

0 comments on commit ccc8a21

Please sign in to comment.