Skip to content

Expose DeviceDescriptor::memory_hints via WGPUDeviceExtras - #619

Open
RubyBit wants to merge 1 commit into
gfx-rs:trunkfrom
RubyBit:expose-memory-hints
Open

Expose DeviceDescriptor::memory_hints via WGPUDeviceExtras#619
RubyBit wants to merge 1 commit into
gfx-rs:trunkfrom
RubyBit:expose-memory-hints

Conversation

@RubyBit

@RubyBit RubyBit commented Jul 12, 2026

Copy link
Copy Markdown

Checklist

  • cargo clippy reports no issues
  • cargo doc reports no issues (unrelated to my changes)
  • cargo deny issues have been fixed or added to deny.toml
  • Human-readable change descriptions added to CHANGELOG.md under the "Unreleased" heading.
    • If the change does not affect the user (or is a process change), preface the change with "Internal:"
    • Add credit to yourself for each change: Added new functionality. @githubname

Description

wgpu's DeviceDescriptor has had memory_hints since MemoryHints was introduced, but map_device_descriptor hardcoded Default::default() (Performance) to be changed in the future (so I changed it): Performance hints make gpu-allocator commit 128 MiB device + 64 MiB host memory blocks for the few tiny internal allocations wgpu makes at device open, so creating a bare device commits ~200 MiB of VRAM (measured on NVIDIA RTX 4080 Laptop/Vulkan; D3D12 is similar), and all committed memory rounds up in 256 MiB steps. Applications with small or mostly-static workloads have had no way to opt out through the C API (such as my tensor library which can load pretty small models on the gpu through wgpu and there is an unnecessary, around 200 MiB overhead).

Add a WGPUMemoryHints enum (Undefined/Performance/MemoryUsage/Manual) and memoryHints + suballocatedDeviceMemoryBlockSize{Start,End} fields to WGPUDeviceExtras, mapped onto wgt::MemoryHints. Zero-initialized extras keep the previous behavior (Undefined -> Performance).

Measured bare-device committed VRAM (RTX 4080 Laptop, Vulkan):
Performance (old default): 201 MiB
MemoryUsage: 21 MiB
Manual { 4 MiB..256 MiB }: 17 MiB

Related Issues

wgpu's DeviceDescriptor has had memory_hints since MemoryHints was
introduced, but map_device_descriptor hardcoded Default::default()
(Performance), with a `// TODO(wgpu.h)` marker. Performance hints make
gpu-allocator commit 128 MiB device + 64 MiB host memory blocks for the
few tiny internal allocations wgpu makes at device open, so creating a
bare device commits ~200 MiB of VRAM (measured on NVIDIA RTX 4080
Laptop/Vulkan; D3D12 is similar), and all committed memory rounds up in
256 MiB steps. Applications with small or mostly-static workloads have
had no way to opt out through the C API.

Add a WGPUMemoryHints enum (Undefined/Performance/MemoryUsage/Manual)
and memoryHints + suballocatedDeviceMemoryBlockSize{Start,End} fields to
WGPUDeviceExtras, mapped onto wgt::MemoryHints. Zero-initialized extras
keep the previous behavior (Undefined -> Performance).

Measured bare-device committed VRAM (RTX 4080 Laptop, Vulkan):
  Performance (old default): 201 MiB
  MemoryUsage:                21 MiB
  Manual { 4 MiB..256 MiB }:  17 MiB

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@RubyBit
RubyBit force-pushed the expose-memory-hints branch from 93db410 to 154a73a Compare July 12, 2026 16:55
@inner-daemons

Copy link
Copy Markdown

Added by #594 so unless you need this instantly I would prefer to wait.

@RubyBit

RubyBit commented Jul 17, 2026

Copy link
Copy Markdown
Author

I see, but when can we expect the PR merged then? v30 also released a few weeks ago.

@inner-daemons

Copy link
Copy Markdown

@RubyBit I would expect within the next month at most for it to be merged, but I have hopes it could happen sooner.

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