gfx-rs / wgpu

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

On d3d12 it is too easy to hit the 2k sampler descriptor limit #4700

Closed nical closed 10 months ago

nical commented 12 months ago

Description

With the d3d12 backend there can be only a limited number of sampler descriptors alive for per device. See the 2k constant here, especially in the browser where the GC can hold texture views alive for arbitrarily long (and texture views don't have a destroy method).

We should eagerly destroy texture views when their textures are destroyed or dropped to free up descriptors faster.

Platform

d3d12 backend on windows

nical commented 12 months ago

Bugzilla entry: https://bugzilla.mozilla.org/show_bug.cgi?id=1863872

nical commented 12 months ago

Actually there is already an issue on file for the 2k sampler limit: https://github.com/gfx-rs/wgpu/issues/3350

I'll repurpose this one for the intermediate fix of eagerly destroying texture views.

cwfitzgerald commented 12 months ago

How would eagerly destroying texture views help with sampler bindings?

nical commented 12 months ago

Aren't the texture views holding sampler descriptors?

cwfitzgerald commented 12 months ago

Nope, bind groups own them - the way I express the limit to people is "number of sampler bindings in live bind groups"

nical commented 12 months ago

Ah yes indeed. That means we probably would benefit from eagerly destroying the bindgroups when a texture is destroyed or maybe destroy bindgroups pointing to destroyed resources when we get close to the sampler descriptor limit.

jimblandy commented 10 months ago

Closed as dup of #3350.