Skip to content

Conversation

carrot-sticks
Copy link

I did the initial fixes, change .C to .c and use old writer. I will take a look to see how new IO works and try to make it work.

Should fix #36

@carrot-sticks
Copy link
Author

I upgraded bmp.zig to Writergate syntax.
You can't use

    var buffer: [1024]u8 = undefined;
    var writer = file.writer(&buffer).interface;

as it won't work. Instead, you need to have two variables, like this:

    var buffer: [1024]u8 = undefined;
    var fw = file.writer(&buffer);
    const writer = &fw.interface;

This is some RAII level hidden flow, which made me spent an hour debugging.

I moved from ** to @splat() as there was some talk about removing it in future versions.

I also moved from bitwise operators to std.mem.alignForward because I found it prettier 🤷

Hopefully, this won't cause many breaking changes in your API changes PR.

@ibotha
Copy link

ibotha commented Sep 20, 2025

I mentioned some problems I was having with zig 0.15.1 on issue #36

I am just testing on Ubuntu, no idea what the effect is on other OSs yet.

Here is the stacktrace I get from the triangle example with a debug build of wgpu-native. Will keep investigating.

zig build run-triangle-example
General protection exception (no address available)
/home/isard/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/../../stdarch/crates/core_arch/src/x86/sse2.rs:1472:0: 0x194c0e4 in _mm_movemask_epi8 (/home/isard/.cargo/git/checkouts/wgpu-045f9a3b3e40a5c0/f35cf94/wgpu-hal/src/lib.rs/@/wgpu_hal.97386ecd7dfc2f89-cgu.05)
pub fn _mm_movemask_epi8(a: __m128i) -> i32 {

/home/isard/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/hashbrown-0.15.5/src/control/group/sse2.rs:87:21: 0x1975bf8 in match_tag (/home/isard/.cargo/git/checkouts/wgpu-045f9a3b3e40a5c0/f35cf94/wgpu-hal/src/lib.rs/@/wgpu_hal.97386ecd7dfc2f89-cgu.06)
            BitMask(x86::_mm_movemask_epi8(cmp) as u16)
                    ^
/home/isard/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/hashbrown-0.15.5/src/raw/mod.rs:1916:30: 0x196d4f9 in find<(usize, usize), allocator_api2::stable::alloc::global::Global, hashbrown::map::equivalent_key::{closure_env#0}<usize, usize, usize>> (/home/isard/.cargo/git/checkouts/wgpu-045f9a3b3e40a5c0/f35cf94/wgpu-hal/src/lib.rs/@/wgpu_hal.97386ecd7dfc2f89-cgu.05)
            for bit in group.match_tag(tag_hash) {
                             ^
/home/isard/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/hashbrown-0.15.5/src/map.rs:1231:40: 0x19d4a0a in entry<usize, usize, foldhash::fast::RandomState, allocator_api2::stable::alloc::global::Global> (/home/isard/.cargo/git/checkouts/wgpu-045f9a3b3e40a5c0/f35cf94/wgpu-hal/src/lib.rs/@/wgpu_hal.97386ecd7dfc2f89-cgu.08)
        if let Some(elem) = self.table.find(hash, equivalent_key(&key)) {
                                       ^
src/gles/egl.rs:491:12: 0x1a39524 in initialize_display (/home/isard/.cargo/git/checkouts/wgpu-045f9a3b3e40a5c0/f35cf94/wgpu-hal/src/lib.rs/@/wgpu_hal.97386ecd7dfc2f89-cgu.13)
src/gles/egl.rs:527:23: 0x1a3985f in create (/home/isard/.cargo/git/checkouts/wgpu-045f9a3b3e40a5c0/f35cf94/wgpu-hal/src/lib.rs/@/wgpu_hal.97386ecd7dfc2f89-cgu.13)
src/gles/egl.rs:941:21: 0x1a3f33d in init (/home/isard/.cargo/git/checkouts/wgpu-045f9a3b3e40a5c0/f35cf94/wgpu-hal/src/lib.rs/@/wgpu_hal.97386ecd7dfc2f89-cgu.13)
src/instance.rs:130:24: 0x1630a68 in try_add_hal<wgpu_hal::gles::Api> (/home/isard/.cargo/git/checkouts/wgpu-045f9a3b3e40a5c0/f35cf94/wgpu-core/src/lib.rs/@/wgpu_core.93467800306a9d8e-cgu.02)
src/instance.rs:105:14: 0x162ff33 in new (/home/isard/.cargo/git/checkouts/wgpu-045f9a3b3e40a5c0/f35cf94/wgpu-core/src/lib.rs/@/wgpu_core.93467800306a9d8e-cgu.02)
src/global.rs:38:23: 0x1805e66 in new (/home/isard/.cargo/git/checkouts/wgpu-045f9a3b3e40a5c0/f35cf94/wgpu-core/src/lib.rs/@/wgpu_core.93467800306a9d8e-cgu.13)
src/lib.rs:661:27: 0x150105b in wgpuCreateInstance (src/lib.rs/@/25gymqctwjaxag14m5mw209g1)
/home/isard/Documents/Code/wgpu_native_zig/src/instance.zig:218:34: 0x14d1d58 in main (triangle.zig)
        return wgpuCreateInstance(descriptor);
                                 ^
/home/isard/.local/zig/zig15/lib/std/start.zig:627:37: 0x14d4021 in main (std.zig)
            const result = root.main() catch |err| {
                                    ^
../sysdeps/nptl/libc_start_call_main.h:58:16: 0x7fdfd002a1c9 in __libc_start_call_main (../sysdeps/x86/libc-start.c)
../csu/libc-start.c:360:3: 0x7fdfd002a28a in __libc_start_main_impl (../sysdeps/x86/libc-start.c)
???:?:?: 0x14fc5c4 in ??? (???)
???:?:?: 0x0 in ??? (???)
run-triangle-example
└─ run exe triangle-example failure
error: the following command terminated unexpectedly:
./.zig-cache/o/e22c799f81b054331aed9a11267488d8/triangle-example

Build Summary: 1/3 steps succeeded; 1 failed
run-triangle-example transitive failure
└─ run exe triangle-example failure

@carrot-sticks
Copy link
Author

Can you try this with --release=fast ?

@ibotha
Copy link

ibotha commented Sep 20, 2025

release=fast does fix it...now that is very interesting

@ibotha
Copy link

ibotha commented Sep 20, 2025

So debug builds break compatibility

@carrot-sticks
Copy link
Author

So it works with LLVM, but breaks in zig compiler. You should open the issue in ziglang/zig

@ibotha
Copy link

ibotha commented Sep 20, 2025

It seems like even with --release=fast its not 100% reliable. There is still some error when querying the adapter limits

I can't be sure that its the same issue since its a release build but it seems to break at the same point as the dynamic linking version.

@felipeasimos
Copy link

I submitted a bug report about it since the issue @ibotha commented was closed.

@carrot-sticks
Copy link
Author

And you were late just a few days for 0.15.2 😢

@felipeasimos
Copy link

Unfortunately I wasn't up to date with the release cycle :/ Good news is that the issue was already picked up and there is a PR. We are close to being LLVM-free, but for now you can use -Duse_llvm=true in #41 so it doesn't block you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0.15.1

3 participants