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

Fix wgpu image bindgroups and updates to latest webgpu-native #8426

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

pplux
Copy link

@pplux pplux commented Feb 22, 2025

On WebGPU backend, in order to display an image, an ImageBindGroup needs to be created for every new textureView. The backend creates and caches these imagebindgroups but it doesn't consider the fact that textureviews can be created/destroyed on the user side.

The webgpu backend can reuse the pointer for the textureview side, so when the user destroys and creates a new textureview, the cached imagebindgroup will try to use a destroyed resource and probably crash.

In order to fix it, we remove the imagebindgroups created during render on every frame.

This PR also updates the code to the latest webgpu-native, where some changes there were breaking the compilation

This issue is been also referenced in #8046, #7765, and #8027

Use case

I had to deal with this because I'm making an example where I render several off-screen shaders, and then I compose the final result with Imgui. Whenever I resize one of the windows, internally it will create a new texture/texture-view that needs to be displayed. When I tried with the current wgpu backend code, it was failing, and end up crashing because It was reusing invalid bindgroups cached internally, and eventually it will also crash due to the 100 limit size.

image

On WebGPU backend, in order to display an image, an ImageBindGroup needs to be created for every new textureView. The backend creates and caches these imagebindgroups but it doesn't consider the fact that textureviews can be created/destroyed on the user side.

The webgpu backend can reuse the pointer for the textureview side, so when the user destroys and creates a new textureview, the cached imagebindgroup will try to use a destroyed resource and probably crash.

In order to fix it, we remove the imagebindgroups created during render on every frame.

This PR also updates the code to the latest webgpu-native, where some changes there were breaking the compilation
@pplux pplux force-pushed the wgpu/fix-image-bindgroups branch from 2bb7fef to 631f9f5 Compare February 22, 2025 12:23
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.

1 participant