Skip to content

RenderBundle support #286

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

Merged
merged 3 commits into from
Jun 11, 2020
Merged

RenderBundle support #286

merged 3 commits into from
Jun 11, 2020

Conversation

kvark
Copy link
Member

@kvark kvark commented Aug 15, 2019

Implements the API of gpuweb/gpuweb#301

The general concept here is having re-usable command streams, which seems much desired given that our command buffers are not reusable.

Currently, only "software" render bundles are supported. That means, they are just smaller chunks of render pass commands, not backed by any driver object.

TODO:

@kvark kvark changed the title [WIP] RenderBundle support RenderBundle support Jun 8, 2020
@kvark kvark marked this pull request as ready for review June 8, 2020 13:32
Copy link
Member

@cwfitzgerald cwfitzgerald left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not knowledgeable on the content, but nothing stuck out to me in the code itself.

@kvark
Copy link
Member Author

kvark commented Jun 9, 2020

Faced a conceptual problem with life times here.

lifetime problem

A render bundle knows about its dependencies and carries a TrackerSet. A render pass, however, doesn't carry TrackersSet around, since it was built in an assumption that all the dependencies will live as long as the pass is recorded. We require the same for the render bundle as a dependency, so technically the requirement for bundle dependencies is fulfilled - they are guaranteed to be alive.

However, the problem comes from actual details. When the bundle is executed in a pass, we just merge in the stream of commands from the bundle. Suppose this stream uses resource A, held alive by the bundle. Suppose the resource got dropped by the user before using the bundle. When the render pass finishes, it goes through the raw commands and encounters that resources, and it sees that the resource is dead. So it panics, since from its perspective, the dependency wasn't held alive.

Proposed solution

I think we can get away here by carrying the TrackerSet in a render pass. For now, we are only going to use it for render bundles: by merging the tracked states in, or at least registering the resources that the bundle uses. This means that, when the pass is finishing, it will see the bundle dependencies as "known" resources.

Second part is to avoid the tracker panic in this borrow. Instead, a resource should produce Option<&RefCount>, which we'll only require if the resource was actually not registerd before, i.e. in the Vacant arm. This will still be correct, and allow bundles to propagate their dependencies smoothly.

@kvark kvark requested a review from cwfitzgerald June 10, 2020 13:36
@kvark
Copy link
Member Author

kvark commented Jun 10, 2020

@cwfitzgerald sorry about the size here, I had to take a different approach in light of the lifetime issues expressed in the previous comments. I believe, it's all for the better, as bundles are now truly visible in the API tracing, and faster to work with. Please see the description at the top of "bundle.rs" in this PR.

Copy link
Member

@cwfitzgerald cwfitzgerald left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple comments/concerns, but nothing major :)

kvark added 3 commits June 11, 2020 15:28
This is a major change in how the bundles are implemented. Instead of
transparently injecting them into the pass command stream, we are now
treating bundles as first-class API objects and API tracing them
accordingly. The bundle contains a normalized command stream that is
very easy to inject into a native command buffer multiple times.
Copy link
Member Author

@kvark kvark left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

Copy link
Member

@cwfitzgerald cwfitzgerald left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@kvark
Copy link
Member Author

kvark commented Jun 11, 2020

bors r=cwfitzgerald

@bors
Copy link
Contributor

bors bot commented Jun 11, 2020

@bors bors bot merged commit 475696a into gfx-rs:master Jun 11, 2020
@kvark kvark deleted the bundle branch June 11, 2020 19:51
bors bot added a commit to gfx-rs/wgpu-native that referenced this pull request Aug 18, 2020
37: Update wgpu with bundle support r=kvark a=kvark

Depends on gfx-rs/wgpu#286
Blocked on mozilla/cbindgen#532 :(

Co-authored-by: Dzmitry Malyshau <kvarkus@gmail.com>
bors bot added a commit to gfx-rs/wgpu-native that referenced this pull request Aug 20, 2020
37: Update wgpu with bundle support r=kvark a=kvark

Depends on gfx-rs/wgpu#286
Blocked on mozilla/cbindgen#532 :(

Co-authored-by: Dzmitry Malyshau <kvarkus@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants