replace check_valid_to_use with ParentDevice.same_device checks

This commit is contained in:
teoxoy 2024-06-20 20:00:53 +02:00 committed by Teodor Tanasoaia
parent 06da3e88d0
commit 1b40c8c745

View File

@ -423,8 +423,7 @@ impl RenderBundleEncoder {
.write()
.add_single(bind_group);
self.check_valid_to_use(bind_group.device.info.id())
.map_pass_err(scope)?;
bind_group.same_device(device).map_pass_err(scope)?;
let max_bind_groups = device.limits.max_bind_groups;
if index >= max_bind_groups {
@ -492,8 +491,7 @@ impl RenderBundleEncoder {
.write()
.add_single(pipeline);
self.check_valid_to_use(pipeline.device.info.id())
.map_pass_err(scope)?;
pipeline.same_device(device).map_pass_err(scope)?;
self.context
.check_compatible(&pipeline.pass_context, RenderPassCompatibilityCheckType::RenderPipeline)
@ -541,8 +539,7 @@ impl RenderBundleEncoder {
.merge_single(buffer, hal::BufferUses::INDEX)
.map_pass_err(scope)?;
self.check_valid_to_use(buffer.device.info.id())
.map_pass_err(scope)?;
buffer.same_device(device).map_pass_err(scope)?;
buffer.check_usage(wgt::BufferUsages::INDEX).map_pass_err(scope)?;
let end = match size {
@ -584,8 +581,7 @@ impl RenderBundleEncoder {
.merge_single(buffer, hal::BufferUses::VERTEX)
.map_pass_err(scope)?;
self.check_valid_to_use(buffer.device.info.id())
.map_pass_err(scope)?;
buffer.same_device(device).map_pass_err(scope)?;
buffer.check_usage(wgt::BufferUsages::VERTEX).map_pass_err(scope)?;
let end = match size {
@ -715,8 +711,7 @@ impl RenderBundleEncoder {
.merge_single(buffer, hal::BufferUses::INDIRECT)
.map_pass_err(scope)?;
self.check_valid_to_use(buffer.device.info.id())
.map_pass_err(scope)?;
buffer.same_device(device).map_pass_err(scope)?;
buffer.check_usage(wgt::BufferUsages::INDIRECT).map_pass_err(scope)?;
buffer_memory_init_actions.extend(buffer.initialization_status.read().create_action(
@ -758,8 +753,7 @@ impl RenderBundleEncoder {
.merge_single(buffer, hal::BufferUses::INDIRECT)
.map_pass_err(scope)?;
self.check_valid_to_use(buffer.device.info.id())
.map_pass_err(scope)?;
buffer.same_device(device).map_pass_err(scope)?;
buffer.check_usage(wgt::BufferUsages::INDIRECT).map_pass_err(scope)?;
buffer_memory_init_actions.extend(buffer.initialization_status.read().create_action(
@ -821,14 +815,6 @@ impl RenderBundleEncoder {
})
}
fn check_valid_to_use(&self, device_id: id::DeviceId) -> Result<(), RenderBundleErrorInner> {
if device_id != self.parent_id {
return Err(RenderBundleErrorInner::NotValidToUse);
}
Ok(())
}
pub fn set_index_buffer(
&mut self,
buffer_id: id::BufferId,
@ -1486,8 +1472,6 @@ impl<A: HalApi> State<A> {
/// Error encountered when finishing recording a render bundle.
#[derive(Clone, Debug, Error)]
pub(super) enum RenderBundleErrorInner {
#[error("Resource is not valid to use with this render bundle because the resource and the bundle come from different devices")]
NotValidToUse,
#[error(transparent)]
Device(#[from] DeviceError),
#[error(transparent)]