mirror of
https://github.com/gfx-rs/wgpu.git
synced 2024-11-22 06:44:14 +00:00
trace as soon as possible
This commit is contained in:
parent
fd52ec8997
commit
1a4f6aca6f
@ -159,11 +159,6 @@ impl Global {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if desc.usage.is_empty() {
|
|
||||||
// Per spec, `usage` must not be zero.
|
|
||||||
break 'error CreateBufferError::InvalidUsage(desc.usage);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(feature = "trace")]
|
#[cfg(feature = "trace")]
|
||||||
if let Some(ref mut trace) = *device.trace.lock() {
|
if let Some(ref mut trace) = *device.trace.lock() {
|
||||||
let mut desc = desc.clone();
|
let mut desc = desc.clone();
|
||||||
@ -174,6 +169,11 @@ impl Global {
|
|||||||
trace.add(trace::Action::CreateBuffer(fid.id(), desc));
|
trace.add(trace::Action::CreateBuffer(fid.id(), desc));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if desc.usage.is_empty() {
|
||||||
|
// Per spec, `usage` must not be zero.
|
||||||
|
break 'error CreateBufferError::InvalidUsage(desc.usage);
|
||||||
|
}
|
||||||
|
|
||||||
let buffer = match device.create_buffer(desc, false) {
|
let buffer = match device.create_buffer(desc, false) {
|
||||||
Ok(buffer) => buffer,
|
Ok(buffer) => buffer,
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
@ -381,15 +381,11 @@ impl Global {
|
|||||||
.devices
|
.devices
|
||||||
.get(device_id)
|
.get(device_id)
|
||||||
.map_err(|_| DeviceError::InvalidDeviceId)?;
|
.map_err(|_| DeviceError::InvalidDeviceId)?;
|
||||||
let snatch_guard = device.snatchable_lock.read();
|
|
||||||
device.check_is_valid()?;
|
|
||||||
|
|
||||||
let buffer = hub
|
let buffer = hub
|
||||||
.buffers
|
.buffers
|
||||||
.get(buffer_id)
|
.get(buffer_id)
|
||||||
.map_err(|_| BufferAccessError::InvalidBufferId(buffer_id))?;
|
.map_err(|_| BufferAccessError::InvalidBufferId(buffer_id))?;
|
||||||
buffer.check_usage(wgt::BufferUsages::MAP_WRITE)?;
|
|
||||||
//assert!(buffer isn't used by the GPU);
|
|
||||||
|
|
||||||
#[cfg(feature = "trace")]
|
#[cfg(feature = "trace")]
|
||||||
if let Some(ref mut trace) = *device.trace.lock() {
|
if let Some(ref mut trace) = *device.trace.lock() {
|
||||||
@ -402,6 +398,11 @@ impl Global {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
device.check_is_valid()?;
|
||||||
|
buffer.check_usage(wgt::BufferUsages::MAP_WRITE)?;
|
||||||
|
//assert!(buffer isn't used by the GPU);
|
||||||
|
|
||||||
|
let snatch_guard = device.snatchable_lock.read();
|
||||||
let raw_buf = buffer.try_raw(&snatch_guard)?;
|
let raw_buf = buffer.try_raw(&snatch_guard)?;
|
||||||
unsafe {
|
unsafe {
|
||||||
let mapping = device
|
let mapping = device
|
||||||
@ -565,6 +566,7 @@ impl Global {
|
|||||||
Ok(device) => device,
|
Ok(device) => device,
|
||||||
Err(_) => break 'error DeviceError::InvalidDeviceId.into(),
|
Err(_) => break 'error DeviceError::InvalidDeviceId.into(),
|
||||||
};
|
};
|
||||||
|
|
||||||
#[cfg(feature = "trace")]
|
#[cfg(feature = "trace")]
|
||||||
if let Some(ref mut trace) = *device.trace.lock() {
|
if let Some(ref mut trace) = *device.trace.lock() {
|
||||||
trace.add(trace::Action::CreateTexture(fid.id(), desc.clone()));
|
trace.add(trace::Action::CreateTexture(fid.id(), desc.clone()));
|
||||||
@ -808,12 +810,7 @@ impl Global {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
let device = &texture.device;
|
let device = &texture.device;
|
||||||
{
|
|
||||||
let snatch_guard = device.snatchable_lock.read();
|
|
||||||
if let Err(e) = texture.check_destroyed(&snatch_guard) {
|
|
||||||
break 'error e.into();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#[cfg(feature = "trace")]
|
#[cfg(feature = "trace")]
|
||||||
if let Some(ref mut trace) = *device.trace.lock() {
|
if let Some(ref mut trace) = *device.trace.lock() {
|
||||||
trace.add(trace::Action::CreateTextureView {
|
trace.add(trace::Action::CreateTextureView {
|
||||||
@ -823,6 +820,13 @@ impl Global {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
let snatch_guard = device.snatchable_lock.read();
|
||||||
|
if let Err(e) = texture.check_destroyed(&snatch_guard) {
|
||||||
|
break 'error e.into();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let view = match unsafe { device.create_texture_view(&texture, desc) } {
|
let view = match unsafe { device.create_texture_view(&texture, desc) } {
|
||||||
Ok(view) => view,
|
Ok(view) => view,
|
||||||
Err(e) => break 'error e,
|
Err(e) => break 'error e,
|
||||||
@ -1519,6 +1523,7 @@ impl Global {
|
|||||||
Ok(device) => device,
|
Ok(device) => device,
|
||||||
Err(_) => break 'error DeviceError::InvalidDeviceId.into(),
|
Err(_) => break 'error DeviceError::InvalidDeviceId.into(),
|
||||||
};
|
};
|
||||||
|
|
||||||
#[cfg(feature = "trace")]
|
#[cfg(feature = "trace")]
|
||||||
if let Some(ref mut trace) = *device.trace.lock() {
|
if let Some(ref mut trace) = *device.trace.lock() {
|
||||||
trace.add(trace::Action::CreateQuerySet {
|
trace.add(trace::Action::CreateQuerySet {
|
||||||
@ -1592,6 +1597,7 @@ impl Global {
|
|||||||
Ok(device) => device,
|
Ok(device) => device,
|
||||||
Err(_) => break 'error DeviceError::InvalidDeviceId.into(),
|
Err(_) => break 'error DeviceError::InvalidDeviceId.into(),
|
||||||
};
|
};
|
||||||
|
|
||||||
#[cfg(feature = "trace")]
|
#[cfg(feature = "trace")]
|
||||||
if let Some(ref mut trace) = *device.trace.lock() {
|
if let Some(ref mut trace) = *device.trace.lock() {
|
||||||
trace.add(trace::Action::CreateRenderPipeline {
|
trace.add(trace::Action::CreateRenderPipeline {
|
||||||
@ -1740,6 +1746,7 @@ impl Global {
|
|||||||
implicit_context: implicit_context.clone(),
|
implicit_context: implicit_context.clone(),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
let pipeline = match device.create_compute_pipeline(desc, implicit_context, hub) {
|
let pipeline = match device.create_compute_pipeline(desc, implicit_context, hub) {
|
||||||
Ok(pair) => pair,
|
Ok(pair) => pair,
|
||||||
Err(e) => break 'error e,
|
Err(e) => break 'error e,
|
||||||
@ -1866,6 +1873,7 @@ impl Global {
|
|||||||
// TODO: Handle error properly
|
// TODO: Handle error properly
|
||||||
Err(crate::storage::InvalidId) => break 'error DeviceError::InvalidDeviceId.into(),
|
Err(crate::storage::InvalidId) => break 'error DeviceError::InvalidDeviceId.into(),
|
||||||
};
|
};
|
||||||
|
|
||||||
#[cfg(feature = "trace")]
|
#[cfg(feature = "trace")]
|
||||||
if let Some(ref mut trace) = *device.trace.lock() {
|
if let Some(ref mut trace) = *device.trace.lock() {
|
||||||
trace.add(trace::Action::CreatePipelineCache {
|
trace.add(trace::Action::CreatePipelineCache {
|
||||||
@ -1873,6 +1881,7 @@ impl Global {
|
|||||||
desc: desc.clone(),
|
desc: desc.clone(),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
let cache = unsafe { device.create_pipeline_cache(desc) };
|
let cache = unsafe { device.create_pipeline_cache(desc) };
|
||||||
match cache {
|
match cache {
|
||||||
Ok(cache) => {
|
Ok(cache) => {
|
||||||
@ -2037,15 +2046,16 @@ impl Global {
|
|||||||
Ok(device) => device,
|
Ok(device) => device,
|
||||||
Err(_) => break 'error DeviceError::InvalidDeviceId.into(),
|
Err(_) => break 'error DeviceError::InvalidDeviceId.into(),
|
||||||
};
|
};
|
||||||
if let Err(e) = device.check_is_valid() {
|
|
||||||
break 'error e.into();
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(feature = "trace")]
|
#[cfg(feature = "trace")]
|
||||||
if let Some(ref mut trace) = *device.trace.lock() {
|
if let Some(ref mut trace) = *device.trace.lock() {
|
||||||
trace.add(trace::Action::ConfigureSurface(surface_id, config.clone()));
|
trace.add(trace::Action::ConfigureSurface(surface_id, config.clone()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if let Err(e) = device.check_is_valid() {
|
||||||
|
break 'error e.into();
|
||||||
|
}
|
||||||
|
|
||||||
let surface = match surface_guard.get(surface_id) {
|
let surface = match surface_guard.get(surface_id) {
|
||||||
Ok(surface) => surface,
|
Ok(surface) => surface,
|
||||||
Err(_) => break 'error E::InvalidSurface,
|
Err(_) => break 'error E::InvalidSurface,
|
||||||
|
@ -436,8 +436,6 @@ impl Global {
|
|||||||
|
|
||||||
let device = queue.device.as_ref().unwrap();
|
let device = queue.device.as_ref().unwrap();
|
||||||
|
|
||||||
buffer.same_device_as(queue.as_ref())?;
|
|
||||||
|
|
||||||
let data_size = data.len() as wgt::BufferAddress;
|
let data_size = data.len() as wgt::BufferAddress;
|
||||||
|
|
||||||
#[cfg(feature = "trace")]
|
#[cfg(feature = "trace")]
|
||||||
@ -451,6 +449,8 @@ impl Global {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
buffer.same_device_as(queue.as_ref())?;
|
||||||
|
|
||||||
if data_size == 0 {
|
if data_size == 0 {
|
||||||
log::trace!("Ignoring write_buffer of size 0");
|
log::trace!("Ignoring write_buffer of size 0");
|
||||||
return Ok(());
|
return Ok(());
|
||||||
@ -1197,8 +1197,6 @@ impl Global {
|
|||||||
Err(_) => continue,
|
Err(_) => continue,
|
||||||
};
|
};
|
||||||
|
|
||||||
cmdbuf.same_device_as(queue.as_ref())?;
|
|
||||||
|
|
||||||
#[cfg(feature = "trace")]
|
#[cfg(feature = "trace")]
|
||||||
if let Some(ref mut trace) = *device.trace.lock() {
|
if let Some(ref mut trace) = *device.trace.lock() {
|
||||||
trace.add(Action::Submit(
|
trace.add(Action::Submit(
|
||||||
@ -1213,6 +1211,9 @@ impl Global {
|
|||||||
.unwrap(),
|
.unwrap(),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cmdbuf.same_device_as(queue.as_ref())?;
|
||||||
|
|
||||||
if !cmdbuf.is_finished() {
|
if !cmdbuf.is_finished() {
|
||||||
let cmdbuf = Arc::into_inner(cmdbuf).expect(
|
let cmdbuf = Arc::into_inner(cmdbuf).expect(
|
||||||
"Command buffer cannot be destroyed because is still in use",
|
"Command buffer cannot be destroyed because is still in use",
|
||||||
|
@ -301,14 +301,15 @@ impl Global {
|
|||||||
};
|
};
|
||||||
|
|
||||||
let device = present.device.downcast_ref::<A>().unwrap();
|
let device = present.device.downcast_ref::<A>().unwrap();
|
||||||
device.check_is_valid()?;
|
|
||||||
let queue = device.get_queue().unwrap();
|
|
||||||
|
|
||||||
#[cfg(feature = "trace")]
|
#[cfg(feature = "trace")]
|
||||||
if let Some(ref mut trace) = *device.trace.lock() {
|
if let Some(ref mut trace) = *device.trace.lock() {
|
||||||
trace.add(Action::Present(surface_id));
|
trace.add(Action::Present(surface_id));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
device.check_is_valid()?;
|
||||||
|
let queue = device.get_queue().unwrap();
|
||||||
|
|
||||||
let result = {
|
let result = {
|
||||||
let texture_id = present
|
let texture_id = present
|
||||||
.acquired_texture
|
.acquired_texture
|
||||||
@ -393,13 +394,14 @@ impl Global {
|
|||||||
};
|
};
|
||||||
|
|
||||||
let device = present.device.downcast_ref::<A>().unwrap();
|
let device = present.device.downcast_ref::<A>().unwrap();
|
||||||
device.check_is_valid()?;
|
|
||||||
|
|
||||||
#[cfg(feature = "trace")]
|
#[cfg(feature = "trace")]
|
||||||
if let Some(ref mut trace) = *device.trace.lock() {
|
if let Some(ref mut trace) = *device.trace.lock() {
|
||||||
trace.add(Action::DiscardSurfaceTexture(surface_id));
|
trace.add(Action::DiscardSurfaceTexture(surface_id));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
device.check_is_valid()?;
|
||||||
|
|
||||||
{
|
{
|
||||||
let texture_id = present
|
let texture_id = present
|
||||||
.acquired_texture
|
.acquired_texture
|
||||||
|
Loading…
Reference in New Issue
Block a user