-
Notifications
You must be signed in to change notification settings - Fork 49
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
Updated examples to be compatible with self-hosted #26
Conversation
…ed, change Mat4 to extern struct as arrays in packed structs are no longer supported
My own zig implementation of the sokol instancing example is is actually what triggered this issue: ziglang/zig#12568 If you do a similar workaround to the one I posted there you can probably get the instancing to work on stage2 too. |
For reference, this is what my update loop looks like now on my side (I don't have the data wrapped in a state struct and just use the sokol c code directly, so maybe it won't work here): {
var i: u32 = 0;
// update particle positions
while (i < cur_num_particles) : (i += 1) {
const particle_pos = &pos[i];
const particle_vel = &vel[i];
particle_vel.y -= frame_time;
particle_pos.* = particle_pos.add(particle_vel.scl(frame_time));
// bounce back from 'ground'
if (particle_pos.y < -2.0) {
particle_vel.y = -1.8;
particle_vel.y = -particle_vel.y;
particle_vel.x *= 0.8;
particle_vel.y *= 0.8;
particle_vel.z *= 0.8;
}
}
} |
Ah, thanks! Indeed that workaround works here as well, just added the change. Cheers! |
Ok, I have merged this PR manually into a new sokol-zig branch 0.10.0: https://github.com/floooh/sokol-zig/tree/zig-0.10.0 ...once Zig 0.10.0 is officially released, I'll merge that back into master, and (hopefully), this PR should then automatically resolve too. PS: ...and I have converted this PR to a draft so that I don't accidentally press the merge button ... PPS: many thanks for the PR :) |
...and it's in master now. |
awesome! |
asRange
calling convention from gen_zig.py: add compile time branches for self-hosted support sokol#710Mat4/Vec2/Vec3
toextern struct
as arrays in packed structs are no longer supported, and a guaranteed memory layout is needed for passing these to the GPUAll the examples (except for
instancing.zig
) run for me on self-hosted (Windows, x86_64) in both opengl and directx. I did notice the point size seems different between dx and gl for sgl-points, but this seems true with-fstage1
as well.The
instancing.zig
example crashes on self-hosted with a stack overflow, at the start offrame()
. Debugging this, it seems that it tries to pass ~40M to___chkstk_ms
, which comes fromlib/compiler_rt/stack_probe.zig
. I recall seeing some activity about this so this may just be a self-hosted bug. I only have access to Windows, so it may not affect other platforms. This may also be related to the issue with structs being copied on to the stack (ziglang/zig#12638) but I'm not familiar with how the stack probe is supposed to work, so I can't say without more investigating.