[core] Use lock::RwLock in RenderBundleScope.

This requires bumping the `LockRankSet` bitset from `u32` to `u64`.
This commit is contained in:
Jim Blandy authored and Connor Fitzgerald committed 2024-04-25 01:28:21 -04:00
1 parent 927b7e96fe
commit a364e566cd
2 files changed
+28 -9

No files matched your search

+7 -2
View File
@@ -55,9 +55,9 @@ macro_rules! define_lock_ranks {
bitflags::bitflags! {
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
/// A bitflags type representing a set of lock ranks.
pub struct LockRankSet: u32 {
pub struct LockRankSet: u64 {
$(
const $name = 1 << (LockRankNumber:: $name as u32);
const $name = 1 << (LockRankNumber:: $name as u64);
)*
}
}
@@ -143,6 +143,11 @@ define_lock_ranks! {
rank DEVICE_USAGE_SCOPES "Device::usage_scopes" followed by { }
rank IDENTITY_MANAGER_VALUES "IdentityManager::values" followed by { }
rank REGISTRY_STORAGE "Registry::storage" followed by { }
rank RENDER_BUNDLE_SCOPE_BUFFERS "RenderBundleScope::buffers" followed by { }
rank RENDER_BUNDLE_SCOPE_TEXTURES "RenderBundleScope::textures" followed by { }
rank RENDER_BUNDLE_SCOPE_BIND_GROUPS "RenderBundleScope::bind_groups" followed by { }
rank RENDER_BUNDLE_SCOPE_RENDER_PIPELINES "RenderBundleScope::render_pipelines" followed by { }
rank RENDER_BUNDLE_SCOPE_QUERY_SETS "RenderBundleScope::query_sets" followed by { }
rank RESOURCE_POOL_INNER "ResourcePool::inner" followed by { }
rank SHARED_TRACKER_INDEX_ALLOCATOR_INNER "SharedTrackerIndexAllocator::inner" followed by { }
rank STAGING_BUFFER_RAW "StagingBuffer::raw" followed by { }
+21 -7
View File
@@ -105,12 +105,11 @@ use crate::{
binding_model, command, conv,
hal_api::HalApi,
id,
lock::{rank, Mutex},
lock::{rank, Mutex, RwLock},
pipeline, resource,
snatch::SnatchGuard,
};
use parking_lot::RwLock;
use std::{fmt, ops, sync::Arc};
use thiserror::Error;
@@ -489,11 +488,26 @@ impl<A: HalApi> RenderBundleScope<A> {
/// Create the render bundle scope and pull the maximum IDs from the hubs.
pub fn new() -> Self {
Self {
buffers: RwLock::new(BufferUsageScope::default()),
textures: RwLock::new(TextureUsageScope::default()),
bind_groups: RwLock::new(StatelessTracker::new()),
render_pipelines: RwLock::new(StatelessTracker::new()),
query_sets: RwLock::new(StatelessTracker::new()),
buffers: RwLock::new(
rank::RENDER_BUNDLE_SCOPE_BUFFERS,
BufferUsageScope::default(),
),
textures: RwLock::new(
rank::RENDER_BUNDLE_SCOPE_TEXTURES,
TextureUsageScope::default(),
),
bind_groups: RwLock::new(
rank::RENDER_BUNDLE_SCOPE_BIND_GROUPS,
StatelessTracker::new(),
),
render_pipelines: RwLock::new(
rank::RENDER_BUNDLE_SCOPE_RENDER_PIPELINES,
StatelessTracker::new(),
),
query_sets: RwLock::new(
rank::RENDER_BUNDLE_SCOPE_QUERY_SETS,
StatelessTracker::new(),
),
}
}