gpu: port lock-free submit-thread watch/shadow/batch/card_steps/send optimizations
This commit is contained in:
1 parent
84b4509fa3
commit
6f34121d31
5 files changed
+325
-143
No files matched your search
@@ -370,45 +370,66 @@ fn plan(does: &[Does], stage: u32, by_order: bool, behind: &mut Option<(usize, u
|
||||
let mut taken = vec![false; does.len()];
|
||||
let (mut read, mut written) = (Vec::new(), Vec::new());
|
||||
let mut more = Vec::new();
|
||||
let (mut has_copy, mut has_placed) = (false, false);
|
||||
for (i, d) in does.iter().enumerate() {
|
||||
match *d {
|
||||
Does::Run => return Err("a step of ours runs"),
|
||||
Does::Read { asked: true, .. } => return Err("a texture reads it"),
|
||||
Does::Copy { asked: true, .. } | Does::Fill { asked: true, .. } => more.push(i),
|
||||
Does::Copy { asked, .. } => {
|
||||
has_copy = true;
|
||||
if asked {
|
||||
more.push(i);
|
||||
}
|
||||
}
|
||||
Does::Fill { asked: true, .. } => more.push(i),
|
||||
Does::Placed { .. } => has_placed = true,
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
let mut taken_count = 0usize;
|
||||
while !more.is_empty() {
|
||||
// (Joined once for the round: one by one the 2,800 fills of a frame
|
||||
// sorted the ranges each time, 16 ms of the submitting thread.)
|
||||
let (mut reads, mut writes) = (Vec::new(), Vec::new());
|
||||
for i in std::mem::take(&mut more) {
|
||||
takes(&does[i])?;
|
||||
taken[i] = true;
|
||||
if !taken[i] {
|
||||
taken[i] = true;
|
||||
taken_count += 1;
|
||||
}
|
||||
if let Some((r, w)) = reads_writes(&does[i]) {
|
||||
if w.0 < w.1 && meet(r, w) {
|
||||
return Err("a copy onto itself");
|
||||
}
|
||||
reads.push(r);
|
||||
writes.push(w);
|
||||
if has_copy || has_placed {
|
||||
reads.push(r);
|
||||
}
|
||||
if w.0 < w.1 {
|
||||
writes.push(w);
|
||||
}
|
||||
}
|
||||
}
|
||||
join_ranges(&mut read, reads);
|
||||
if writes.iter().any(|w| w.0 < w.1) {
|
||||
if !reads.is_empty() {
|
||||
join_ranges(&mut read, reads);
|
||||
}
|
||||
if !writes.is_empty() {
|
||||
join_ranges(&mut written, writes);
|
||||
}
|
||||
if taken.iter().filter(|t| **t).count() > MOST {
|
||||
if taken_count > MOST {
|
||||
return Err("too many steps depend on it");
|
||||
}
|
||||
for (i, d) in does.iter().enumerate() {
|
||||
// A fill that cannot be taken is looked at below.
|
||||
if taken[i] || matches!(d, Does::Fill { to: false, .. }) {
|
||||
continue;
|
||||
}
|
||||
if let Some((r, w)) = reads_writes(d)
|
||||
&& (touched(&written, r) || touched(&written, w) || touched(&read, w))
|
||||
{
|
||||
more.push(i);
|
||||
if !written.is_empty() || (has_copy && !read.is_empty()) {
|
||||
for (i, d) in does.iter().enumerate() {
|
||||
// A fill that cannot be taken is looked at below.
|
||||
if taken[i] || matches!(d, Does::Fill { to: false, .. }) {
|
||||
continue;
|
||||
}
|
||||
if let Some((r, w)) = reads_writes(d)
|
||||
&& (touched(&written, r)
|
||||
|| (w.0 < w.1 && (touched(&written, w) || touched(&read, w))))
|
||||
{
|
||||
more.push(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user