Optimized ray stack task duplication with memcopy.
This commit is contained in:
parent
68fba19fc6
commit
2a0ca001e2
7
Cargo.lock
generated
7
Cargo.lock
generated
|
@ -100,6 +100,11 @@ dependencies = [
|
||||||
name = "color"
|
name = "color"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "copy_in_place"
|
||||||
|
version = "0.2.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "crossbeam"
|
name = "crossbeam"
|
||||||
version = "0.3.2"
|
version = "0.3.2"
|
||||||
|
@ -239,6 +244,7 @@ dependencies = [
|
||||||
"bvh_order 0.1.0",
|
"bvh_order 0.1.0",
|
||||||
"clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"color 0.1.0",
|
"color 0.1.0",
|
||||||
|
"copy_in_place 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"crossbeam 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"crossbeam 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"float4 0.1.0",
|
"float4 0.1.0",
|
||||||
"half 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"half 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
@ -557,6 +563,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
"checksum cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "b486ce3ccf7ffd79fdeb678eac06a9e6c09fc88d33836340becb8fffe87c5e33"
|
"checksum cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "b486ce3ccf7ffd79fdeb678eac06a9e6c09fc88d33836340becb8fffe87c5e33"
|
||||||
"checksum clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5067f5bb2d80ef5d68b4c87db81601f0b75bca627bc2ef76b141d7b846a3c6d9"
|
"checksum clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5067f5bb2d80ef5d68b4c87db81601f0b75bca627bc2ef76b141d7b846a3c6d9"
|
||||||
"checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f"
|
"checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f"
|
||||||
|
"checksum copy_in_place 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b792a46b1ef44bb5e9a04721d34e186522431be965a283437107843d62ddbaad"
|
||||||
"checksum crossbeam 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "24ce9782d4d5c53674646a6a4c1863a21a8fc0cb649b3c94dfc16e45071dea19"
|
"checksum crossbeam 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "24ce9782d4d5c53674646a6a4c1863a21a8fc0cb649b3c94dfc16e45071dea19"
|
||||||
"checksum fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "2fad85553e09a6f881f739c29f0b00b0f01357c743266d478b68951ce23285f3"
|
"checksum fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "2fad85553e09a6f881f739c29f0b00b0f01357c743266d478b68951ce23285f3"
|
||||||
"checksum fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba"
|
"checksum fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba"
|
||||||
|
|
|
@ -25,6 +25,7 @@ debug = true
|
||||||
# Crates.io dependencies
|
# Crates.io dependencies
|
||||||
base64 = "0.9"
|
base64 = "0.9"
|
||||||
clap = "2.30"
|
clap = "2.30"
|
||||||
|
copy_in_place = "0.2.0"
|
||||||
crossbeam = "0.3"
|
crossbeam = "0.3"
|
||||||
half = "1.0"
|
half = "1.0"
|
||||||
lazy_static = "1.0"
|
lazy_static = "1.0"
|
||||||
|
|
13
src/ray.rs
13
src/ray.rs
|
@ -279,11 +279,18 @@ impl RayStack {
|
||||||
let start = task.start_idx;
|
let start = task.start_idx;
|
||||||
let end = self.lanes[l].end_len;
|
let end = self.lanes[l].end_len;
|
||||||
|
|
||||||
for i in start..end {
|
// Extend the indices vector
|
||||||
let idx = self.lanes[l].idxs[i];
|
self.lanes[l].idxs.reserve(end - start);
|
||||||
self.lanes[l].idxs.push(idx);
|
let old_len = self.lanes[l].idxs.len();
|
||||||
|
let new_len = old_len + end - start;
|
||||||
|
unsafe {
|
||||||
|
self.lanes[l].idxs.set_len(new_len);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Copy elements
|
||||||
|
copy_in_place::copy_in_place(&mut self.lanes[l].idxs, start..end, end);
|
||||||
|
|
||||||
|
// Push the new task onto the stack
|
||||||
self.tasks.push(RayTask {
|
self.tasks.push(RayTask {
|
||||||
lane: l,
|
lane: l,
|
||||||
start_idx: end,
|
start_idx: end,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user