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

Expose gpu allocation configuration options #5875

Merged
merged 6 commits into from
Jul 8, 2024
Merged

Conversation

nical
Copy link
Contributor

@nical nical commented Jun 25, 2024

Connections

Addresses #5869
See also Traverse-Research/gpu-allocator#235

Description

This commit adds hints to control memory allocations strategies to device configuration options. These hints allow for automatic profiles such as optimizing for performance (the default, makes sense for a game), optimizing for memory usage (typically more useful for a web browser or UI library) and specifying settings manually.

The details of gpu allocation are still in flux. The goal is to switch vulkan and metal to gpu_allocator which is currently used with d3d12. gpu_allocator will also likely receive more configuration options, in particular the ability to start with smaller memory block sizes and progressively grow the block size. So the manual settings already provision for this upcoming option. Another approach could be to wait and add the manual option after the dust settles.

The reason for providing presets and defining values in the backends instead of in platform-independent code is that I am convinced that optimal configurations should take hardware capabilities into consideration. It's a deep rabbit hole, though, so that will be an exercise for later.

Testing

The examples have a mix of Performance and MemoryUsage presets which gives some very superficial coverage, however this can't properly be tested without large/realistic workloads.

Checklist

  • Run cargo fmt.
  • Run cargo clippy. If applicable, add:
  • Run cargo xtask test to run tests.
  • Add change to CHANGELOG.md. See simple instructions inside file.

@nical nical requested a review from a team as a code owner June 25, 2024 12:07
@nical nical force-pushed the memcfg branch 5 times, most recently from b224d38 to c50b4f2 Compare June 28, 2024 14:43
@Wumpf Wumpf self-requested a review June 30, 2024 17:35
nical added 2 commits July 3, 2024 17:08
This commit adds hints to control memory allocations strategies to the configuration options. These hints allow for automatic profiles such as optimizing for performance (the default, makes sense for a game), optimizing for memory usage (typically more useful for a web browser or UI library) and specifying settings manually.

The details of gpu allocation are still in flux. The goal is to switch vulkan and metal to gpu_allocator which is currently used with d3d12. gpu_allocator will also likely receive more configuration options, in particular the ability to start with smaller memory block sizes and progressively grow the block size. So the manual settings already provision for this upcoming option. Another approach could be to wait and add the manual option after the dust settles.

The reason for providing presets and defining values in the backends is that I am convinced that optimal fonigurations should take hardware capabilities into consideration. It's a deep rabbithole, though, so that will be an exercise for later.
wgpu-hal/src/vulkan/adapter.rs Outdated Show resolved Hide resolved
Copy link
Member

@Wumpf Wumpf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looking good overall, great to start to expose this!
The Manual configuration is indeed a bit unforunate that it doesn't map well to either backend 🤔 . Not too strong feelings about it since the path forward is pretty clear (switch to gpu_allocator and expose its config more or less verbatim)

CHANGELOG.md Outdated Show resolved Hide resolved
wgpu-hal/src/vulkan/adapter.rs Show resolved Hide resolved
wgpu-hal/src/lib.rs Show resolved Hide resolved
Copy link
Member

@Wumpf Wumpf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@nical nical enabled auto-merge (squash) July 8, 2024 12:27
@nical nical merged commit 4c6318c into gfx-rs:trunk Jul 8, 2024
25 checks passed
@nical nical deleted the memcfg branch July 8, 2024 12:50
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.

2 participants