use Arc::ptr_eq for resource equality

This commit is contained in:
teoxoy 2024-06-19 15:06:44 +02:00 committed by Teodor Tanasoaia
parent a21bbdccf0
commit 0c4b449644
3 changed files with 14 additions and 15 deletions

View File

@ -1414,7 +1414,7 @@ impl<A: HalApi> State<A> {
) {
match self.index {
Some(ref current)
if Arc::ptr_eq(&current.buffer, &buffer)
if current.buffer.is_equal(&buffer)
&& current.format == format
&& current.range == range =>
{

View File

@ -85,7 +85,7 @@ impl<A: HalApi> CommandBufferTextureMemoryActions<A> {
// self.discards is empty!)
let init_actions = &mut self.init_actions;
self.discards.retain(|discarded_surface| {
if discarded_surface.texture.as_info().id() == action.texture.as_info().id()
if discarded_surface.texture.is_equal(&action.texture)
&& action.range.layer_range.contains(&discarded_surface.layer)
&& action
.range

View File

@ -159,7 +159,8 @@ pub(crate) trait ParentDevice<A: HalApi>: Resource {
fn device(&self) -> &Arc<Device<A>>;
fn same_device_as<O: ParentDevice<A>>(&self, other: &O) -> Result<(), DeviceError> {
Arc::ptr_eq(self.device(), other.device())
self.device()
.is_equal(other.device())
.then_some(())
.ok_or_else(|| {
DeviceError::DeviceMismatch(Box::new(DeviceMismatch {
@ -172,16 +173,14 @@ pub(crate) trait ParentDevice<A: HalApi>: Resource {
}
fn same_device(&self, device: &Arc<Device<A>>) -> Result<(), DeviceError> {
Arc::ptr_eq(self.device(), device)
.then_some(())
.ok_or_else(|| {
DeviceError::DeviceMismatch(Box::new(DeviceMismatch {
res: self.error_ident(),
res_device: self.device().error_ident(),
target: None,
target_device: device.error_ident(),
}))
})
self.device().is_equal(device).then_some(()).ok_or_else(|| {
DeviceError::DeviceMismatch(Box::new(DeviceMismatch {
res: self.error_ident(),
res_device: self.device().error_ident(),
target: None,
target_device: device.error_ident(),
}))
})
}
}
@ -208,8 +207,8 @@ pub(crate) trait Resource: 'static + Sized + WasmNotSendSync {
fn is_unique(self: &Arc<Self>) -> bool {
self.ref_count() == 1
}
fn is_equal(&self, other: &Self) -> bool {
self.as_info().id().unzip() == other.as_info().id().unzip()
fn is_equal(self: &Arc<Self>, other: &Arc<Self>) -> bool {
Arc::ptr_eq(self, other)
}
fn error_ident(&self) -> ResourceErrorIdent {
ResourceErrorIdent {