gfx-rs / wgpu

A cross-platform, safe, pure-Rust graphics API.
https://wgpu.rs
Apache License 2.0
12.52k stars 916 forks source link

Early Resource Deletion in Poll Tests #3160

Closed cwfitzgerald closed 3 months ago

cwfitzgerald commented 1 year ago

Poll tests (https://github.com/gfx-rs/wgpu/blob/master/wgpu/tests/poll.rs) are currently completely disabled due to bugs in resource tracking. I believe the problem stems from the resources being completely dropped by the time the device is maintained.

teoxoy commented 1 year ago

I ran the poll tests locally and this is what I'm seeing:


In #3174 the CI seems to have the same issues (segfaults in linux/vulkan and errors with OBJECT_DELETED_WHILE_STILL_IN_USE on windows/dx12). So, finding and fixing the underlying bug might also fix that test case.

jimblandy commented 10 months ago

It would be nice to see if this still occurs after arcanization.

cwfitzgerald commented 10 months ago

I tested it and it does.

teoxoy commented 3 months ago

https://github.com/gfx-rs/wgpu/pull/3873 seems to have removed all the .skip(FailureCase::always()) from the poll tests.

I tried running the poll tests on the parent commit and they failed.

I can't tell why they are passing with https://github.com/gfx-rs/wgpu/pull/3873, I don't see any changes in wgpu-core.

@cwfitzgerald do you know why they are working now?

teoxoy commented 3 months ago

Ah, I see what happened, https://github.com/gfx-rs/wgpu/pull/3873 added a DummyWorkData struct that contains the CommandBuffer resources so that they are not dropped before the CommandBuffer.

teoxoy commented 3 months ago

I bisected this being fixed by https://github.com/gfx-rs/wgpu/commit/aade481bdf7f8f9ae18423bf9f0dc1279844f37e (https://github.com/gfx-rs/wgpu/pull/4894). More specifically by this being removed:

//Releasing safely unused resources to decrement refcount
bind_group.used_buffer_ranges.write().clear();
bind_group.used_texture_ranges.write().clear();
bind_group.dynamic_binding_info.write().clear();