-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
TrackedRenderPass
internal tracking state reset
#14948
TrackedRenderPass
internal tracking state reset
#14948
Conversation
/// Resets tracking state | ||
pub fn reset_tracking(&mut self) { | ||
self.pipeline = None; | ||
self.bind_groups.iter_mut().for_each(|val| { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I understand why you set the values to None instead of just clearing the entire vec so it's emtpy.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See previous comment: https://github.com/bevyengine/bevy/pull/14948/files#r1733639227
@@ -95,6 +95,19 @@ impl DrawState { | |||
) -> bool { | |||
self.index_buffer == Some((buffer, offset, index_format)) | |||
} | |||
|
|||
/// Resets tracking state | |||
pub fn reset_tracking(&mut self) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couldn't this just do self = Default::default()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is important to keep vector lengths to device limits. Additionally, we want to avoid reallocating Vec heap memory.
See TrackedRenderPass::new
state: DrawState {
bind_groups: vec![(None, Vec::new()); max_bind_groups],
vertex_buffers: vec![None; max_vertex_buffers],
..default()
},
@fintelia could I get your review here? |
This change looks plausible to me, but I'm not familiar enough with the surrounding code at this point to have much confidence. The one suggestion I have is that it might make sense to have |
Applied @fintelia suggestion. Fixed conflicts. |
11a6650
to
6a9c663
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lgtm sans comment about the name.
@@ -24,6 +24,9 @@ struct DrawState { | |||
/// List of vertex buffers by [`BufferId`], offset, and size. See [`DrawState::buffer_slice_key`] | |||
vertex_buffers: Vec<Option<(BufferId, u64, u64)>>, | |||
index_buffer: Option<(BufferId, u64, IndexFormat)>, | |||
|
|||
/// Stores whether this state is populated or empty for quick state invalidation | |||
stores_state: bool, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bikeshed: this name confuses me, can we try one of
dirty
changed
modified
instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought of multiple variants when I implemented this, but they do not improve the situation and didn't feel correct for me.
DrawState
structure stores state.
changed
: It doesn't store if state has changed between different points in time, it stores state information of RenderPass.modified
: The same as withchanged
.dirty
: Stored state doesn't make this structure dirty (It implies something incorrect, not cleaned up). In reality normally this structure should store state, be populated.
That is the reason why I decided to use explicit naming of store_state
with documentation comment. Maybe populated
could be used, but explicit name store_state
made sense for me.
Can change variable name if other reviewers suggest to do so.
Ping @IceSentry |
Objective
Fixes #13225
Solution
Invalidate
TrackedRenderPass
internal state upon accessing internalwgpu::RenderPass
.Testing
set_bind_group
onRenderPass
returned byTrackedRenderPass::wgpu_pass
and checking if in laterset_bind_group
calls onTrackedRenderPass
correct bind group is restored.