diff options
author | Stan Seibert <stan@mtrr.org> | 2012-02-17 13:53:36 -0500 |
---|---|---|
committer | tlatorre <tlatorre@uchicago.edu> | 2021-05-09 08:42:38 -0700 |
commit | aa14bc9f0947a77781c1234c38f422f18b2fe154 (patch) | |
tree | fe9502d45c3cb6d41dbf87f29cf72af82c7571f4 /bin | |
parent | 3cd18a51d4e73d9148fc721527880c8dbbd08871 (diff) | |
download | chroma-aa14bc9f0947a77781c1234c38f422f18b2fe154.tar.gz chroma-aa14bc9f0947a77781c1234c38f422f18b2fe154.tar.bz2 chroma-aa14bc9f0947a77781c1234c38f422f18b2fe154.zip |
BVH optimization to sort child nodes by area. Only has a small effect.
Diffstat (limited to 'bin')
-rw-r--r-- | bin/chroma-bvh | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/bin/chroma-bvh b/bin/chroma-bvh index e3e6a8c..d4287ad 100644 --- a/bin/chroma-bvh +++ b/bin/chroma-bvh @@ -11,7 +11,8 @@ from chroma.loader import load_geometry_from_string from chroma.log import logger, logging from chroma.bvh import make_recursive_grid_bvh from chroma.gpu import create_cuda_context -from chroma.gpu.bvh import optimize_layer +from chroma.gpu.geometry import GPUGeometry +from chroma.gpu.bvh import optimize_layer, area_sort_nodes def parse_bvh_id(id_str): @@ -28,6 +29,23 @@ def parse_bvh_id(id_str): bvh_name = parts[1] geo_name = parts[0] return geo_name, bvh_name + + +def sort_node(cache, args): + geo_name, bvh_name = parse_bvh_id(args[0]) + mesh_hash = cache.get_geometry_hash(geo_name) + geometry = cache.load_geometry(geo_name) + geometry.bvh = cache.load_bvh(mesh_hash, bvh_name) + + print 'Sorting BVH nodes by area...' + + context = create_cuda_context() + gpu_geometry = GPUGeometry(geometry) + geometry.bvh.nodes = area_sort_nodes(gpu_geometry, geometry.bvh.layer_bounds) + + print 'Saving new BVH...' + context.pop() + cache.save_bvh(geometry.bvh, mesh_hash, bvh_name) def node_swap(cache, args): @@ -181,6 +199,7 @@ commands = { 'remove' : remove, 'node_swap' : node_swap, 'hist' : area_hist, + 'sort' : sort_node, } |