The goal here (see #10) is to make binding easier or transparent. Removing the usize node structs is outside of this goal because they serve a real purpose (among them making the subpass API easy to use, by supporting copy) which I don't see improvements on yet.
Bind by Reference
This change introduces bind-by-reference as opposed to the current design, which is bind-by-value with regard to buffers, images, etc, being used on a render graph.
The new design retains almost entirely the same API as before, and previous concepts carry over.
What is new is that by implication of using a reference to bind nodes we do not need to unbind them, unless it is helpful in your workflow. Unbinding is now totally optional and could potentially be removed.
New example usage
let my_image = Arc::new(Image::create(&device, ImageInfo { ..same as before.. })?);
let my_node = frame.render_graph.bind_node(&my_image);
Upgrade guidance
Search and replace ImageBinding with Arc<Image> (same for Buffer and AccelerationStructure)
Search and replace ImageLeaseBinding with Arc<Lease<Image>> (same for Buffer and AccelerationStructure)
Remove as_mut().unwrap() pattern from new leases: You now have the actual resource directly
Remove unbind_node() calls (if you also change the bind_node() calls to use borrows instead of instances)
Description of the change
The first step was to move the state of a resource from the "graph" layer into the "driver" layer; so that state sits on the actual acceleration structure, buffer, or image. Doing this requires a synchronization primitive of some kind, because previously this state was "owned" by the graph and now it is borrowed. I've chosen to use an AtomicU8 for this state.
After moving the state data the only remaining field on the ImageBinding, BufferLeaseBinding, etc types was the actual resource.
The second commit removed these binding types and now you may bind any of Image, Arc<Image> or &Arc<Image>, etc. This means you don't have to provide instances of these resources, just borrows. This should make Screen 13 much easier to use.
TODO
[x] Unsoundness with descriptor sets (introduced with second commit, must fix, easy)
The goal here (see #10) is to make binding easier or transparent. Removing the
usize
node structs is outside of this goal because they serve a real purpose (among them making the subpass API easy to use, by supportingcopy
) which I don't see improvements on yet.Bind by Reference
This change introduces bind-by-reference as opposed to the current design, which is bind-by-value with regard to buffers, images, etc, being used on a render graph.
The new design retains almost entirely the same API as before, and previous concepts carry over.
What is new is that by implication of using a reference to bind nodes we do not need to unbind them, unless it is helpful in your workflow. Unbinding is now totally optional and could potentially be removed.
New example usage
Upgrade guidance
ImageBinding
withArc<Image>
(same forBuffer
andAccelerationStructure
)ImageLeaseBinding
withArc<Lease<Image>>
(same forBuffer
andAccelerationStructure
)as_mut().unwrap()
pattern from new leases: You now have the actual resource directlyunbind_node()
calls (if you also change thebind_node()
calls to use borrows instead of instances)Description of the change
The first step was to move the state of a resource from the "graph" layer into the "driver" layer; so that state sits on the actual acceleration structure, buffer, or image. Doing this requires a synchronization primitive of some kind, because previously this state was "owned" by the graph and now it is borrowed. I've chosen to use an
AtomicU8
for this state.After moving the state data the only remaining field on the
ImageBinding
,BufferLeaseBinding
, etc types was the actual resource.The second commit removed these binding types and now you may bind any of
Image
,Arc<Image>
or&Arc<Image>
, etc. This means you don't have to provide instances of these resources, just borrows. This should make Screen 13 much easier to use.TODO