Correctly set the tacker sizes before executing render bundles

This commit is contained in:
Nicolas Silva 2024-02-27 11:08:21 +01:00 committed by Erich Gubler
parent ed852c4774
commit 6f68d3dffa
2 changed files with 32 additions and 30 deletions

View File

@ -350,24 +350,44 @@ impl RenderBundleEncoder {
) -> Result<RenderBundle<A>, RenderBundleError> {
let bind_group_guard = hub.bind_groups.read();
let pipeline_guard = hub.render_pipelines.read();
let query_set_guard = hub.query_sets.read();
let buffer_guard = hub.buffers.read();
let texture_guard = hub.textures.read();
let mut state = State {
trackers: RenderBundleScope::new(
&*buffer_guard,
&*texture_guard,
&*bind_group_guard,
&*pipeline_guard,
&*query_set_guard,
),
trackers: RenderBundleScope::new(),
pipeline: None,
bind: (0..hal::MAX_BIND_GROUPS).map(|_| None).collect(),
vertex: (0..hal::MAX_VERTEX_BUFFERS).map(|_| None).collect(),
index: None,
flat_dynamic_offsets: Vec::new(),
};
let indices = &device.tracker_indices;
state
.trackers
.buffers
.write()
.set_size(indices.buffers.size());
state
.trackers
.textures
.write()
.set_size(indices.textures.size());
state
.trackers
.bind_groups
.write()
.set_size(indices.bind_groups.size());
state
.trackers
.render_pipelines
.write()
.set_size(indices.render_pipelines.size());
state
.trackers
.query_sets
.write()
.set_size(indices.query_sets.size());
let mut commands = Vec::new();
let mut buffer_memory_init_actions = Vec::new();
let mut texture_memory_init_actions = Vec::new();

View File

@ -103,7 +103,6 @@ mod texture;
use crate::{
binding_model, command, conv, hal_api::HalApi, id, pipeline, resource, snatch::SnatchGuard,
storage::Storage,
};
use parking_lot::{Mutex, RwLock};
@ -479,31 +478,14 @@ pub(crate) struct RenderBundleScope<A: HalApi> {
impl<A: HalApi> RenderBundleScope<A> {
/// Create the render bundle scope and pull the maximum IDs from the hubs.
pub fn new(
buffers: &Storage<resource::Buffer<A>>,
textures: &Storage<resource::Texture<A>>,
bind_groups: &Storage<binding_model::BindGroup<A>>,
render_pipelines: &Storage<pipeline::RenderPipeline<A>>,
query_sets: &Storage<resource::QuerySet<A>>,
) -> Self {
let value = Self {
pub fn new() -> Self {
Self {
buffers: RwLock::new(BufferUsageScope::new()),
textures: RwLock::new(TextureUsageScope::new()),
bind_groups: RwLock::new(StatelessTracker::new()),
render_pipelines: RwLock::new(StatelessTracker::new()),
query_sets: RwLock::new(StatelessTracker::new()),
};
value.buffers.write().set_size(buffers.len());
value.textures.write().set_size(textures.len());
value.bind_groups.write().set_size(bind_groups.len());
value
.render_pipelines
.write()
.set_size(render_pipelines.len());
value.query_sets.write().set_size(query_sets.len());
value
}
}
/// Merge the inner contents of a bind group into the render bundle tracker.