wgpu icon indicating copy to clipboard operation
wgpu copied to clipboard

max_sampled_texture_limit on metal is too low

Open Darksecond opened this issue 1 year ago • 3 comments

Description According to https://developer.apple.com/metal/Metal-Feature-Set-Tables.pdf the limit for "Maximum number of textures you can access, per stage, from an argument buffer" is 1M on my device (M1 Pro, so Apple7 in the pdf). However wgpu has a hardcoded limit (on metal) of 16 max_sampled_textures_per_shader_stage. I would like to make a TextureViewArray binding with more than 16 items.

Expected vs observed behavior I get limits that are lower than possible according to the Apple's specs.

Platform wgpu master on metal on m1 pro

Darksecond avatar Jul 20 '22 11:07 Darksecond

Actually, since it looks like wgpu and naga do not use argument buffers, the limit is 128 (which is still much higher than the 16 currently enforced). self.max_textures_per_stage already has the right value in it so it should be an easy change.

Darksecond avatar Jul 20 '22 11:07 Darksecond

Ran into the same issue: I can create a texture array with 256 layers without any issues, but I can't use it because the BindGroupLayoutEntry count must be set to texture layer count and then it runs into the aforementioned limit. Reproducable with a tweaked (count > 16) texture-arrays example.

I'm not sure if WGPU is checking the correct limit here... Isn't texture array binding counts as a single texture binding, regardless of how many layers it contains? Otherwise texture arrays wouldn't make much sense.

Edit: I'm confusing texture arrays with array textures, nevermind. Array textures work as expected after some fixing on my side.

yzsolt avatar Jul 31 '22 08:07 yzsolt

Reproducable with a tweaked (count > 16) texture-arrays example.

The default limits used by wgpu examples are Limits::downlevel_webgl2_defaults(), set limits: adapter.limits() can use the actual hardware limits.

jinleili avatar Aug 21 '22 09:08 jinleili