-
Notifications
You must be signed in to change notification settings - Fork 184
Uniquely identifying TextureView
s - Thoughts on a downstream API design problem
#206
Comments
The biggest question for me here is whether Nannou is an opaque abstraction, or a transparent one, when it comes to If it's transparent, then it should expose the programming model that is compatible with |
I ran into a similar issue. I've added |
Sorry I just realised I never responded here! @kvark nannou for the most part attempts to be transparent, but provides a suite of helper items to simplify common uses, provide some useful defaults, etc. We try to be as transparent as possible in order to:
We actually re-export |
Unfortunately we have a very wide target audience, e.g. we aim to provide both:
All that said, this is more of our own problem to solve though! I also think our current solution is actually working out nicely all things considered! I mostly just wanted to mention the experience for feedback and in case any other folk run into similar things and are thinking about solutions :) |
@mitchmindtree I see, thanks for the information! So |
I have a design problem w/ nannou I'm currently thinking about and would love to get your thoughts on! It's about the way users provide texture views to the immediate draw APIs such as:
and so on.
Each of these
draw
API calls creates an entry into an inner list ofDrawCommand
s which describe how to draw the whole scene at a very high-level. When it's time to render the contents of a draw instance to a texture, this list ofDrawCommand
s is consumed and thedraw::Renderer
converts them intoRenderCommand
s that map directly to commands that may be encoded with awgpu::CommandEncoder
.As a part of this process, the
draw::Renderer
needs to be able to uniquely distinguish between each of the texture views provided by the user in order to ensure it has one unique bind group ready for each unique texture. This allows us to draw an arbitrary number of different textures in a single render pass by inserting commands to switch between bind groups between draw commands, but only as often as is necessary. Currently however, thewgpu::TextureView
type has no way of being uniquely identified, and I'm trying to think of a nice way of going about this.The first option that comes to mind is to have the user maintain a map of
Id
s toTextureView
, whereId
s are submitted to the draw API and the map of texture views is lent to the rendering process. This is not ideal however, as we mostly shift the burden onto the user and have them run the risk of letting their map leak, etc. We could perhaps maintain a map for the user, however we would need to allow for the user to manually clear this map in some way or run the risk of leaking ourselves.Another option that comes to mind is creating a
TextureView
wrapper type that does allow for unique identification, e.g. the ID of the source texture, plus the unique descriptor it was created with. Ensuring that the source texture has an easily accessible unique ID should be doable for nannou as it already maintains its ownTexture
wrapper type as mentioned in #205. This does mean maintaining a wrapper type however, and all the issues that come along with this, e.g. keeping the API up to date with upstream, ensuring users can always access the inner type if necessary, running the risk of users not being able to use nannouTextureView
APIs with awgpu::TextureView
. Maybe these are worth the easier-to-use design though!I just wanted to share in case you had any thoughts or advice on how you would go about approaching this? Or whether perhaps you see enough value in the use case to consider allowing the
TextureView
to provide a.unique_id()
method orHash
impl - it seems the web target is the blocker here? I think this is one of the last missing pieces to make nannou's draw API really shine - would love for it to be both efficient yet also trivial to use when introducing brand new users to creative coding.The text was updated successfully, but these errors were encountered: