glfw: undo setSizeLimits workaround once self-hosted compiler bug is fixed #581

Closed
opened 2022-10-14 16:55:31 +00:00 by mitchellh · 4 comments
mitchellh commented 2022-10-14 16:55:31 +00:00 (Migrated from github.com)

This is possibly a stage2 bug but I wanted to report here to get another set of eyes. If it is a stage2 bug, would appreciate if you could get an issue up!

try window.setSizeLimits(.{
        .width = @floatToInt(u32, grid.cell_size.width * 10),
        .height = @floatToInt(u32, grid.cell_size.height * 4),
}, .{ .width = null, .height = null });

On stage1 (-fstage1) compiles fine. With stage2:

vendor/mach/libs/glfw/src/Window.zig:706:50: error: unable to unwrap null
        std.debug.assert(min.width.? <= max.width.?);

I see that Window is already protecting against null so this seems... weird.

This is possibly a stage2 bug but I wanted to report here to get another set of eyes. If it is a stage2 bug, would appreciate if you could get an issue up! ```zig try window.setSizeLimits(.{ .width = @floatToInt(u32, grid.cell_size.width * 10), .height = @floatToInt(u32, grid.cell_size.height * 4), }, .{ .width = null, .height = null }); ``` On stage1 (`-fstage1`) compiles fine. With stage2: ``` vendor/mach/libs/glfw/src/Window.zig:706:50: error: unable to unwrap null std.debug.assert(min.width.? <= max.width.?); ``` I see that Window is already protecting against null so this seems... weird.
emidoots commented 2022-10-15 01:12:54 +00:00 (Migrated from github.com)

I can't reproduce this.

diff --git a/examples/triangle-msaa/main.zig b/examples/triangle-msaa/main.zig
index de728b41..c6377fdc 100644
--- a/examples/triangle-msaa/main.zig
+++ b/examples/triangle-msaa/main.zig
@@ -13,6 +13,8 @@ window_title_timer: mach.Timer,
 const sample_count = 4;
 
 pub fn init(app: *App, core: *mach.Core) !void {
+    try core.internal.window.setSizeLimits(.{.width = 400, .height = 400}, .{ .width = null, .height = null });
+
     const vs_module = core.device.createShaderModuleWGSL("vert.wgsl", @embedFile("vert.wgsl"));
     const fs_module = core.device.createShaderModuleWGSL("frag.wgsl", @embedFile("frag.wgsl"));
 

What Zig version are you using? Are you using stage3?

I can't reproduce this. ``` diff --git a/examples/triangle-msaa/main.zig b/examples/triangle-msaa/main.zig index de728b41..c6377fdc 100644 --- a/examples/triangle-msaa/main.zig +++ b/examples/triangle-msaa/main.zig @@ -13,6 +13,8 @@ window_title_timer: mach.Timer, const sample_count = 4; pub fn init(app: *App, core: *mach.Core) !void { + try core.internal.window.setSizeLimits(.{.width = 400, .height = 400}, .{ .width = null, .height = null }); + const vs_module = core.device.createShaderModuleWGSL("vert.wgsl", @embedFile("vert.wgsl")); const fs_module = core.device.createShaderModuleWGSL("frag.wgsl", @embedFile("frag.wgsl")); ``` What Zig version are you using? Are you using stage3?
mitchellh commented 2022-10-15 01:25:29 +00:00 (Migrated from github.com)

Zig version 0.10.0-dev.4333+f5f28e0d2. Works with stage1, not stage2 (and zig binary is stage3 yes, an official nightly).

So, it very specifically only reproduces with that floatToInt call, if I change that to a comptime-known number it doesn't work. Try this:

var bleh: u32 = 42;
try window.setSizeLimits(.{
        .width = bleh,
        .height = bleh,
}, .{ .width = null, .height = null });

I'm trying to get a tighter reproduction now to report a Zig issue, this is clearly that.

Zig version `0.10.0-dev.4333+f5f28e0d2`. Works with stage1, not stage2 (and `zig` binary is stage3 yes, an official nightly). So, it very specifically only reproduces with that floatToInt call, if I change that to a comptime-known number it doesn't work. Try this: ```zig var bleh: u32 = 42; try window.setSizeLimits(.{ .width = bleh, .height = bleh, }, .{ .width = null, .height = null }); ``` I'm trying to get a tighter reproduction now to report a Zig issue, this is clearly that.
mitchellh commented 2022-10-15 01:33:35 +00:00 (Migrated from github.com)

I got it: https://github.com/ziglang/zig/issues/13164

A workaround for now if you want is to remove the inline if you want to do that until that issue is resolved.

I got it: https://github.com/ziglang/zig/issues/13164 A workaround for now if you want is to remove the `inline` if you want to do that until that issue is resolved.
emidoots commented 2022-10-15 07:59:09 +00:00 (Migrated from github.com)

Thanks for tracking that down! I added that workaround for now, will leave this issue open for tracking.

Thanks for tracking that down! I added that workaround for now, will leave this issue open for tracking.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
hexops/mach#581
No description provided.