Skip to content
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

[re_renderer] Interior mutable buffer/texture/bindgroup pools #1374

Merged
merged 10 commits into from Feb 22, 2023

Conversation

Wumpf
Copy link
Member

@Wumpf Wumpf commented Feb 21, 2023

Allows allocating buffers/textures/bindgroups without a mut reference to the pool.
Moved wgpu::Buffer ownership from slotmap inside the pool to the strong handle itself, simplifying a lot of callsites.

Some ripple effects on DrawData lifetime requirements and that in turn onto how ViewBuilder are composited - needed to do a workaround for the egui integration case.

Checklist

  • I have read and agree to Contributor Guide and the Code of Conduct
  • I've included a screenshot or gif (if applicable)
  • I've added a line to CHANGELOG.md (if this is a big enough change to warrant it)

@Wumpf Wumpf changed the title [re_renderer] Interior multable buffer/texture/bindgroup pools [re_renderer] Interior mutable buffer/texture/bindgroup pools Feb 21, 2023
@Wumpf Wumpf added the 🔺 re_renderer affects re_renderer itself label Feb 21, 2023
@Wumpf Wumpf marked this pull request as ready for review February 21, 2023 23:23
0,
index_buffer_size.try_into().unwrap(),
)
.write_buffer_with(&index_buffer, 0, index_buffer_size.try_into().unwrap())
.unwrap(); // Fails only if mapping is bigger than buffer size.
Copy link
Member

Choose a reason for hiding this comment

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

unrelated, but there is a lot of scary unwraps in this code

Copy link
Member Author

Choose a reason for hiding this comment

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

all of those write_buffer_with will soon be replaced with the staging belt, making them at least look less scary 🙃

state.alive_resources.retain(|_, resource| {
let resolved = resource
.take()
.expect("Alive resources should never be None");
Copy link
Member

Choose a reason for hiding this comment

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

then why use an Option in alive_resources?? O.o

Copy link
Member

Choose a reason for hiding this comment

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

ah ok, it needs to be taken here so we can unwrap it.

Copy link
Member Author

Choose a reason for hiding this comment

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

yeah that whole thing is a bit of an annoying workaround

crates/re_renderer/src/wgpu_resources/texture_pool.rs Outdated Show resolved Hide resolved
@@ -56,10 +76,16 @@ where
Handle: Key,
Desc: Clone + Eq + Hash + Debug + SizedResourceDesc,
{
pub fn alloc<F: FnOnce(&Desc) -> Res>(&mut self, desc: &Desc, creation_func: F) -> Arc<Handle> {
pub fn alloc<F: FnOnce(&Desc) -> Res>(
&self,
Copy link
Member

Choose a reason for hiding this comment

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

so alloc is now thread-safe? that's very nice!

Copy link
Member

@emilk emilk left a comment

Choose a reason for hiding this comment

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

There's a lot of scary unwrap calls, but otherwise LGTM

@teh-cmc teh-cmc self-requested a review February 22, 2023 09:29
@Wumpf Wumpf merged commit 49cc353 into main Feb 22, 2023
@Wumpf Wumpf deleted the andreas/re_renderer/interior-mutable-pools branch February 22, 2023 11:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🔺 re_renderer affects re_renderer itself
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants