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

Metal just returns NULL when creating a large 3D texture #3153

Closed
kvark opened this issue Nov 1, 2022 · 2 comments · Fixed by #3554
Closed

Metal just returns NULL when creating a large 3D texture #3153

kvark opened this issue Nov 1, 2022 · 2 comments · Fixed by #3554
Labels
api: metal Issues with Metal area: correctness We're behaving incorrectly external: driver-bug A driver is causing the bug, though we may still want to work around it type: bug Something isn't working

Comments

@kvark
Copy link
Member

kvark commented Nov 1, 2022

Description
I'm creating an R32Uint texture of size 1024x2048x256, and this line just returns a NULL handle:

let raw = self.shared.device.lock().new_texture(&descriptor);

A smaller size works (e.g. 128 for the depth).
It's either a driver bug, or we are hitting another limit that we don't know about.

Repro steps
available upon demand :)
This happens in vange-rs

Expected vs observed behavior
We should return an error, or succeed.

Extra materials
Total number of requested texels is 512M.
The total byte size is 2Gb. This one is interesting.
Metal behaves as if it can't allocate more than 1Gb, hence reducing the Z dimension to 128 works (it brings the total size to 1GB). Metal has a limit for the max buffer size. Maybe it also applies to textures?

Platform

MacBook Pro (13-inch, 2016, Four Thunderbolt 3 Ports)
Intel Iris Graphics 550 1536 MB
MacOS 12.6.1 (21G217)

@kvark kvark added type: bug Something isn't working external: driver-bug A driver is causing the bug, though we may still want to work around it area: correctness We're behaving incorrectly api: metal Issues with Metal labels Nov 1, 2022
@teoxoy teoxoy added this to the WebGPU Specification V1 milestone Dec 5, 2022
@jinleili
Copy link
Contributor

let texture_descriptor = wgpu::TextureDescriptor {
	size: wgpu::Extent3d {
		width: 1024,
		height: 2048,
		depth_or_array_layers: 256,
	},
// ...
};

let mut list: Vec<wgpu::Texture> = vec![];
for i in 0..300 {
	println!("Create texture {}", i);
	let a_texture = device.create_texture(&texture_descriptor);
	list.push(a_texture);
}

I tested it on Mac and iPhone using the above code.
On the M1 Mac (64G RAM), crash occurs when i is equal to 180;
On iPhone 12, crash occurs when i is equal to 2;

Changing size to 4096x4096x256, it will crash on M1 Mac when i is equal to 22. So, the issue is probably related to the amount of memory available to the GPU.

@teoxoy
Copy link
Member

teoxoy commented Mar 3, 2023

So, the issue is probably related to the amount of memory available to the GPU.

Looking at the metal docs, it sounds right.

Return Value
A new texture object backed by heap memory, or nil if the heap memory is full.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: metal Issues with Metal area: correctness We're behaving incorrectly external: driver-bug A driver is causing the bug, though we may still want to work around it type: bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants