Repository navigation
feat(gpu): expose startup GpuMemoryPolicy for wgpu suballocation - #1903
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #80
Summary
GpuMemoryPolicy(MemoryUsagedefault,Performance,Manual { block_size: Range<u64> }) incrates/rune-gpu/src/memory.rsand re-exports it fromrune.rune::set_gpu_memory_policy(policy)andApp::gpu_memory_policy(self, policy)(crates/rune/src/render/device.rs,crates/rune/src/app.rs), keepingwgputypes out ofrune's public API.Gpu::device_on(crates/rune/src/render/device.rs) to passrune_gpu::memory::wgpu_hints()towgpu::DeviceDescriptor::memory_hints, reaching every window, overlay, headless, prewarmed, and warmed device.prewarm_gputhread or discards a parked/warming Windows/Linuxwarm_gpudevice so a cached device built under the old policy is never silently reused.Manualranges (start.max(1)..end.max(start.max(1))) while preserving fixed-size ranges (4 MiB..4 MiB).LAUNCH_FLOOR_MEMORY_POLICYtoexamples/launch-floor/src/main.rs(memory-usage,performance,manual:<mib>,manual:<min>-<max>), updatescrates/rune/README.mdandexamples/README.md, and addschangelog/unreleased/2026-11-24-gpu-memory-policy.md.Design basis
wgpu::MemoryHints(MemoryUsage,Performance,Manual { suballocated_device_memory_block_size }), preserving Rune's existingMemoryUsagedefault. Honored by wgpu's D3D12 (Windows) and Vulkan (Linux) suballocators; ignored by Rune's native Metal backend, wgpu's Metal backend, and browser backends (WebGPU/WebGL2). Resources larger than aManualblock range still succeed via dedicated allocations.GpuBackend/App::gpu_backendprocess-wide startup pattern (crates/rune-gpu/src/backend.rs,crates/rune/src/app.rs,crates/rune/src/render/device.rs).Usage
For apps calling
prewarm_gpu(),warm_gpu(), orwarm_gpu_cache()before buildingApp, callrune::set_gpu_memory_policy(...)first.Verification
rune-gpu(50 passed + 1 doctest),rune::render::device(25 passed, including isolated child-process D3D12 allocator-report checks verifying 8 MiB defaultMemoryUsage, 4 MiBManual { 4..8 MiB }via bothset_gpu_memory_policyandApp::gpu_memory_policyplus a 10 MiB dedicated allocation, 128 MiBPerformance, and parked-GPU discard on policy change),render::prewarm_tests(1 passed),render::warm_tests(6 passed),launch-floor(1 passed),runedoctests (2 passed),cargo check -p rune -p rune-kit.cargo test -p rune-gpu -p rune --lib -- memory render::device render::prewarm_tests(31 + 6 passed).cargo check -p rune-gpu -p rune -p rune-kit --tests(compiled).cargo check-wasmandcargo check-webgl(compiled).scripts/file-size.shpassed.