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

Rework render target allocation #351

Merged
merged 7 commits into from
Mar 3, 2020
Merged

Conversation

zakorgy
Copy link

@zakorgy zakorgy commented Feb 6, 2020

This is the first step toward #348 . We allocate a large chunk of linear memory which we can use for render targets between consecutive frames. Right now the PR just allows us to reuse that chunk between frames, the next step would be reuse it between render passes.


This change is Reviewable

@zakorgy zakorgy force-pushed the render-target-alloc branch from b4103c2 to 098a20c Compare February 6, 2020 12:00
@@ -352,6 +352,7 @@ pub struct Device<B: hal::Backend> {
#[cfg(debug_assertions)]
shader_is_ready: bool,
rebind_descriptors: bool,
linear_memory: LinearMemoryBlock<B>,
Copy link

Choose a reason for hiding this comment

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

can we call it render_target_memory?

@@ -1918,6 +1928,7 @@ impl<B: hal::Backend> Device<B> {
filter: TextureFilter,
render_target: Option<RenderTargetInfo>,
layer_count: i32,
texture_usage: TextureUsage,
Copy link

Choose a reason for hiding this comment

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

Don't we already know if it's a render target based on the render_target parameter? Does a new parameter help?

Copy link
Author

Choose a reason for hiding this comment

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

Yes we know that this is a render target from that parameter, but there is a TextureCache texture which is also a render target, but can persist across multiple frames and we can't use the linear allocation for that:
https://github.com/szeged/webrender/blob/master/webrender/src/renderer.rs#L3462

Copy link

Choose a reason for hiding this comment

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

in this case, can we extend RenderTargetInfo ? perhaps, something as simple as a persistent: bool field would work best.

@zakorgy zakorgy changed the title WIP Rework render target allocation Rework render target allocation Feb 13, 2020
@zakorgy zakorgy force-pushed the render-target-alloc branch from 40859ab to ee93717 Compare February 19, 2020 10:03
@zakorgy zakorgy requested a review from kvark February 19, 2020 16:34
@@ -1983,6 +1990,12 @@ impl<B: hal::Backend> Device<B> {
usage_base | hal::image::Usage::COLOR_ATTACHMENT,
),
};

let (memory, id) = match render_target {
Some(RenderTargetInfo { has_depth: _, persistent}) if !persistent => (Some(&mut self.render_target_memory), Some(texture.id)),
Copy link

Choose a reason for hiding this comment

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

could just do RenderTargetInfo { persistent: false, .. }

}
}

struct LinearMemoryBlock<B: hal::Backend> {
Copy link

Choose a reason for hiding this comment

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

isn't all of that implemented by rendy-memory?

memory_block: MemoryBlock<B>,
alignment: u64,
type_mask: u64,
free_chunks: Vec<MemoryRange>,
Copy link

Choose a reason for hiding this comment

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

My understanding is that the whole point of a linear allocator ("Linear" in the LinearMemoryBlock) that we don't need to track any free chunks, otherwise it's becoming a general-purpose allocator.

Copy link
Author

Choose a reason for hiding this comment

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

That's true, and that was the case before I introduced the tracking of free chunks(which is required to reuse memory between passes), I just forget to change the name of the allocator and the block. I will change it to avoid further confusion.

Copy link

@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.

As agreed on the last call!

@zakorgy zakorgy merged commit 8f8c001 into szeged:master Mar 3, 2020
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