Alternative Upload geometry data in parallel to multiple GPUs using the "Multi-Device" #107552
|
@ -1,8 +1,8 @@
|
|||
/* SPDX-License-Identifier: Apache-2.0
|
||||
* Copyright 2011-2022 Blender Foundation */
|
||||
|
||||
#include "scene/scene.h"
|
||||
#include "scene/devicescene.h"
|
||||
#include "scene/scene.h"
|
||||
|
||||
CCL_NAMESPACE_BEGIN
|
||||
|
||||
|
@ -229,8 +229,8 @@ void DeviceScene::device_update_host_pointers(Device *device,
|
|||
* This copies the data to the devices if they have been modified
|
||||
*/
|
||||
void DeviceScene::device_update_mesh(Device *device,
|
||||
const GeometrySizes *p_sizes,
|
||||
Progress &progress)
|
||||
const GeometrySizes *p_sizes,
|
||||
Progress &progress)
|
||||
{
|
||||
progress.set_status("Updating Mesh", "Copying Mesh to device");
|
||||
if (p_sizes->tri_size != 0) {
|
||||
|
@ -262,8 +262,8 @@ void DeviceScene::device_update_mesh(Device *device,
|
|||
* Copies the attribute buffer data to the devices
|
||||
*/
|
||||
void DeviceScene::device_update_attributes(Device *device,
|
||||
const AttributeSizes *sizes,
|
||||
Progress &progress)
|
||||
const AttributeSizes *sizes,
|
||||
Progress &progress)
|
||||
{
|
||||
progress.set_status("Updating Mesh", "Copying Attributes to device");
|
||||
/* copy svm attributes to device */
|
||||
|
@ -275,4 +275,50 @@ void DeviceScene::device_update_attributes(Device *device,
|
|||
attributes_uchar4.copy_to_device_if_modified(sizes->attr_uchar4_size, 0);
|
||||
objects.copy_to_device_if_modified();
|
||||
}
|
||||
|
||||
void DeviceScene::device_update_bvh2(Device *device,
|
||||
BVH *bvh,
|
||||
Progress &progress)
|
||||
{
|
||||
if (bvh->params.bvh_layout == BVH_LAYOUT_BVH2) {
|
||||
BVH2 *bvh2 = static_cast<BVH2 *>(bvh);
|
||||
|
||||
/* When using BVH2, we always have to copy/update the data as its layout is dependent on
|
||||
* the BVH's leaf nodes which may be different when the objects or vertices move. */
|
||||
|
||||
if (bvh2->pack.nodes.size()) {
|
||||
bvh_nodes.assign_mem(bvh2->pack.nodes);
|
||||
bvh_nodes.copy_to_device();
|
||||
}
|
||||
if (bvh2->pack.leaf_nodes.size()) {
|
||||
bvh_leaf_nodes.assign_mem(bvh2->pack.leaf_nodes);
|
||||
bvh_leaf_nodes.copy_to_device();
|
||||
}
|
||||
if (bvh2->pack.object_node.size()) {
|
||||
object_node.assign_mem(bvh2->pack.object_node);
|
||||
object_node.copy_to_device();
|
||||
}
|
||||
if (bvh2->pack.prim_type.size()) {
|
||||
prim_type.assign_mem(bvh2->pack.prim_type);
|
||||
prim_type.copy_to_device();
|
||||
}
|
||||
if (bvh2->pack.prim_visibility.size()) {
|
||||
prim_visibility.assign_mem(bvh2->pack.prim_visibility);
|
||||
prim_visibility.copy_to_device();
|
||||
}
|
||||
if (bvh2->pack.prim_index.size()) {
|
||||
prim_index.assign_mem(bvh2->pack.prim_index);
|
||||
prim_index.copy_to_device();
|
||||
}
|
||||
if (bvh2->pack.prim_object.size()) {
|
||||
prim_object.assign_mem(bvh2->pack.prim_object);
|
||||
prim_object.copy_to_device();
|
||||
}
|
||||
if (bvh2->pack.prim_time.size()) {
|
||||
prim_time.assign_mem(bvh2->pack.prim_time);
|
||||
prim_time.copy_to_device();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CCL_NAMESPACE_END
|
||||
|
|
|
@ -4,14 +4,20 @@
|
|||
#ifndef __DEVICESCENE_H__
|
||||
#define __DEVICESCENE_H__
|
||||
|
||||
#include "bvh/bvh.h"
|
||||
#include "bvh/bvh2.h"
|
||||
|
||||
#include "device/memory.h"
|
||||
|
||||
#include "kernel/types.h"
|
||||
|
||||
#include "util/progress.h"
|
||||
#include "util/types.h"
|
||||
#include "util/vector.h"
|
||||
#include "util/progress.h"
|
||||
#include "kernel/types.h"
|
||||
|
||||
CCL_NAMESPACE_BEGIN
|
||||
|
||||
|
||||
class BVH;
|
||||
struct GeometrySizes;
|
||||
struct AttributeSizes;
|
||||
|
||||
|
@ -104,13 +110,10 @@ class DeviceScene {
|
|||
void device_update_host_pointers(Device *device,
|
||||
DeviceScene *dscene,
|
||||
const GeometrySizes *p_sizes);
|
||||
void device_update_mesh(Device *device,
|
||||
const GeometrySizes *p_sizes,
|
||||
Progress &progress);
|
||||
|
||||
void device_update_attributes(Device *device,
|
||||
const AttributeSizes *sizes,
|
||||
Progress &progress);
|
||||
void device_update_mesh(Device *device, const GeometrySizes *p_sizes, Progress &progress);
|
||||
|
||||
void device_update_attributes(Device *device, const AttributeSizes *sizes, Progress &progress);
|
||||
void device_update_bvh2(Device *device, BVH *bvh, Progress &progress);
|
||||
};
|
||||
|
||||
CCL_NAMESPACE_END
|
||||
|
|
|
@ -824,7 +824,7 @@ void GeometryManager::device_data_xfer_and_bvh_update(int idx,
|
|||
});
|
||||
/* Build the scene BVH */
|
||||
device_update_bvh(sub_device, sub_dscene, scene, can_refit, 1, 1, progress);
|
||||
device_update_bvh2(sub_device, sub_dscene, scene, progress);
|
||||
sub_dscene->device_update_bvh2(sub_device, scene->bvh, progress);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -254,28 +254,28 @@ class GeometryManager {
|
|||
void collect_statistics(const Scene *scene, RenderStats *stats);
|
||||
|
||||
size_t create_object_bvhs(Device *device,
|
||||
DeviceScene *dscene,
|
||||
Scene *scene,
|
||||
const BVHLayout bvh_layout,
|
||||
bool &need_update_scene_bvh);
|
||||
DeviceScene *dscene,
|
||||
Scene *scene,
|
||||
const BVHLayout bvh_layout,
|
||||
bool &need_update_scene_bvh);
|
||||
void update_scene_bvhs(Device *device, DeviceScene *dscene, Scene *scene, Progress &progress);
|
||||
void clear_shader_update_tags(Scene *scene);
|
||||
void clear_geometry_update_and_modified_tags(Scene *scene);
|
||||
void device_data_xfer_and_bvh_update(int idx,
|
||||
Scene *scene,
|
||||
DeviceScene *dscene,
|
||||
const BVHLayout bvh_layout,
|
||||
size_t num_bvh,
|
||||
bool can_refit,
|
||||
bool need_update_scene_bvh,
|
||||
Progress &progress);
|
||||
Scene *scene,
|
||||
DeviceScene *dscene,
|
||||
const BVHLayout bvh_layout,
|
||||
size_t num_bvh,
|
||||
bool can_refit,
|
||||
bool need_update_scene_bvh,
|
||||
Progress &progress);
|
||||
void update_object_bounds(Scene *scene);
|
||||
void tesselate(Scene *scene, size_t total_tess_needed, Progress &progress);
|
||||
void pretess_disp_normal_and_vertices_setup(Device *device,
|
||||
Scene *scene,
|
||||
bool &true_displacement_used,
|
||||
bool &curve_shadow_transparency_used,
|
||||
size_t &total_tess_needed);
|
||||
Scene *scene,
|
||||
bool &true_displacement_used,
|
||||
bool &curve_shadow_transparency_used,
|
||||
size_t &total_tess_needed);
|
||||
static void device_update_sub_bvh(Device *device,
|
||||
DeviceScene *dscene,
|
||||
BVH *bvh,
|
||||
|
@ -308,7 +308,6 @@ class GeometryManager {
|
|||
|
||||
void device_update_mesh_preprocess(
|
||||
Device *device, DeviceScene *dscene, Scene *scene, Progress &progress);
|
||||
void device_update_bvh2(Device *device, DeviceScene *dscene, Scene *scene, Progress &progress);
|
||||
bool displacement_and_curve_shadow_transparency(Scene *scene,
|
||||
Device *device,
|
||||
DeviceScene *dscene,
|
||||
|
|
|
@ -46,53 +46,6 @@ void GeometryManager::device_update_bvh(Device *device,
|
|||
device, dscene, bvh, sub_bvh, can_refit, n, total, &progress);
|
||||
}
|
||||
|
||||
void GeometryManager::device_update_bvh2(Device *device,
|
||||
DeviceScene *dscene,
|
||||
Scene *scene,
|
||||
Progress &progress)
|
||||
{
|
||||
BVH *bvh = scene->bvh;
|
||||
if (bvh->params.bvh_layout == BVH_LAYOUT_BVH2) {
|
||||
BVH2 *bvh2 = static_cast<BVH2 *>(bvh);
|
||||
|
||||
/* When using BVH2, we always have to copy/update the data as its layout is dependent on
|
||||
* the BVH's leaf nodes which may be different when the objects or vertices move. */
|
||||
|
||||
if (bvh2->pack.nodes.size()) {
|
||||
dscene->bvh_nodes.assign_mem(bvh2->pack.nodes);
|
||||
dscene->bvh_nodes.copy_to_device();
|
||||
}
|
||||
if (bvh2->pack.leaf_nodes.size()) {
|
||||
dscene->bvh_leaf_nodes.assign_mem(bvh2->pack.leaf_nodes);
|
||||
dscene->bvh_leaf_nodes.copy_to_device();
|
||||
}
|
||||
if (bvh2->pack.object_node.size()) {
|
||||
dscene->object_node.assign_mem(bvh2->pack.object_node);
|
||||
dscene->object_node.copy_to_device();
|
||||
}
|
||||
if (bvh2->pack.prim_type.size()) {
|
||||
dscene->prim_type.assign_mem(bvh2->pack.prim_type);
|
||||
dscene->prim_type.copy_to_device();
|
||||
}
|
||||
if (bvh2->pack.prim_visibility.size()) {
|
||||
dscene->prim_visibility.assign_mem(bvh2->pack.prim_visibility);
|
||||
dscene->prim_visibility.copy_to_device();
|
||||
}
|
||||
if (bvh2->pack.prim_index.size()) {
|
||||
dscene->prim_index.assign_mem(bvh2->pack.prim_index);
|
||||
dscene->prim_index.copy_to_device();
|
||||
}
|
||||
if (bvh2->pack.prim_object.size()) {
|
||||
dscene->prim_object.assign_mem(bvh2->pack.prim_object);
|
||||
dscene->prim_object.copy_to_device();
|
||||
}
|
||||
if (bvh2->pack.prim_time.size()) {
|
||||
dscene->prim_time.assign_mem(bvh2->pack.prim_time);
|
||||
dscene->prim_time.copy_to_device();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GeometryManager::device_update_bvh_postprocess(Device *device,
|
||||
DeviceScene *dscene,
|
||||
Scene *scene,
|
||||
|
|
Loading…
Reference in New Issue