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

Out of memory error when max_texture_dimension_2d isn't limited #43

Closed
ecton opened this issue Jun 28, 2023 · 2 comments
Closed

Out of memory error when max_texture_dimension_2d isn't limited #43

ecton opened this issue Jun 28, 2023 · 2 comments
Labels
question Further information is requested

Comments

@ecton
Copy link

ecton commented Jun 28, 2023

The hello-world example uses wgpu::Limits::downlevel_defaults(), which creates a set of limits with max_texture_dimension_2d set to 2048. In my wgpu application, I'm using wgpu::Limits::downlevel_webgl2_defaults().using_resolution(adapter.limits()) which is what many of the wgpu examples use. This results in a max_texture_dimension_2d of 32,768.

When the texture atlas is initialized against this device, it attempts to allocate a 32kx32k texture which is 4 gigs with the SrgbUnorm texture format. This causes an out of memory error on my machine.

I can of course restrict my limits further, but it seems like TextAtlas shouldn't be attempting to create the largest possible texture. Ideally it would start small and dynamically grow as needed. However, I know that's really complicated, so as an alternative, perhaps allow the developer a way to specify the atlas size explicitly?

@grovesNL
Copy link
Owner

Hi @ecton! Yeah absolutely - this was planned from the start to be configurable and optionally grow (#7).

If you'd like to try it out, #34 implements the first version of an initially smaller atlas that grows as needed.

@grovesNL grovesNL added the question Further information is requested label Jun 28, 2023
@ecton
Copy link
Author

ecton commented Jun 28, 2023

That's always great news when the issue you report turns out to already be in process of being resolved! Sorry I didn't notice the existing issue for resizing the atlas before submitting this report.

I can confirm that the branch in #34 at least causes the out of memory error to go away. I'm going to go ahead and close this since it's mostly a duplicate of #7.

Thank you for the quick response!

@ecton ecton closed this as completed Jun 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants