mirror of
https://github.com/gfx-rs/wgpu.git
synced 2025-12-08 21:26:17 +00:00
Add missing device validity checks
This commit is contained in:
parent
e10e17907f
commit
487f79ba44
@ -125,6 +125,8 @@ impl Global {
|
||||
list.push(TraceCommand::ClearBuffer { dst, offset, size });
|
||||
}
|
||||
|
||||
cmd_buf.device.check_is_valid()?;
|
||||
|
||||
let dst_buffer = hub.buffers.get(dst).get()?;
|
||||
|
||||
dst_buffer.same_device_as(cmd_buf.as_ref())?;
|
||||
@ -213,6 +215,8 @@ impl Global {
|
||||
});
|
||||
}
|
||||
|
||||
cmd_buf.device.check_is_valid()?;
|
||||
|
||||
if !cmd_buf.support_clear_texture {
|
||||
return Err(ClearError::MissingClearTextureFeature);
|
||||
}
|
||||
|
||||
@ -348,6 +348,13 @@ impl Global {
|
||||
match cmd_buf_data.lock_encoder() {
|
||||
Ok(()) => {
|
||||
drop(cmd_buf_data);
|
||||
if let Err(err) = cmd_buf.device.check_is_valid() {
|
||||
return (
|
||||
ComputePass::new_invalid(cmd_buf, &label, err.map_pass_err(scope)),
|
||||
None,
|
||||
);
|
||||
}
|
||||
|
||||
match desc
|
||||
.timestamp_writes
|
||||
.as_ref()
|
||||
|
||||
@ -1144,6 +1144,8 @@ impl Global {
|
||||
list.push(TraceCommand::PushDebugGroup(label.to_owned()));
|
||||
}
|
||||
|
||||
cmd_buf.device.check_is_valid()?;
|
||||
|
||||
let cmd_buf_raw = cmd_buf_data.encoder.open()?;
|
||||
if !cmd_buf
|
||||
.device
|
||||
@ -1177,6 +1179,8 @@ impl Global {
|
||||
list.push(TraceCommand::InsertDebugMarker(label.to_owned()));
|
||||
}
|
||||
|
||||
cmd_buf.device.check_is_valid()?;
|
||||
|
||||
if !cmd_buf
|
||||
.device
|
||||
.instance_flags
|
||||
@ -1209,6 +1213,8 @@ impl Global {
|
||||
list.push(TraceCommand::PopDebugGroup);
|
||||
}
|
||||
|
||||
cmd_buf.device.check_is_valid()?;
|
||||
|
||||
let cmd_buf_raw = cmd_buf_data.encoder.open()?;
|
||||
if !cmd_buf
|
||||
.device
|
||||
|
||||
@ -367,10 +367,6 @@ impl Global {
|
||||
.get(command_encoder_id.into_command_buffer_id());
|
||||
let mut cmd_buf_data = cmd_buf.data.lock();
|
||||
cmd_buf_data.record_with(|cmd_buf_data| -> Result<(), QueryError> {
|
||||
cmd_buf
|
||||
.device
|
||||
.require_features(wgt::Features::TIMESTAMP_QUERY_INSIDE_ENCODERS)?;
|
||||
|
||||
#[cfg(feature = "trace")]
|
||||
if let Some(ref mut list) = cmd_buf_data.commands {
|
||||
list.push(TraceCommand::WriteTimestamp {
|
||||
@ -379,9 +375,16 @@ impl Global {
|
||||
});
|
||||
}
|
||||
|
||||
cmd_buf.device.check_is_valid()?;
|
||||
|
||||
cmd_buf
|
||||
.device
|
||||
.require_features(wgt::Features::TIMESTAMP_QUERY_INSIDE_ENCODERS)?;
|
||||
|
||||
let raw_encoder = cmd_buf_data.encoder.open()?;
|
||||
|
||||
let query_set = hub.query_sets.get(query_set_id).get()?;
|
||||
query_set.same_device_as(cmd_buf.as_ref())?;
|
||||
|
||||
query_set.validate_and_write_timestamp(raw_encoder, query_index, None)?;
|
||||
|
||||
@ -418,6 +421,8 @@ impl Global {
|
||||
});
|
||||
}
|
||||
|
||||
cmd_buf.device.check_is_valid()?;
|
||||
|
||||
if destination_offset % wgt::QUERY_RESOLVE_BUFFER_ALIGNMENT != 0 {
|
||||
return Err(QueryError::Resolve(ResolveError::BufferOffsetAlignment));
|
||||
}
|
||||
|
||||
@ -77,6 +77,7 @@ impl Global {
|
||||
cmd_buf_data.record_with(
|
||||
|cmd_buf_data| -> Result<(), BuildAccelerationStructureError> {
|
||||
let device = &cmd_buf.device;
|
||||
device.check_is_valid()?;
|
||||
device
|
||||
.require_features(Features::EXPERIMENTAL_RAY_TRACING_ACCELERATION_STRUCTURE)?;
|
||||
|
||||
@ -214,6 +215,7 @@ impl Global {
|
||||
}
|
||||
|
||||
let device = &cmd_buf.device;
|
||||
device.check_is_valid()?;
|
||||
device.require_features(Features::EXPERIMENTAL_RAY_TRACING_ACCELERATION_STRUCTURE)?;
|
||||
|
||||
let mut buf_storage = Vec::new();
|
||||
|
||||
@ -1548,6 +1548,8 @@ impl Global {
|
||||
arc_desc: &mut ArcRenderPassDescriptor,
|
||||
device: &Device,
|
||||
) -> Result<(), RenderPassErrorInner> {
|
||||
device.check_is_valid()?;
|
||||
|
||||
let query_sets = hub.query_sets.read();
|
||||
let texture_views = hub.texture_views.read();
|
||||
|
||||
|
||||
@ -654,6 +654,10 @@ impl Global {
|
||||
trace.add(trace::Action::CreatePipelineLayout(fid.id(), desc.clone()));
|
||||
}
|
||||
|
||||
if let Err(e) = device.check_is_valid() {
|
||||
break 'error e.into();
|
||||
}
|
||||
|
||||
let bind_group_layouts = {
|
||||
let bind_group_layouts_guard = hub.bind_group_layouts.read();
|
||||
desc.bind_group_layouts
|
||||
@ -722,6 +726,10 @@ impl Global {
|
||||
trace.add(trace::Action::CreateBindGroup(fid.id(), desc.clone()));
|
||||
}
|
||||
|
||||
if let Err(e) = device.check_is_valid() {
|
||||
break 'error e.into();
|
||||
}
|
||||
|
||||
let layout = match hub.bind_group_layouts.get(desc.layout).get() {
|
||||
Ok(layout) => layout,
|
||||
Err(e) => break 'error e.into(),
|
||||
@ -1250,6 +1258,10 @@ impl Global {
|
||||
});
|
||||
}
|
||||
|
||||
if let Err(e) = device.check_is_valid() {
|
||||
break 'error e.into();
|
||||
}
|
||||
|
||||
let layout = desc
|
||||
.layout
|
||||
.map(|layout| hub.pipeline_layouts.get(layout).get())
|
||||
@ -1485,6 +1497,10 @@ impl Global {
|
||||
});
|
||||
}
|
||||
|
||||
if let Err(e) = device.check_is_valid() {
|
||||
break 'error e.into();
|
||||
}
|
||||
|
||||
let layout = desc
|
||||
.layout
|
||||
.map(|layout| hub.pipeline_layouts.get(layout).get())
|
||||
|
||||
@ -1445,6 +1445,7 @@ impl Queue {
|
||||
profiling::scope!("Queue::compact_blas");
|
||||
api_log!("Queue::compact_blas");
|
||||
|
||||
self.device.check_is_valid()?;
|
||||
self.same_device_as(blas.as_ref())?;
|
||||
|
||||
let device = blas.device.clone();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user