-
Notifications
You must be signed in to change notification settings - Fork 165
Refactor vello::util
#1048
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
base: main
Are you sure you want to change the base?
Refactor vello::util
#1048
Conversation
faadfcc
to
748324e
Compare
Signed-off-by: Nico Burns <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few thoughts, without having specifically carefully reviewed the code:
vello::util
should never have been our job to expose, and should be removed entirely (maybe inlined as appropriate intowith_winit
, and the other examples should just manage this themselves1). If you want to make a crate for something like this, the best place for that would probably be in the wgpu repository itself. I think we could land this first, if you wanted. However, I don't want to make another release with breaking changes here before removing it, so we need a plan for someone to do the requisite work. That might involve just slapping adocs(hidden)
on the whole module; I wouldn't like that solution, but it does address our needs here.vello::util
's is something which should be pretty independent of the rest of Vello - it's pretty much a generic wgpu utility. The addition of the blitter was explicitly as an intermediate state.- We have another copy of this code in
sparse_strips
, which probably should be updated similarly. - The updates generally look like a reasonable improvement to the code quality here
- This needs a changelog entry.
It's clear to me that Vello owning all of this stuff is not fit for purpose, and will require more and more special cased APIs.
Footnotes
-
This is a question about what the role of the "simple" example is; I think it's reasonable for that example to not care about multiple windows. See the discussion in https://github.com/linebender/vello/pull/227, where it seems like this multi-device support was never actually necessary, at least for single
Surface
cases. For headless and the tests, there is no surface, so it definitely doesn't need all this complexity. ↩
// Determine features to request | ||
// The user may request additional features | ||
let extra_features = self.extra_features.unwrap_or(Features::empty()); | ||
let vello_features = wgpu::Features::CLEAR_TEXTURE | wgpu::Features::PIPELINE_CACHE; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We probably should pass these in using the new mechanism, now
@DJMcNab It seems that this infrastructure is mostly for caching/reusing resources? Otherwise we could just recreate everything on every "resume"? Do you have a read on which operations are expensive?
I would really like to make
I think Vello also has quite specific requirements around things like features, limits, texture format? I guess we might be able to pass those in as parameters.
It would be nice to unify these into one if possible. Although I guess the intermediate texture isn't great in that regard. |
I don't think that's the case? It just some utilities around creating wgpu utilities, because there's a lot of boilerplate there. In particular, this is boilerplate around supporting multiple devices, which is only "necessary" if you're going to have multiple surfaces (an unoptimal surface will keep chugging along with bad performance, which is fine - we don't even both recreating a more optimal surface) I don't see how any part of my suggestion suggests to not maintain these resources, just not have them be managed by code in Vello - that's the wrong abstraction level.
Yeah, this would live inside of the
Ish? We basically just require baseline wgpu, but can make use of the clear texture ability. We really don't want to be in charge of creating your device.
Writing this out yourself in each app is basically the idiomatic way to write wgpu code. My suggestion for where a utility for this should live is the wgpu repository - the maintainers there are better placed to determine how to write this type of code idiomatically. See for example the examples for vello_hybrid: vello/sparse_strips/vello_hybrid/examples/wgpu_webgl/src/lib.rs Lines 38 to 71 in 36c6659
|
See also in #879, where we recreate the device etc in resume if and only if the old device was not compatible: |
If it's just boilerplate, then I don't understand why we persist the devices and the instance (i.e. why the code is stateful). It seems like you could just have a function that goes through the instance -> adapter -> device -> surface dance from scratch every time which would be much simpler (never bother with My assumption from the structure of the code was that there was some reason why devices must be reused, and I assumed performance (I'm still confused). |
I really don't follow what you're asking; your suggests seem completely unrelated to what I'm suggesting. But as I say, if you want to just move on from this, we can land this PR, with adding |
find_existing_device
methodDeviceHandle
insideRenderSurface
RenderContext
toRenderSurface
Features
andLimits
(possibly these should be less global)(the latter was the initial motivation for me interacting with this code - I need to be able to configure these for the
override_image
demo (both vello and blitz))Some questions:
RenderContext
be global? (actually static? suggested to be Arc>?)RenderContext
also holdVelloRenderer
s? Why iswith_winit
reusingVelloRenderer
instances?RenderContext
provide utility methods to help with pipeline caching?