Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing core to work with win32 #1257 #1258

Merged
merged 1 commit into from
Aug 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/core/custom-entrypoint/main.zig
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pub fn main() !void {
// possible on all platforms.
if (mach.Core.supports_non_blocking) {
mach.Core.non_blocking = true;
while (mach.mods.mod.mach_core.state != .exited) {
while (mach.mods.mod.mach_core.state().state != .exited) {
// Execute systems until a frame has been finished.
try mach.mods.dispatchUntil(stack_space, .mach_core, .frame_finished);
}
Expand Down
8 changes: 6 additions & 2 deletions src/Core.zig
Original file line number Diff line number Diff line change
Expand Up @@ -331,8 +331,8 @@ pub fn start(core: *Mod) !void {
const stack_space = try core.state().allocator.alloc(u8, 8 * 1024 * 1024);

if (supports_non_blocking) {
while (mach.mods.mod.mach_core.state != .exited) {
try mach.mods.dispatchUntil(stack_space, .mach_core, .frame_finished);
while (core.state().state != .exited) {
dispatch(stack_space);
}
// Don't return, because Platform.run wouldn't either (marked noreturn due to underlying
// platform APIs never returning.)
Expand All @@ -348,6 +348,10 @@ pub fn start(core: *Mod) !void {
}
}

fn dispatch(stack_space: []u8) void {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the reason this intermediate function call is needed? Or, what error do you get without this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the error I get is

src\module\module.zig:325:27: error: unable to resolve inferred error set
            try m.dispatch(stack_space, .{

without digging much deeper my assumption was might be occurring because it was being called from a "system" which is analyzed when creating the .Mod.

I saw platform_update_callback did not have this issue. That is why I created a function dispatch that would catch the error and not propagate the error thus breaking the loop when the compiler is determining the error set.

mach.mods.dispatchUntil(stack_space, .mach_core, .frame_finished) catch { @panic("Dispatch in Core failed"); };
}

fn platform_update_callback(core: *Mod, stack_space: []u8) !bool {
// Execute systems until .mach_core.frame_finished is dispatched, signalling a frame was
// finished.
Expand Down
1 change: 1 addition & 0 deletions src/core/win32.zig
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ pub fn init(
self.border = options.border;
self.headless = options.headless;
self.refresh_rate = 60; // TODO (win32) get monitor refresh rate
self.vsync_mode = .triple;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Filed #1259


_ = w.SetWindowLongPtrW(window, w.GWLP_USERDATA, @bitCast(@intFromPtr(self)));
if (!options.headless) {
Expand Down
Loading