Repository navigation
Build headless WGPU renderers on a shared context - #17
Draft
francois-unity wants to merge 2 commits into
Draft
francois-unity wants to merge 2 commits into
francois-unity wants to merge 2 commits into
Conversation
WgpuHeadlessRenderer::with_context(&WgpuContext) renders on an existing context's device and queue, so a test suite that opens many headless windows creates one device instead of one per window. Each renderer keeps its own sprite atlas and render target. new_with_requirements now delegates to it.
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.
Headless renderers can now share one GPU device.
WgpuHeadlessRenderer::with_context(&WgpuContext)builds a renderer on an existing context’s device and queue instead of creating a new device.WgpuHeadlessRendererfor each one.new()creates a new instance, adapter and device on every call, and on lavapipe that setup is about four fifths of each scene’s time.with_contexttakes the context by reference; each renderer still gets its own sprite atlas and render target, as every window does today.new_with_requirementsnow delegates to it, sonew()behaves as before.WgpuContextrather than aWgpuContextHandle: the handle has nowgpu::Adapter, and building the render target needs one.Testing
A new test in
tests/headless_primitives.rs,renderers_on_one_context_share_its_device_and_render_alike, builds two renderers on one context and one on its own device. It checks that the two report the same device (and that it is the context’s device and queue), that the third reports a different one, and that all three render the same path scene to identical frames.Locally on an Apple Silicon Mac:
cargo test -p gpui_ce_wgpu --features test-support --test headless_primitivespasses (6 tests), and clippy is clean ongpui_ce_wgpu(all targets,test-support).This branch is
unity/hub-consolidated(the Hub’s current pin,94d0427e2d) plus this one commit.