Skip to content

Commit

Permalink
improve copy_to_device logic (fix rendering bug)
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesPerlman committed Jun 29, 2023
1 parent e0e35b8 commit 1e14731
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
18 changes: 14 additions & 4 deletions src/core/renderer.cu
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,10 @@ void Renderer::prepare_for_rendering(

auto& scene_ws = ctx.scene_ws;
const uint32_t n_nerfs = nerfs.size();

const bool needs_update = scene_ws.n_nerfs != n_nerfs || scene_ws.n_rays != n_rays;

if (scene_ws.n_nerfs != n_nerfs || scene_ws.n_rays != n_rays) {
if (needs_update) {
scene_ws.enlarge(
stream,
n_nerfs,
Expand Down Expand Up @@ -75,9 +77,17 @@ void Renderer::prepare_for_rendering(
}

// copy updatable properties (these only get copied if their is_dirty flag is set)
proxy->render_bbox.copy_to_device(scene_ws.render_bboxes + i, stream);
proxy->training_bbox.copy_to_device(scene_ws.training_bboxes + i, stream);
proxy->transform.copy_to_device(scene_ws.nerf_transforms + i, stream);
if (needs_update || proxy->render_bbox.is_dirty()) {
proxy->render_bbox.copy_to_device(scene_ws.render_bboxes + i, stream);
}

if (needs_update || proxy->training_bbox.is_dirty()) {
proxy->training_bbox.copy_to_device(scene_ws.training_bboxes + i, stream);
}

if (needs_update || proxy->transform.is_dirty()) {
proxy->transform.copy_to_device(scene_ws.nerf_transforms + i, stream);
}

// copy occupancy grids
// TODO: turn this into an UpdatableProperty
Expand Down
5 changes: 0 additions & 5 deletions src/models/updatable-property.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,11 @@ public:
return _value;
}

// copy to device util, only copies if dirty
__host__
void copy_to_device(
T* device_ptr,
cudaStream_t stream = 0
) {
if (!_is_dirty) {
return;
}

cudaMemcpyAsync(
device_ptr,
&_value,
Expand Down

0 comments on commit 1e14731

Please sign in to comment.