Free textures after submitting queue instead of before with wgpu renderer on Web (#7291)
This commit is contained in:
parent
dc79998044
commit
1878874f7d
|
|
@ -279,13 +279,6 @@ impl WebPainter for WebPainterWgpu {
|
||||||
Some((output_frame, capture_buffer))
|
Some((output_frame, capture_buffer))
|
||||||
};
|
};
|
||||||
|
|
||||||
{
|
|
||||||
let mut renderer = render_state.renderer.write();
|
|
||||||
for id in &textures_delta.free {
|
|
||||||
renderer.free_texture(id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Submit the commands: both the main buffer and user-defined ones.
|
// Submit the commands: both the main buffer and user-defined ones.
|
||||||
render_state
|
render_state
|
||||||
.queue
|
.queue
|
||||||
|
|
@ -307,6 +300,16 @@ impl WebPainter for WebPainterWgpu {
|
||||||
frame.present();
|
frame.present();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Free textures marked for destruction **after** queue submit since they might still be used in the current frame.
|
||||||
|
// Calling `wgpu::Texture::destroy` on a texture that is still in use would invalidate the command buffer(s) it is used in.
|
||||||
|
// However, once we called `wgpu::Queue::submit`, it is up for wgpu to determine how long the underlying gpu resource has to live.
|
||||||
|
{
|
||||||
|
let mut renderer = render_state.renderer.write();
|
||||||
|
for id in &textures_delta.free {
|
||||||
|
renderer.free_texture(id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue