mirror of
https://github.com/storytold/wgpu.git
synced 2026-11-26 01:11:22 +01:00
Fix compute pass barriers
This commit is contained in:
1 parent
17e555b257
commit
4446b81f3e
3 files changed
+18
-13
No files matched your search
@@ -24,12 +24,16 @@ pub struct ComputePass<B: hal::Backend> {
|
||||
}
|
||||
|
||||
impl<B: hal::Backend> ComputePass<B> {
|
||||
pub(crate) fn new(raw: B::CommandBuffer, cmb_id: Stored<CommandBufferId>) -> Self {
|
||||
pub(crate) fn new(
|
||||
raw: B::CommandBuffer,
|
||||
cmb_id: Stored<CommandBufferId>,
|
||||
trackers: TrackerSet,
|
||||
) -> Self {
|
||||
ComputePass {
|
||||
raw,
|
||||
cmb_id,
|
||||
binder: Binder::default(),
|
||||
trackers: TrackerSet::new(),
|
||||
trackers,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -38,14 +42,14 @@ impl<B: hal::Backend> ComputePass<B> {
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wgpu_compute_pass_end_pass(pass_id: ComputePassId) -> CommandBufferId {
|
||||
let mut command_buffer_guard = HUB.command_buffers.write();
|
||||
let mut cmb_guard = HUB.command_buffers.write();
|
||||
let pass = HUB.compute_passes.unregister(pass_id);
|
||||
let cmb = &mut cmb_guard[pass.cmb_id.value];
|
||||
|
||||
//TODO: transitions?
|
||||
|
||||
command_buffer_guard[pass.cmb_id.value]
|
||||
.raw
|
||||
.push(pass.raw);
|
||||
// There are no transitions to be made: we've already been inserting barriers
|
||||
// into the parent command buffer while recording this compute pass.
|
||||
cmb.trackers = pass.trackers;
|
||||
cmb.raw.push(pass.raw);
|
||||
pass.cmb_id.value
|
||||
}
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ use back::Backend;
|
||||
use hal::{command::RawCommandBuffer, Device as _};
|
||||
use log::trace;
|
||||
|
||||
use std::{collections::hash_map::Entry, iter, slice, thread::ThreadId};
|
||||
use std::{collections::hash_map::Entry, iter, mem, slice, thread::ThreadId};
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq)]
|
||||
@@ -426,12 +426,13 @@ pub fn command_encoder_begin_compute_pass(
|
||||
let cmb = &mut cmb_guard[command_encoder_id];
|
||||
|
||||
let raw = cmb.raw.pop().unwrap();
|
||||
let trackers = mem::replace(&mut cmb.trackers, TrackerSet::new());
|
||||
let stored = Stored {
|
||||
value: command_encoder_id,
|
||||
ref_count: cmb.life_guard.ref_count.clone(),
|
||||
};
|
||||
|
||||
ComputePass::new(raw, stored)
|
||||
ComputePass::new(raw, stored, trackers)
|
||||
}
|
||||
|
||||
#[cfg(feature = "local")]
|
||||
|
||||
Reference in new issue
Block a user