mirror of
https://github.com/gfx-rs/wgpu.git
synced 2026-04-22 03:02:01 -04:00
build and clippy fixes, command buffer cleanup
This commit is contained in:
@@ -290,12 +290,6 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
|
||||
});
|
||||
}
|
||||
|
||||
if let Some(ref label) = base.label {
|
||||
unsafe {
|
||||
raw.begin_debug_marker(label);
|
||||
}
|
||||
}
|
||||
|
||||
let (_, mut token) = hub.render_bundles.read(&mut token);
|
||||
let (pipeline_layout_guard, mut token) = hub.pipeline_layouts.read(&mut token);
|
||||
let (bind_group_guard, mut token) = hub.bind_groups.read(&mut token);
|
||||
@@ -315,6 +309,11 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
|
||||
let mut string_offset = 0;
|
||||
let mut active_query = None;
|
||||
|
||||
let hal_desc = hal::ComputePassDescriptor { label: base.label };
|
||||
unsafe {
|
||||
raw.begin_compute_pass(&hal_desc);
|
||||
}
|
||||
|
||||
for command in base.commands {
|
||||
match *command {
|
||||
ComputeCommand::SetBindGroup {
|
||||
@@ -659,10 +658,8 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(_) = base.label {
|
||||
unsafe {
|
||||
raw.end_debug_marker();
|
||||
}
|
||||
unsafe {
|
||||
raw.end_compute_pass();
|
||||
}
|
||||
cmd_buf.status = CommandEncoderStatus::Recording;
|
||||
|
||||
|
||||
@@ -70,7 +70,6 @@ impl<A: HalApi> CommandBuffer<A> {
|
||||
#[cfg(feature = "trace")] enable_tracing: bool,
|
||||
#[cfg(debug_assertions)] label: &Label,
|
||||
) -> Self {
|
||||
use crate::LabelHelpers as _;
|
||||
CommandBuffer {
|
||||
raw: vec![raw],
|
||||
status: CommandEncoderStatus::Recording,
|
||||
@@ -89,7 +88,7 @@ impl<A: HalApi> CommandBuffer<A> {
|
||||
None
|
||||
},
|
||||
#[cfg(debug_assertions)]
|
||||
label: label.borrow_or_default().to_string(),
|
||||
label: crate::LabelHelpers::borrow_or_default(label).to_string(),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3448,6 +3448,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
|
||||
device.features,
|
||||
#[cfg(feature = "trace")]
|
||||
device.trace.is_some(),
|
||||
#[cfg(debug_assertions)]
|
||||
&desc.label,
|
||||
);
|
||||
|
||||
@@ -4412,14 +4413,14 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
|
||||
#[cfg(feature = "trace")]
|
||||
if let Some(ref trace) = device.trace {
|
||||
let mut trace = trace.lock();
|
||||
let size = sub_range.size_to(buffer.size);
|
||||
let size = range.end - range.start;
|
||||
let data = trace.make_binary("bin", unsafe {
|
||||
std::slice::from_raw_parts(ptr.as_ptr(), size as usize)
|
||||
});
|
||||
trace.add(trace::Action::WriteBuffer {
|
||||
id: buffer_id,
|
||||
data,
|
||||
range: sub_range.offset..sub_range.offset + size,
|
||||
range: range.clone(),
|
||||
queued: false,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -68,9 +68,9 @@ impl<A: hal::Api> PendingWrites<A> {
|
||||
}
|
||||
|
||||
pub fn dispose(self, device: &A::Device) {
|
||||
if let Some(raw) = self.command_buffer {
|
||||
if let Some(cmd_buf) = self.command_buffer {
|
||||
unsafe {
|
||||
device.destroy_command_buffer(raw);
|
||||
device.destroy_command_buffer(cmd_buf);
|
||||
}
|
||||
}
|
||||
for resource in self.temp_resources {
|
||||
@@ -91,6 +91,7 @@ impl<A: hal::Api> PendingWrites<A> {
|
||||
|
||||
fn consume(&mut self, stage: StagingData<A>) {
|
||||
self.temp_resources.push(TempResource::Buffer(stage.buffer));
|
||||
assert!(self.command_buffer.is_none());
|
||||
self.command_buffer = Some(stage.cmdbuf);
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ pub(crate) fn new_render_bundle_encoder_descriptor<'a>(
|
||||
label,
|
||||
color_formats: Cow::Borrowed(&context.attachments.colors),
|
||||
depth_stencil_format: context.attachments.depth_stencil,
|
||||
sample_count: context.sample_count as u32,
|
||||
sample_count: context.sample_count,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -269,6 +269,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
|
||||
.take()
|
||||
.ok_or(SwapChainError::AlreadyAcquired)?;
|
||||
let (view_maybe, _) = hub.texture_views.unregister(view_id.value.0, &mut token);
|
||||
drop(view_id); // contains the ref count
|
||||
let view = view_maybe.ok_or(SwapChainError::Invalid)?;
|
||||
if view.life_guard.ref_count.unwrap().load() != 1 {
|
||||
return Err(SwapChainError::StillReferenced);
|
||||
|
||||
@@ -10,7 +10,7 @@ impl super::CommandBuffer {
|
||||
self.blit.as_ref().unwrap()
|
||||
}
|
||||
|
||||
fn leave_blit(&mut self) {
|
||||
pub(super) fn leave_blit(&mut self) {
|
||||
if let Some(encoder) = self.blit.take() {
|
||||
encoder.end_encoding();
|
||||
}
|
||||
@@ -22,11 +22,7 @@ impl super::CommandBuffer {
|
||||
} else if let Some(ref encoder) = self.compute {
|
||||
encoder
|
||||
} else {
|
||||
if self.blit.is_none() {
|
||||
debug_assert!(self.render.is_none() && self.compute.is_none());
|
||||
self.blit = Some(self.raw.new_blit_command_encoder().to_owned());
|
||||
}
|
||||
self.blit.as_ref().unwrap()
|
||||
self.enter_blit()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -361,7 +361,9 @@ impl crate::Device<super::Api> for super::Device {
|
||||
disabilities: self.shared.disabilities.clone(),
|
||||
})
|
||||
}
|
||||
unsafe fn destroy_command_buffer(&self, _cmd_buf: super::CommandBuffer) {}
|
||||
unsafe fn destroy_command_buffer(&self, mut cmd_buf: super::CommandBuffer) {
|
||||
cmd_buf.leave_blit();
|
||||
}
|
||||
|
||||
unsafe fn create_bind_group_layout(
|
||||
&self,
|
||||
|
||||
Reference in New Issue
Block a user