mirror of
https://github.com/gfx-rs/wgpu.git
synced 2026-04-22 03:02:01 -04:00
Merge #847
847: Gecko-requested refactor r=cwfitzgerald a=kvark Co-authored-by: Dzmitry Malyshau <dmalyshau@mozilla.com>
This commit is contained in:
63
Cargo.lock
generated
63
Cargo.lock
generated
@@ -196,6 +196,21 @@ dependencies = [
|
||||
"objc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cocoa-foundation"
|
||||
version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7ade49b65d560ca58c403a479bb396592b155c0185eada742ee323d1d68d6318"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"block",
|
||||
"core-foundation 0.9.0",
|
||||
"core-graphics-types",
|
||||
"foreign-types",
|
||||
"libc",
|
||||
"objc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "copyless"
|
||||
version = "0.1.5"
|
||||
@@ -222,6 +237,16 @@ dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "core-foundation"
|
||||
version = "0.9.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3b5ed8e7e76c45974e15e41bfa8d5b0483cd90191639e01d8f5f1e606299d3fb"
|
||||
dependencies = [
|
||||
"core-foundation-sys 0.8.0",
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "core-foundation-sys"
|
||||
version = "0.6.2"
|
||||
@@ -234,6 +259,12 @@ version = "0.7.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b3a71ab494c0b5b860bdc8407ae08978052417070c2ced38573a9157ad75b8ac"
|
||||
|
||||
[[package]]
|
||||
name = "core-foundation-sys"
|
||||
version = "0.8.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9a21fa21941700a3cd8fcb4091f361a6a712fac632f85d9f487cc892045d55c6"
|
||||
|
||||
[[package]]
|
||||
name = "core-graphics"
|
||||
version = "0.19.0"
|
||||
@@ -246,6 +277,18 @@ dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "core-graphics-types"
|
||||
version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e92f5d519093a4178296707dbaa3880eae85a5ef5386675f361a1cf25376e93c"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"core-foundation 0.9.0",
|
||||
"foreign-types",
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "core-video-sys"
|
||||
version = "0.1.4"
|
||||
@@ -445,16 +488,15 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "gfx-backend-metal"
|
||||
version = "0.5.4"
|
||||
version = "0.5.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "412a1e0e53e9e325a7c2e0316f1a4e8a14cbe8d8bfb5f030bc3895692f8a8254"
|
||||
checksum = "92804d20b194de6c84cb4bec14ec6a6dcae9c51f0a9186817fb412a590131ae6"
|
||||
dependencies = [
|
||||
"arrayvec",
|
||||
"bitflags",
|
||||
"block",
|
||||
"cocoa",
|
||||
"cocoa-foundation",
|
||||
"copyless",
|
||||
"core-graphics",
|
||||
"foreign-types",
|
||||
"gfx-auxil",
|
||||
"gfx-hal",
|
||||
@@ -472,14 +514,14 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "gfx-backend-vulkan"
|
||||
version = "0.5.9"
|
||||
version = "0.5.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5f2e8bb53e5bea0bfec7035462a75717cd04d733963a225c816339a671ef108b"
|
||||
checksum = "aec9c919cfc236d2c36aaa38609c1906a92f2df99a3c7f53022b01936f98275a"
|
||||
dependencies = [
|
||||
"arrayvec",
|
||||
"ash",
|
||||
"byteorder",
|
||||
"core-graphics",
|
||||
"core-graphics-types",
|
||||
"gfx-hal",
|
||||
"lazy_static",
|
||||
"log",
|
||||
@@ -721,14 +763,13 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "metal"
|
||||
version = "0.18.0"
|
||||
version = "0.20.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e198a0ee42bdbe9ef2c09d0b9426f3b2b47d90d93a4a9b0395c4cea605e92dc0"
|
||||
checksum = "5c4e8a431536529327e28c9ba6992f2cb0c15d4222f0602a16e6d7695ff3bccf"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"block",
|
||||
"cocoa",
|
||||
"core-graphics",
|
||||
"cocoa-foundation",
|
||||
"foreign-types",
|
||||
"log",
|
||||
"objc",
|
||||
|
||||
@@ -311,8 +311,8 @@ impl GlobalPlay for wgc::hub::Global<IdentityPassThroughFactory> {
|
||||
&wgt::CommandEncoderDescriptor { label: ptr::null() },
|
||||
comb_manager.alloc(device.backend()),
|
||||
);
|
||||
let comb = self.encode_commands::<B>(encoder, commands);
|
||||
self.queue_submit::<B>(device, &[comb]).unwrap();
|
||||
let cmdbuf = self.encode_commands::<B>(encoder, commands);
|
||||
self.queue_submit::<B>(device, &[cmdbuf]).unwrap();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,16 +59,16 @@ package = "wgpu-types"
|
||||
version = "0.5"
|
||||
|
||||
[target.'cfg(any(target_os = "ios", target_os = "macos"))'.dependencies]
|
||||
gfx-backend-metal = { version = "0.5.4" }
|
||||
gfx-backend-vulkan = { version = "0.5.9", optional = true }
|
||||
gfx-backend-metal = { version = "0.5.6" }
|
||||
gfx-backend-vulkan = { version = "0.5.11", optional = true }
|
||||
|
||||
[target.'cfg(all(unix, not(target_os = "ios"), not(target_os = "macos")))'.dependencies]
|
||||
gfx-backend-vulkan = { version = "0.5.9" }
|
||||
gfx-backend-vulkan = { version = "0.5.11" }
|
||||
|
||||
[target.'cfg(windows)'.dependencies]
|
||||
gfx-backend-dx12 = { version = "0.5.8" }
|
||||
gfx-backend-dx11 = { version = "0.5" }
|
||||
gfx-backend-vulkan = { version = "0.5.9" }
|
||||
gfx-backend-vulkan = { version = "0.5.11" }
|
||||
|
||||
[target.'cfg(any(target_os = "linux", target_os = "macos", target_os = "windows", target_os = "dragonfly", target_os = "freebsd"))'.dependencies]
|
||||
battery = { version = "0.7", optional = true }
|
||||
|
||||
@@ -29,7 +29,7 @@ impl<B: hal::Backend> CommandPool<B> {
|
||||
if self.pending[i].1 <= last_done_index {
|
||||
let (cmd_buf, index) = self.pending.swap_remove(i);
|
||||
tracing::trace!(
|
||||
"recycling comb submitted in {} when {} is last done",
|
||||
"recycling cmdbuf submitted in {} when {} is last done",
|
||||
index,
|
||||
last_done_index,
|
||||
);
|
||||
|
||||
@@ -126,7 +126,7 @@ impl RenderBundle {
|
||||
/// a chance to go through the commands in `render_bundle_encoder_finish`.
|
||||
pub(crate) unsafe fn execute<B: GfxBackend>(
|
||||
&self,
|
||||
comb: &mut B::CommandBuffer,
|
||||
cmdbuf: &mut B::CommandBuffer,
|
||||
pipeline_layout_guard: &Storage<
|
||||
crate::binding_model::PipelineLayout<B>,
|
||||
id::PipelineLayoutId,
|
||||
@@ -149,7 +149,7 @@ impl RenderBundle {
|
||||
bind_group_id,
|
||||
} => {
|
||||
let bind_group = &bind_group_guard[bind_group_id];
|
||||
comb.bind_graphics_descriptor_sets(
|
||||
cmdbuf.bind_graphics_descriptor_sets(
|
||||
&pipeline_layout_guard[pipeline_layout_id.unwrap()].raw,
|
||||
index as usize,
|
||||
iter::once(bind_group.raw.raw()),
|
||||
@@ -159,7 +159,7 @@ impl RenderBundle {
|
||||
}
|
||||
RenderCommand::SetPipeline(pipeline_id) => {
|
||||
let pipeline = &pipeline_guard[pipeline_id];
|
||||
comb.bind_graphics_pipeline(&pipeline.raw);
|
||||
cmdbuf.bind_graphics_pipeline(&pipeline.raw);
|
||||
index_type = conv::map_index_format(pipeline.index_format);
|
||||
pipeline_layout_id = Some(pipeline.layout_id.value);
|
||||
}
|
||||
@@ -178,7 +178,7 @@ impl RenderBundle {
|
||||
index_type,
|
||||
};
|
||||
|
||||
comb.bind_index_buffer(view);
|
||||
cmdbuf.bind_index_buffer(view);
|
||||
}
|
||||
RenderCommand::SetVertexBuffer {
|
||||
slot,
|
||||
@@ -191,7 +191,7 @@ impl RenderBundle {
|
||||
offset,
|
||||
size: size.map(|s| s.get()),
|
||||
};
|
||||
comb.bind_vertex_buffers(slot, iter::once((&buffer.raw, range)));
|
||||
cmdbuf.bind_vertex_buffers(slot, iter::once((&buffer.raw, range)));
|
||||
}
|
||||
RenderCommand::SetPushConstant {
|
||||
stages,
|
||||
@@ -208,7 +208,7 @@ impl RenderBundle {
|
||||
let data_slice = &self.base.push_constant_data
|
||||
[(values_offset as usize)..values_end_offset];
|
||||
|
||||
comb.push_graphics_constants(
|
||||
cmdbuf.push_graphics_constants(
|
||||
&pipeline_layout.raw,
|
||||
conv::map_shader_stage_flags(stages),
|
||||
offset,
|
||||
@@ -219,7 +219,7 @@ impl RenderBundle {
|
||||
offset,
|
||||
size_bytes,
|
||||
|clear_offset, clear_data| {
|
||||
comb.push_graphics_constants(
|
||||
cmdbuf.push_graphics_constants(
|
||||
&pipeline_layout.raw,
|
||||
conv::map_shader_stage_flags(stages),
|
||||
clear_offset,
|
||||
@@ -235,7 +235,7 @@ impl RenderBundle {
|
||||
first_vertex,
|
||||
first_instance,
|
||||
} => {
|
||||
comb.draw(
|
||||
cmdbuf.draw(
|
||||
first_vertex..first_vertex + vertex_count,
|
||||
first_instance..first_instance + instance_count,
|
||||
);
|
||||
@@ -247,7 +247,7 @@ impl RenderBundle {
|
||||
base_vertex,
|
||||
first_instance,
|
||||
} => {
|
||||
comb.draw_indexed(
|
||||
cmdbuf.draw_indexed(
|
||||
first_index..first_index + index_count,
|
||||
base_vertex,
|
||||
first_instance..first_instance + instance_count,
|
||||
@@ -260,7 +260,7 @@ impl RenderBundle {
|
||||
indexed: false,
|
||||
} => {
|
||||
let buffer = &buffer_guard[buffer_id];
|
||||
comb.draw_indirect(&buffer.raw, offset, 1, 0);
|
||||
cmdbuf.draw_indirect(&buffer.raw, offset, 1, 0);
|
||||
}
|
||||
RenderCommand::MultiDrawIndirect {
|
||||
buffer_id,
|
||||
@@ -269,7 +269,7 @@ impl RenderBundle {
|
||||
indexed: true,
|
||||
} => {
|
||||
let buffer = &buffer_guard[buffer_id];
|
||||
comb.draw_indexed_indirect(&buffer.raw, offset, 1, 0);
|
||||
cmdbuf.draw_indexed_indirect(&buffer.raw, offset, 1, 0);
|
||||
}
|
||||
RenderCommand::MultiDrawIndirect { .. }
|
||||
| RenderCommand::MultiDrawIndirectCount { .. } => unimplemented!(),
|
||||
|
||||
@@ -161,20 +161,20 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
|
||||
let (swap_chain_guard, mut token) = hub.swap_chains.read(&mut token);
|
||||
//TODO: actually close the last recorded command buffer
|
||||
let (mut comb_guard, _) = hub.command_buffers.write(&mut token);
|
||||
let comb = &mut comb_guard[encoder_id];
|
||||
if !comb.is_recording {
|
||||
let cmdbuf = &mut comb_guard[encoder_id];
|
||||
if !cmdbuf.is_recording {
|
||||
return Err(CommandEncoderFinishError::NotRecording);
|
||||
}
|
||||
comb.is_recording = false;
|
||||
cmdbuf.is_recording = false;
|
||||
// stop tracking the swapchain image, if used
|
||||
if let Some((ref sc_id, _)) = comb.used_swap_chain {
|
||||
if let Some((ref sc_id, _)) = cmdbuf.used_swap_chain {
|
||||
let view_id = swap_chain_guard[sc_id.value]
|
||||
.acquired_view_id
|
||||
.as_ref()
|
||||
.expect("Used swap chain frame has already presented");
|
||||
comb.trackers.views.remove(view_id.value);
|
||||
cmdbuf.trackers.views.remove(view_id.value);
|
||||
}
|
||||
tracing::trace!("Command buffer {:?} {:#?}", encoder_id, comb.trackers);
|
||||
tracing::trace!("Command buffer {:?} {:#?}", encoder_id, cmdbuf.trackers);
|
||||
Ok(encoder_id)
|
||||
}
|
||||
|
||||
|
||||
@@ -516,7 +516,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
|
||||
let mut trackers = TrackerSet::new(B::VARIANT);
|
||||
let cmb = &mut cmb_guard[encoder_id];
|
||||
let device = &device_guard[cmb.device_id.value];
|
||||
let mut raw = device.com_allocator.extend(cmb);
|
||||
let mut raw = device.cmd_allocator.extend(cmb);
|
||||
|
||||
#[cfg(feature = "trace")]
|
||||
match cmb.commands {
|
||||
|
||||
@@ -184,7 +184,7 @@ pub struct Device<B: hal::Backend> {
|
||||
pub(crate) raw: B::Device,
|
||||
pub(crate) adapter_id: Stored<id::AdapterId>,
|
||||
pub(crate) queue_group: hal::queue::QueueGroup<B>,
|
||||
pub(crate) com_allocator: command::CommandAllocator<B>,
|
||||
pub(crate) cmd_allocator: command::CommandAllocator<B>,
|
||||
mem_allocator: Mutex<Heaps<B>>,
|
||||
desc_allocator: Mutex<DescriptorAllocator<B>>,
|
||||
//Note: The submission index here corresponds to the last submission that is done.
|
||||
@@ -218,7 +218,7 @@ impl<B: GfxBackend> Device<B> {
|
||||
desc: &wgt::DeviceDescriptor,
|
||||
trace_path: Option<&std::path::Path>,
|
||||
) -> Self {
|
||||
let com_allocator = command::CommandAllocator::new(queue_group.family, &raw);
|
||||
let cmd_allocator = command::CommandAllocator::new(queue_group.family, &raw);
|
||||
let heaps = unsafe {
|
||||
Heaps::new(
|
||||
&mem_props,
|
||||
@@ -243,7 +243,7 @@ impl<B: GfxBackend> Device<B> {
|
||||
Device {
|
||||
raw,
|
||||
adapter_id,
|
||||
com_allocator,
|
||||
cmd_allocator,
|
||||
mem_allocator: Mutex::new(heaps),
|
||||
desc_allocator: Mutex::new(descriptors),
|
||||
queue_group,
|
||||
@@ -318,7 +318,7 @@ impl<B: GfxBackend> Device<B> {
|
||||
self.life_guard
|
||||
.submission_index
|
||||
.store(last_done, Ordering::Release);
|
||||
self.com_allocator.maintain(&self.raw, last_done);
|
||||
self.cmd_allocator.maintain(&self.raw, last_done);
|
||||
Ok(callbacks)
|
||||
}
|
||||
|
||||
@@ -644,8 +644,8 @@ impl<B: hal::Backend> Device<B> {
|
||||
let mut desc_alloc = self.desc_allocator.into_inner();
|
||||
let mut mem_alloc = self.mem_allocator.into_inner();
|
||||
self.pending_writes
|
||||
.dispose(&self.raw, &self.com_allocator, &mut mem_alloc);
|
||||
self.com_allocator.destroy(&self.raw);
|
||||
.dispose(&self.raw, &self.cmd_allocator, &mut mem_alloc);
|
||||
self.cmd_allocator.destroy(&self.raw);
|
||||
unsafe {
|
||||
desc_alloc.clear(&self.raw);
|
||||
mem_alloc.clear(&self.raw);
|
||||
@@ -2047,7 +2047,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
|
||||
ref_count: device.life_guard.add_ref(),
|
||||
};
|
||||
|
||||
let mut command_buffer = device.com_allocator.allocate(
|
||||
let mut command_buffer = device.cmd_allocator.allocate(
|
||||
dev_stored,
|
||||
&device.raw,
|
||||
device.limits.clone(),
|
||||
@@ -2078,14 +2078,14 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
|
||||
let mut token = Token::root();
|
||||
|
||||
let (mut device_guard, mut token) = hub.devices.write(&mut token);
|
||||
let comb = {
|
||||
let cmdbuf = {
|
||||
let (mut command_buffer_guard, _) = hub.command_buffers.write(&mut token);
|
||||
command_buffer_guard.remove(command_encoder_id).unwrap()
|
||||
};
|
||||
|
||||
let device = &mut device_guard[comb.device_id.value];
|
||||
device.untrack::<G>(&hub, &comb.trackers, &mut token);
|
||||
device.com_allocator.discard(comb);
|
||||
let device = &mut device_guard[cmdbuf.device_id.value];
|
||||
device.untrack::<G>(&hub, &cmdbuf.trackers, &mut token);
|
||||
device.cmd_allocator.discard(cmdbuf);
|
||||
}
|
||||
|
||||
pub fn command_buffer_destroy<B: GfxBackend>(&self, command_buffer_id: id::CommandBufferId) {
|
||||
@@ -2987,14 +2987,14 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
|
||||
families: None,
|
||||
};
|
||||
unsafe {
|
||||
let comb = device.borrow_pending_writes();
|
||||
comb.pipeline_barrier(
|
||||
let cmdbuf = device.borrow_pending_writes();
|
||||
cmdbuf.pipeline_barrier(
|
||||
hal::pso::PipelineStage::HOST..hal::pso::PipelineStage::TRANSFER,
|
||||
hal::memory::Dependencies::empty(),
|
||||
iter::once(transition_src).chain(iter::once(transition_dst)),
|
||||
);
|
||||
if buffer.size > 0 {
|
||||
comb.copy_buffer(&stage_buffer, &buffer.raw, iter::once(region));
|
||||
cmdbuf.copy_buffer(&stage_buffer, &buffer.raw, iter::once(region));
|
||||
}
|
||||
}
|
||||
device
|
||||
|
||||
@@ -26,7 +26,7 @@ use thiserror::Error;
|
||||
struct StagingData<B: hal::Backend> {
|
||||
buffer: B::Buffer,
|
||||
memory: MemoryBlock<B>,
|
||||
comb: B::CommandBuffer,
|
||||
cmdbuf: B::CommandBuffer,
|
||||
}
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
@@ -46,11 +46,11 @@ impl<B: hal::Backend> PendingWrites<B> {
|
||||
pub fn dispose(
|
||||
self,
|
||||
device: &B::Device,
|
||||
com_allocator: &CommandAllocator<B>,
|
||||
cmd_allocator: &CommandAllocator<B>,
|
||||
mem_allocator: &mut Heaps<B>,
|
||||
) {
|
||||
if let Some(raw) = self.command_buffer {
|
||||
com_allocator.discard_internal(raw);
|
||||
cmd_allocator.discard_internal(raw);
|
||||
}
|
||||
for (buffer, memory) in self.temp_buffers {
|
||||
mem_allocator.free(device, memory);
|
||||
@@ -66,18 +66,18 @@ impl<B: hal::Backend> PendingWrites<B> {
|
||||
|
||||
fn consume(&mut self, stage: StagingData<B>) {
|
||||
self.temp_buffers.push((stage.buffer, stage.memory));
|
||||
self.command_buffer = Some(stage.comb);
|
||||
self.command_buffer = Some(stage.cmdbuf);
|
||||
}
|
||||
}
|
||||
|
||||
impl<B: hal::Backend> super::Device<B> {
|
||||
pub fn borrow_pending_writes(&mut self) -> &mut B::CommandBuffer {
|
||||
if self.pending_writes.command_buffer.is_none() {
|
||||
let mut comb = self.com_allocator.allocate_internal();
|
||||
let mut cmdbuf = self.cmd_allocator.allocate_internal();
|
||||
unsafe {
|
||||
comb.begin_primary(hal::command::CommandBufferFlags::ONE_TIME_SUBMIT);
|
||||
cmdbuf.begin_primary(hal::command::CommandBufferFlags::ONE_TIME_SUBMIT);
|
||||
}
|
||||
self.pending_writes.command_buffer = Some(comb);
|
||||
self.pending_writes.command_buffer = Some(cmdbuf);
|
||||
}
|
||||
self.pending_writes.command_buffer.as_mut().unwrap()
|
||||
}
|
||||
@@ -113,20 +113,20 @@ impl<B: hal::Backend> super::Device<B> {
|
||||
})?;
|
||||
}
|
||||
|
||||
let comb = match self.pending_writes.command_buffer.take() {
|
||||
Some(comb) => comb,
|
||||
let cmdbuf = match self.pending_writes.command_buffer.take() {
|
||||
Some(cmdbuf) => cmdbuf,
|
||||
None => {
|
||||
let mut comb = self.com_allocator.allocate_internal();
|
||||
let mut cmdbuf = self.cmd_allocator.allocate_internal();
|
||||
unsafe {
|
||||
comb.begin_primary(hal::command::CommandBufferFlags::ONE_TIME_SUBMIT);
|
||||
cmdbuf.begin_primary(hal::command::CommandBufferFlags::ONE_TIME_SUBMIT);
|
||||
}
|
||||
comb
|
||||
cmdbuf
|
||||
}
|
||||
};
|
||||
Ok(StagingData {
|
||||
buffer,
|
||||
memory,
|
||||
comb,
|
||||
cmdbuf,
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -215,7 +215,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
|
||||
size: data.len() as _,
|
||||
};
|
||||
unsafe {
|
||||
stage.comb.pipeline_barrier(
|
||||
stage.cmdbuf.pipeline_barrier(
|
||||
super::all_buffer_stages()..hal::pso::PipelineStage::TRANSFER,
|
||||
hal::memory::Dependencies::empty(),
|
||||
iter::once(hal::memory::Barrier::Buffer {
|
||||
@@ -227,7 +227,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
|
||||
.chain(transition.map(|pending| pending.into_hal(dst))),
|
||||
);
|
||||
stage
|
||||
.comb
|
||||
.cmdbuf
|
||||
.copy_buffer(&stage.buffer, &dst.raw, iter::once(region));
|
||||
}
|
||||
|
||||
@@ -346,7 +346,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
|
||||
image_extent: conv::map_extent(size, dst.dimension),
|
||||
};
|
||||
unsafe {
|
||||
stage.comb.pipeline_barrier(
|
||||
stage.cmdbuf.pipeline_barrier(
|
||||
super::all_image_stages() | hal::pso::PipelineStage::HOST
|
||||
..hal::pso::PipelineStage::TRANSFER,
|
||||
hal::memory::Dependencies::empty(),
|
||||
@@ -358,7 +358,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
|
||||
})
|
||||
.chain(transition.map(|pending| pending.into_hal(dst))),
|
||||
);
|
||||
stage.comb.copy_buffer_to_image(
|
||||
stage.cmdbuf.copy_buffer_to_image(
|
||||
&stage.buffer,
|
||||
&dst.raw,
|
||||
hal::image::Layout::TransferDstOptimal,
|
||||
@@ -420,32 +420,35 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
|
||||
|
||||
// finish all the command buffers first
|
||||
for &cmb_id in command_buffer_ids {
|
||||
let comb = &mut command_buffer_guard[cmb_id];
|
||||
let cmdbuf = &mut command_buffer_guard[cmb_id];
|
||||
#[cfg(feature = "trace")]
|
||||
match device.trace {
|
||||
Some(ref trace) => trace
|
||||
.lock()
|
||||
.add(Action::Submit(submit_index, comb.commands.take().unwrap())),
|
||||
.add(Action::Submit(submit_index, cmdbuf.commands.take().unwrap())),
|
||||
None => (),
|
||||
};
|
||||
|
||||
if let Some((sc_id, fbo)) = comb.used_swap_chain.take() {
|
||||
if let Some((sc_id, fbo)) = cmdbuf.used_swap_chain.take() {
|
||||
let sc = &mut swap_chain_guard[sc_id.value];
|
||||
sc.active_submission_index = submit_index;
|
||||
if sc.acquired_view_id.is_none() {
|
||||
return Err(QueueSubmitError::SwapChainOutputDropped);
|
||||
}
|
||||
// For each swapchain, we only want to have at most 1 signaled semaphore.
|
||||
if sc.acquired_framebuffers.is_empty() {
|
||||
// Only add a signal if this is the first time for this swapchain
|
||||
// to be used in the submission.
|
||||
signal_swapchain_semaphores.push(sc_id.value);
|
||||
}
|
||||
sc.acquired_framebuffers.push(fbo);
|
||||
}
|
||||
|
||||
// optimize the tracked states
|
||||
comb.trackers.optimize();
|
||||
cmdbuf.trackers.optimize();
|
||||
|
||||
// update submission IDs
|
||||
for id in comb.trackers.buffers.used() {
|
||||
for id in cmdbuf.trackers.buffers.used() {
|
||||
let buffer = &mut buffer_guard[id];
|
||||
if !buffer.life_guard.use_at(submit_index) {
|
||||
if let BufferMapState::Active { .. } = buffer.map_state {
|
||||
@@ -460,42 +463,42 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
|
||||
}
|
||||
}
|
||||
}
|
||||
for id in comb.trackers.textures.used() {
|
||||
for id in cmdbuf.trackers.textures.used() {
|
||||
if !texture_guard[id].life_guard.use_at(submit_index) {
|
||||
device.temp_suspected.textures.push(id);
|
||||
}
|
||||
}
|
||||
for id in comb.trackers.views.used() {
|
||||
for id in cmdbuf.trackers.views.used() {
|
||||
if !texture_view_guard[id].life_guard.use_at(submit_index) {
|
||||
device.temp_suspected.texture_views.push(id);
|
||||
}
|
||||
}
|
||||
for id in comb.trackers.bind_groups.used() {
|
||||
for id in cmdbuf.trackers.bind_groups.used() {
|
||||
if !bind_group_guard[id].life_guard.use_at(submit_index) {
|
||||
device.temp_suspected.bind_groups.push(id);
|
||||
}
|
||||
}
|
||||
for id in comb.trackers.samplers.used() {
|
||||
for id in cmdbuf.trackers.samplers.used() {
|
||||
if !sampler_guard[id].life_guard.use_at(submit_index) {
|
||||
device.temp_suspected.samplers.push(id);
|
||||
}
|
||||
}
|
||||
for id in comb.trackers.compute_pipes.used() {
|
||||
for id in cmdbuf.trackers.compute_pipes.used() {
|
||||
if !compute_pipe_guard[id].life_guard.use_at(submit_index) {
|
||||
device.temp_suspected.compute_pipelines.push(id);
|
||||
}
|
||||
}
|
||||
for id in comb.trackers.render_pipes.used() {
|
||||
for id in cmdbuf.trackers.render_pipes.used() {
|
||||
if !render_pipe_guard[id].life_guard.use_at(submit_index) {
|
||||
device.temp_suspected.render_pipelines.push(id);
|
||||
}
|
||||
}
|
||||
|
||||
// execute resource transitions
|
||||
let mut transit = device.com_allocator.extend(comb);
|
||||
let mut transit = device.cmd_allocator.extend(cmdbuf);
|
||||
unsafe {
|
||||
// the last buffer was open, closing now
|
||||
comb.raw.last_mut().unwrap().finish();
|
||||
cmdbuf.raw.last_mut().unwrap().finish();
|
||||
transit
|
||||
.begin_primary(hal::command::CommandBufferFlags::ONE_TIME_SUBMIT);
|
||||
}
|
||||
@@ -503,14 +506,14 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
|
||||
CommandBuffer::insert_barriers(
|
||||
&mut transit,
|
||||
&mut *trackers,
|
||||
&comb.trackers,
|
||||
&cmdbuf.trackers,
|
||||
&*buffer_guard,
|
||||
&*texture_guard,
|
||||
);
|
||||
unsafe {
|
||||
transit.finish();
|
||||
}
|
||||
comb.raw.insert(0, transit);
|
||||
cmdbuf.raw.insert(0, transit);
|
||||
}
|
||||
|
||||
tracing::trace!("Device after submission {}: {:#?}", submit_index, trackers);
|
||||
@@ -541,7 +544,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
|
||||
|
||||
if let Some(comb_raw) = pending_write_command_buffer {
|
||||
device
|
||||
.com_allocator
|
||||
.cmd_allocator
|
||||
.after_submit_internal(comb_raw, submit_index);
|
||||
}
|
||||
|
||||
@@ -556,7 +559,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
|
||||
// finally, return the command buffers to the allocator
|
||||
for &cmb_id in command_buffer_ids {
|
||||
let (cmd_buf, _) = hub.command_buffers.unregister(cmb_id, &mut token);
|
||||
device.com_allocator.after_submit(cmd_buf, submit_index);
|
||||
device.cmd_allocator.after_submit(cmd_buf, submit_index);
|
||||
}
|
||||
|
||||
callbacks
|
||||
|
||||
@@ -536,7 +536,7 @@ impl<B: GfxBackend, F: GlobalIdentityHandlerFactory> Hub<B, F> {
|
||||
for element in self.command_buffers.data.write().map.drain(..) {
|
||||
if let Element::Occupied(command_buffer, _) = element {
|
||||
devices[command_buffer.device_id.value]
|
||||
.com_allocator
|
||||
.cmd_allocator
|
||||
.after_submit(command_buffer, 0);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user