Skip to content

Commit a364e56

Browse files
jimblandycwfitzgerald
authored andcommitted
[core] Use lock::RwLock in RenderBundleScope.
This requires bumping the `LockRankSet` bitset from `u32` to `u64`.
1 parent 927b7e9 commit a364e56

File tree

2 files changed

+28
-9
lines changed

2 files changed

+28
-9
lines changed

wgpu-core/src/lock/rank.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ macro_rules! define_lock_ranks {
5555
bitflags::bitflags! {
5656
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
5757
/// A bitflags type representing a set of lock ranks.
58-
pub struct LockRankSet: u32 {
58+
pub struct LockRankSet: u64 {
5959
$(
60-
const $name = 1 << (LockRankNumber:: $name as u32);
60+
const $name = 1 << (LockRankNumber:: $name as u64);
6161
)*
6262
}
6363
}
@@ -143,6 +143,11 @@ define_lock_ranks! {
143143
rank DEVICE_USAGE_SCOPES "Device::usage_scopes" followed by { }
144144
rank IDENTITY_MANAGER_VALUES "IdentityManager::values" followed by { }
145145
rank REGISTRY_STORAGE "Registry::storage" followed by { }
146+
rank RENDER_BUNDLE_SCOPE_BUFFERS "RenderBundleScope::buffers" followed by { }
147+
rank RENDER_BUNDLE_SCOPE_TEXTURES "RenderBundleScope::textures" followed by { }
148+
rank RENDER_BUNDLE_SCOPE_BIND_GROUPS "RenderBundleScope::bind_groups" followed by { }
149+
rank RENDER_BUNDLE_SCOPE_RENDER_PIPELINES "RenderBundleScope::render_pipelines" followed by { }
150+
rank RENDER_BUNDLE_SCOPE_QUERY_SETS "RenderBundleScope::query_sets" followed by { }
146151
rank RESOURCE_POOL_INNER "ResourcePool::inner" followed by { }
147152
rank SHARED_TRACKER_INDEX_ALLOCATOR_INNER "SharedTrackerIndexAllocator::inner" followed by { }
148153
rank STAGING_BUFFER_RAW "StagingBuffer::raw" followed by { }

wgpu-core/src/track/mod.rs

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,11 @@ use crate::{
105105
binding_model, command, conv,
106106
hal_api::HalApi,
107107
id,
108-
lock::{rank, Mutex},
108+
lock::{rank, Mutex, RwLock},
109109
pipeline, resource,
110110
snatch::SnatchGuard,
111111
};
112112

113-
use parking_lot::RwLock;
114113
use std::{fmt, ops, sync::Arc};
115114
use thiserror::Error;
116115

@@ -489,11 +488,26 @@ impl<A: HalApi> RenderBundleScope<A> {
489488
/// Create the render bundle scope and pull the maximum IDs from the hubs.
490489
pub fn new() -> Self {
491490
Self {
492-
buffers: RwLock::new(BufferUsageScope::default()),
493-
textures: RwLock::new(TextureUsageScope::default()),
494-
bind_groups: RwLock::new(StatelessTracker::new()),
495-
render_pipelines: RwLock::new(StatelessTracker::new()),
496-
query_sets: RwLock::new(StatelessTracker::new()),
491+
buffers: RwLock::new(
492+
rank::RENDER_BUNDLE_SCOPE_BUFFERS,
493+
BufferUsageScope::default(),
494+
),
495+
textures: RwLock::new(
496+
rank::RENDER_BUNDLE_SCOPE_TEXTURES,
497+
TextureUsageScope::default(),
498+
),
499+
bind_groups: RwLock::new(
500+
rank::RENDER_BUNDLE_SCOPE_BIND_GROUPS,
501+
StatelessTracker::new(),
502+
),
503+
render_pipelines: RwLock::new(
504+
rank::RENDER_BUNDLE_SCOPE_RENDER_PIPELINES,
505+
StatelessTracker::new(),
506+
),
507+
query_sets: RwLock::new(
508+
rank::RENDER_BUNDLE_SCOPE_QUERY_SETS,
509+
StatelessTracker::new(),
510+
),
497511
}
498512
}
499513

0 commit comments

Comments
 (0)