Alternative Upload geometry data in parallel to multiple GPUs using the "Multi-Device" #107552
|
@ -46,6 +46,10 @@
|
|||
|
||||
#include "kernel/util/color.h"
|
||||
|
||||
#ifdef WITH_OPTIX
|
||||
#include "device/device.h"
|
||||
#endif
|
||||
|
||||
CCL_NAMESPACE_BEGIN
|
||||
|
||||
/* RenderServices implementation */
|
||||
|
|
|
@ -15,6 +15,7 @@ set(SRC
|
|||
camera.cpp
|
||||
colorspace.cpp
|
||||
constant_fold.cpp
|
||||
devicescene.cpp
|
||||
film.cpp
|
||||
geometry.cpp
|
||||
geometry_mesh.cpp
|
||||
|
@ -58,6 +59,7 @@ set(SRC_HEADERS
|
|||
camera.h
|
||||
colorspace.h
|
||||
constant_fold.h
|
||||
devicescene.h
|
||||
film.h
|
||||
geometry.h
|
||||
hair.h
|
||||
|
|
|
@ -0,0 +1,278 @@
|
|||
/* SPDX-License-Identifier: Apache-2.0
|
||||
* Copyright 2011-2022 Blender Foundation */
|
||||
|
||||
#include "scene/scene.h"
|
||||
#include "scene/devicescene.h"
|
||||
|
||||
CCL_NAMESPACE_BEGIN
|
||||
|
||||
DeviceScene::DeviceScene(Device *device)
|
||||
: bvh_nodes(device, "bvh_nodes", MEM_GLOBAL),
|
||||
bvh_leaf_nodes(device, "bvh_leaf_nodes", MEM_GLOBAL),
|
||||
object_node(device, "object_node", MEM_GLOBAL),
|
||||
prim_type(device, "prim_type", MEM_GLOBAL),
|
||||
prim_visibility(device, "prim_visibility", MEM_GLOBAL),
|
||||
prim_index(device, "prim_index", MEM_GLOBAL),
|
||||
prim_object(device, "prim_object", MEM_GLOBAL),
|
||||
prim_time(device, "prim_time", MEM_GLOBAL),
|
||||
tri_verts(device, "tri_verts", MEM_GLOBAL),
|
||||
tri_shader(device, "tri_shader", MEM_GLOBAL),
|
||||
tri_vnormal(device, "tri_vnormal", MEM_GLOBAL),
|
||||
tri_vindex(device, "tri_vindex", MEM_GLOBAL),
|
||||
tri_patch(device, "tri_patch", MEM_GLOBAL),
|
||||
tri_patch_uv(device, "tri_patch_uv", MEM_GLOBAL),
|
||||
curves(device, "curves", MEM_GLOBAL),
|
||||
curve_keys(device, "curve_keys", MEM_GLOBAL),
|
||||
curve_segments(device, "curve_segments", MEM_GLOBAL),
|
||||
patches(device, "patches", MEM_GLOBAL),
|
||||
points(device, "points", MEM_GLOBAL),
|
||||
points_shader(device, "points_shader", MEM_GLOBAL),
|
||||
objects(device, "objects", MEM_GLOBAL),
|
||||
object_motion_pass(device, "object_motion_pass", MEM_GLOBAL),
|
||||
object_motion(device, "object_motion", MEM_GLOBAL),
|
||||
object_flag(device, "object_flag", MEM_GLOBAL),
|
||||
object_volume_step(device, "object_volume_step", MEM_GLOBAL),
|
||||
object_prim_offset(device, "object_prim_offset", MEM_GLOBAL),
|
||||
camera_motion(device, "camera_motion", MEM_GLOBAL),
|
||||
attributes_map(device, "attributes_map", MEM_GLOBAL),
|
||||
attributes_float(device, "attributes_float", MEM_GLOBAL),
|
||||
attributes_float2(device, "attributes_float2", MEM_GLOBAL),
|
||||
attributes_float3(device, "attributes_float3", MEM_GLOBAL),
|
||||
attributes_float4(device, "attributes_float4", MEM_GLOBAL),
|
||||
attributes_uchar4(device, "attributes_uchar4", MEM_GLOBAL),
|
||||
light_distribution(device, "light_distribution", MEM_GLOBAL),
|
||||
lights(device, "lights", MEM_GLOBAL),
|
||||
light_background_marginal_cdf(device, "light_background_marginal_cdf", MEM_GLOBAL),
|
||||
light_background_conditional_cdf(device, "light_background_conditional_cdf", MEM_GLOBAL),
|
||||
light_tree_nodes(device, "light_tree_nodes", MEM_GLOBAL),
|
||||
light_tree_emitters(device, "light_tree_emitters", MEM_GLOBAL),
|
||||
light_to_tree(device, "light_to_tree", MEM_GLOBAL),
|
||||
object_lookup_offset(device, "object_lookup_offset", MEM_GLOBAL),
|
||||
triangle_to_tree(device, "triangle_to_tree", MEM_GLOBAL),
|
||||
particles(device, "particles", MEM_GLOBAL),
|
||||
svm_nodes(device, "svm_nodes", MEM_GLOBAL),
|
||||
shaders(device, "shaders", MEM_GLOBAL),
|
||||
lookup_table(device, "lookup_table", MEM_GLOBAL),
|
||||
sample_pattern_lut(device, "sample_pattern_lut", MEM_GLOBAL),
|
||||
ies_lights(device, "ies", MEM_GLOBAL)
|
||||
{
|
||||
memset((void *)&data, 0, sizeof(data));
|
||||
}
|
||||
|
||||
void DeviceScene::device_free(bool force_free)
|
||||
{
|
||||
bvh_nodes.free_if_need_realloc(force_free);
|
||||
bvh_leaf_nodes.free_if_need_realloc(force_free);
|
||||
object_node.free_if_need_realloc(force_free);
|
||||
prim_type.free_if_need_realloc(force_free);
|
||||
prim_visibility.free_if_need_realloc(force_free);
|
||||
prim_index.free_if_need_realloc(force_free);
|
||||
prim_object.free_if_need_realloc(force_free);
|
||||
prim_time.free_if_need_realloc(force_free);
|
||||
tri_verts.free_if_need_realloc(force_free);
|
||||
tri_shader.free_if_need_realloc(force_free);
|
||||
tri_vnormal.free_if_need_realloc(force_free);
|
||||
tri_vindex.free_if_need_realloc(force_free);
|
||||
tri_patch.free_if_need_realloc(force_free);
|
||||
tri_patch_uv.free_if_need_realloc(force_free);
|
||||
curves.free_if_need_realloc(force_free);
|
||||
curve_keys.free_if_need_realloc(force_free);
|
||||
curve_segments.free_if_need_realloc(force_free);
|
||||
points.free_if_need_realloc(force_free);
|
||||
points_shader.free_if_need_realloc(force_free);
|
||||
patches.free_if_need_realloc(force_free);
|
||||
attributes_map.free_if_need_realloc(force_free);
|
||||
attributes_float.free_if_need_realloc(force_free);
|
||||
attributes_float2.free_if_need_realloc(force_free);
|
||||
attributes_float3.free_if_need_realloc(force_free);
|
||||
attributes_float4.free_if_need_realloc(force_free);
|
||||
attributes_uchar4.free_if_need_realloc(force_free);
|
||||
}
|
||||
|
||||
/*
|
||||
* Clears the modified tags for all elements of the device scene
|
||||
*/
|
||||
void DeviceScene::device_scene_clear_modified()
|
||||
{
|
||||
bvh_nodes.clear_modified();
|
||||
bvh_leaf_nodes.clear_modified();
|
||||
object_node.clear_modified();
|
||||
prim_type.clear_modified();
|
||||
prim_visibility.clear_modified();
|
||||
prim_index.clear_modified();
|
||||
prim_object.clear_modified();
|
||||
prim_time.clear_modified();
|
||||
tri_verts.clear_modified();
|
||||
tri_shader.clear_modified();
|
||||
tri_vindex.clear_modified();
|
||||
tri_patch.clear_modified();
|
||||
tri_vnormal.clear_modified();
|
||||
tri_patch_uv.clear_modified();
|
||||
curves.clear_modified();
|
||||
curve_keys.clear_modified();
|
||||
curve_segments.clear_modified();
|
||||
points.clear_modified();
|
||||
points_shader.clear_modified();
|
||||
patches.clear_modified();
|
||||
attributes_map.clear_modified();
|
||||
attributes_float.clear_modified();
|
||||
attributes_float2.clear_modified();
|
||||
attributes_float3.clear_modified();
|
||||
attributes_float4.clear_modified();
|
||||
attributes_uchar4.clear_modified();
|
||||
objects.clear_modified();
|
||||
attributes_map.clear_modified();
|
||||
}
|
||||
|
||||
void DeviceScene::device_update_host_pointers(Device *device,
|
||||
DeviceScene *dscene,
|
||||
const GeometrySizes *p_sizes)
|
||||
{
|
||||
if (p_sizes->tri_size != 0) {
|
||||
if (dscene->tri_verts.is_modified()) {
|
||||
tri_verts.assign_mem(dscene->tri_verts);
|
||||
tri_verts.tag_modified();
|
||||
}
|
||||
{
|
||||
if (dscene->tri_shader.is_modified()) {
|
||||
tri_shader.assign_mem(dscene->tri_shader);
|
||||
tri_shader.tag_modified();
|
||||
}
|
||||
}
|
||||
{
|
||||
if (dscene->tri_vnormal.is_modified()) {
|
||||
tri_vnormal.assign_mem(dscene->tri_vnormal);
|
||||
tri_vnormal.tag_modified();
|
||||
}
|
||||
}
|
||||
{
|
||||
if (dscene->tri_vindex.is_modified()) {
|
||||
tri_vindex.assign_mem(dscene->tri_vindex);
|
||||
tri_vindex.tag_modified();
|
||||
}
|
||||
}
|
||||
{
|
||||
if (dscene->tri_patch.is_modified()) {
|
||||
tri_patch.assign_mem(dscene->tri_patch);
|
||||
tri_patch.tag_modified();
|
||||
}
|
||||
}
|
||||
{
|
||||
if (dscene->tri_patch_uv.is_modified()) {
|
||||
tri_patch_uv.assign_mem(dscene->tri_patch_uv);
|
||||
tri_patch_uv.tag_modified();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (p_sizes->curve_segment_size != 0) {
|
||||
if (dscene->curve_keys.is_modified()) {
|
||||
curve_keys.assign_mem(dscene->curve_keys);
|
||||
curve_keys.tag_modified();
|
||||
}
|
||||
|
||||
if (dscene->curves.is_modified()) {
|
||||
curves.assign_mem(dscene->curves);
|
||||
curves.tag_modified();
|
||||
}
|
||||
|
||||
if (dscene->curve_segments.is_modified()) {
|
||||
curve_segments.assign_mem(dscene->curve_segments);
|
||||
}
|
||||
}
|
||||
|
||||
if (p_sizes->point_size != 0) {
|
||||
// TODO: Why does this not check the modified tag?
|
||||
points.assign_mem(dscene->points);
|
||||
// sub_dscene->points.tag_modified();
|
||||
|
||||
points_shader.assign_mem(dscene->points_shader);
|
||||
// sub_dscene->points_shader.tag_modified();
|
||||
}
|
||||
|
||||
if (p_sizes->patch_size != 0 && dscene->patches.need_realloc()) {
|
||||
patches.assign_mem(dscene->patches);
|
||||
}
|
||||
|
||||
// Update the Attributes
|
||||
if (dscene->attributes_map.is_modified()) {
|
||||
attributes_map.assign_mem(dscene->attributes_map);
|
||||
attributes_map.tag_modified();
|
||||
}
|
||||
if (dscene->attributes_float.is_modified()) {
|
||||
attributes_float.assign_mem(dscene->attributes_float);
|
||||
attributes_float.tag_modified();
|
||||
}
|
||||
if (dscene->attributes_float2.is_modified()) {
|
||||
attributes_float2.assign_mem(dscene->attributes_float2);
|
||||
attributes_float2.tag_modified();
|
||||
}
|
||||
if (dscene->attributes_float3.is_modified()) {
|
||||
attributes_float3.assign_mem(dscene->attributes_float3);
|
||||
attributes_float3.tag_modified();
|
||||
}
|
||||
if (dscene->attributes_float4.is_modified()) {
|
||||
attributes_float4.assign_mem(dscene->attributes_float4);
|
||||
attributes_float4.tag_modified();
|
||||
}
|
||||
if (dscene->attributes_uchar4.is_modified()) {
|
||||
attributes_uchar4.assign_mem(dscene->attributes_uchar4);
|
||||
attributes_uchar4.tag_modified();
|
||||
}
|
||||
if (dscene->objects.is_modified()) {
|
||||
objects.assign_mem(dscene->objects);
|
||||
objects.tag_modified();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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)
|
||||
{
|
||||
progress.set_status("Updating Mesh", "Copying Mesh to device");
|
||||
if (p_sizes->tri_size != 0) {
|
||||
tri_verts.copy_to_device_if_modified(p_sizes->vert_size, 0);
|
||||
tri_shader.copy_to_device_if_modified(p_sizes->tri_size, 0);
|
||||
tri_vnormal.copy_to_device_if_modified(p_sizes->vert_size, 0);
|
||||
tri_vindex.copy_to_device_if_modified(p_sizes->tri_size, 0);
|
||||
tri_patch.copy_to_device_if_modified(p_sizes->tri_size, 0);
|
||||
tri_patch_uv.copy_to_device_if_modified(p_sizes->vert_size, 0);
|
||||
}
|
||||
|
||||
if (p_sizes->curve_segment_size != 0) {
|
||||
curve_keys.copy_to_device_if_modified(p_sizes->curve_key_size, 0);
|
||||
curves.copy_to_device_if_modified(p_sizes->curve_size, 0);
|
||||
curve_segments.copy_to_device_if_modified(p_sizes->curve_segment_size, 0);
|
||||
}
|
||||
|
||||
if (p_sizes->point_size != 0) {
|
||||
points.copy_to_device(p_sizes->point_size, 0);
|
||||
points_shader.copy_to_device(p_sizes->point_size, 0);
|
||||
}
|
||||
|
||||
if (p_sizes->patch_size != 0 && patches.need_realloc()) {
|
||||
patches.copy_to_device(p_sizes->patch_size, 0);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Copies the attribute buffer data to the devices
|
||||
*/
|
||||
void DeviceScene::device_update_attributes(Device *device,
|
||||
const AttributeSizes *sizes,
|
||||
Progress &progress)
|
||||
{
|
||||
progress.set_status("Updating Mesh", "Copying Attributes to device");
|
||||
/* copy svm attributes to device */
|
||||
attributes_map.copy_to_device_if_modified();
|
||||
attributes_float.copy_to_device_if_modified(sizes->attr_float_size, 0);
|
||||
attributes_float2.copy_to_device_if_modified(sizes->attr_float2_size, 0);
|
||||
attributes_float3.copy_to_device_if_modified(sizes->attr_float3_size, 0);
|
||||
attributes_float4.copy_to_device_if_modified(sizes->attr_float4_size, 0);
|
||||
attributes_uchar4.copy_to_device_if_modified(sizes->attr_uchar4_size, 0);
|
||||
objects.copy_to_device_if_modified();
|
||||
}
|
||||
CCL_NAMESPACE_END
|
|
@ -0,0 +1,118 @@
|
|||
/* SPDX-License-Identifier: Apache-2.0
|
||||
* Copyright 2011-2022 Blender Foundation */
|
||||
|
||||
#ifndef __DEVICESCENE_H__
|
||||
#define __DEVICESCENE_H__
|
||||
|
||||
#include "device/memory.h"
|
||||
#include "util/types.h"
|
||||
#include "util/vector.h"
|
||||
#include "util/progress.h"
|
||||
#include "kernel/types.h"
|
||||
CCL_NAMESPACE_BEGIN
|
||||
|
||||
|
||||
struct GeometrySizes;
|
||||
struct AttributeSizes;
|
||||
|
||||
/* Scene Device Data */
|
||||
|
||||
class DeviceScene {
|
||||
public:
|
||||
/* BVH */
|
||||
device_vector<int4> bvh_nodes;
|
||||
device_vector<int4> bvh_leaf_nodes;
|
||||
device_vector<int> object_node;
|
||||
device_vector<int> prim_type;
|
||||
device_vector<uint> prim_visibility;
|
||||
device_vector<int> prim_index;
|
||||
device_vector<int> prim_object;
|
||||
device_vector<float2> prim_time;
|
||||
|
||||
/* mesh */
|
||||
device_vector<packed_float3> tri_verts;
|
||||
device_vector<uint> tri_shader;
|
||||
device_vector<packed_float3> tri_vnormal;
|
||||
device_vector<packed_uint3> tri_vindex;
|
||||
device_vector<uint> tri_patch;
|
||||
device_vector<float2> tri_patch_uv;
|
||||
|
||||
device_vector<KernelCurve> curves;
|
||||
device_vector<float4> curve_keys;
|
||||
device_vector<KernelCurveSegment> curve_segments;
|
||||
|
||||
device_vector<uint> patches;
|
||||
|
||||
/* point-cloud */
|
||||
device_vector<float4> points;
|
||||
device_vector<uint> points_shader;
|
||||
|
||||
/* objects */
|
||||
device_vector<KernelObject> objects;
|
||||
device_vector<Transform> object_motion_pass;
|
||||
device_vector<DecomposedTransform> object_motion;
|
||||
device_vector<uint> object_flag;
|
||||
device_vector<float> object_volume_step;
|
||||
device_vector<uint> object_prim_offset;
|
||||
|
||||
/* cameras */
|
||||
device_vector<DecomposedTransform> camera_motion;
|
||||
|
||||
/* attributes */
|
||||
device_vector<AttributeMap> attributes_map;
|
||||
device_vector<float> attributes_float;
|
||||
device_vector<float2> attributes_float2;
|
||||
device_vector<packed_float3> attributes_float3;
|
||||
device_vector<float4> attributes_float4;
|
||||
device_vector<uchar4> attributes_uchar4;
|
||||
|
||||
/* lights */
|
||||
device_vector<KernelLightDistribution> light_distribution;
|
||||
device_vector<KernelLight> lights;
|
||||
device_vector<float2> light_background_marginal_cdf;
|
||||
device_vector<float2> light_background_conditional_cdf;
|
||||
|
||||
/* light tree */
|
||||
device_vector<KernelLightTreeNode> light_tree_nodes;
|
||||
device_vector<KernelLightTreeEmitter> light_tree_emitters;
|
||||
device_vector<uint> light_to_tree;
|
||||
device_vector<uint> object_lookup_offset;
|
||||
device_vector<uint> triangle_to_tree;
|
||||
|
||||
/* particles */
|
||||
device_vector<KernelParticle> particles;
|
||||
|
||||
/* shaders */
|
||||
device_vector<int4> svm_nodes;
|
||||
device_vector<KernelShader> shaders;
|
||||
|
||||
/* lookup tables */
|
||||
device_vector<float> lookup_table;
|
||||
|
||||
/* integrator */
|
||||
device_vector<float> sample_pattern_lut;
|
||||
|
||||
/* IES lights */
|
||||
device_vector<float> ies_lights;
|
||||
|
||||
KernelData data;
|
||||
|
||||
DeviceScene(Device *device);
|
||||
|
||||
void device_free(bool force_free);
|
||||
void device_scene_clear_modified();
|
||||
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);
|
||||
};
|
||||
|
||||
CCL_NAMESPACE_END
|
||||
|
||||
#endif /* __DEVICESCENE_H__ */
|
|
@ -775,7 +775,7 @@ void GeometryManager::device_data_xfer_and_bvh_update(int idx,
|
|||
Device *sub_device = sub_dscene->tri_verts.device;
|
||||
// Assign the host_pointers to the sub_dscene so that they access
|
||||
// the correct data
|
||||
device_update_host_pointers(sub_device, dscene, sub_dscene, &(scene->geom_sizes));
|
||||
sub_dscene->device_update_host_pointers(sub_device, dscene, &(scene->geom_sizes));
|
||||
|
||||
/* Upload geometry and attribute buffers to the device */
|
||||
{
|
||||
|
@ -785,7 +785,7 @@ void GeometryManager::device_data_xfer_and_bvh_update(int idx,
|
|||
scene->times[idx].mesh = time;
|
||||
}
|
||||
});
|
||||
device_update_mesh(sub_device, sub_dscene, &(scene->geom_sizes), progress);
|
||||
sub_dscene->device_update_mesh(sub_device, &(scene->geom_sizes), progress);
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -794,10 +794,10 @@ void GeometryManager::device_data_xfer_and_bvh_update(int idx,
|
|||
scene->times[idx].attrib = time;
|
||||
}
|
||||
});
|
||||
device_update_attributes(sub_device, sub_dscene, &(scene->attrib_sizes), progress);
|
||||
sub_dscene->device_update_attributes(sub_device, &(scene->attrib_sizes), progress);
|
||||
}
|
||||
|
||||
device_scene_clear_modified(sub_dscene);
|
||||
sub_dscene->device_scene_clear_modified();
|
||||
{
|
||||
scoped_callback_timer timer([scene, idx](double time) {
|
||||
if (scene->update_stats) {
|
||||
|
@ -1018,38 +1018,12 @@ void GeometryManager::device_update(Device *device,
|
|||
clear_geometry_update_and_modified_tags(scene);
|
||||
clear_shader_update_tags(scene);
|
||||
update_flags = UPDATE_NONE;
|
||||
device_scene_clear_modified(dscene);
|
||||
dscene->device_scene_clear_modified();
|
||||
}
|
||||
|
||||
void GeometryManager::device_free(Device *device, DeviceScene *dscene, bool force_free)
|
||||
{
|
||||
dscene->bvh_nodes.free_if_need_realloc(force_free);
|
||||
dscene->bvh_leaf_nodes.free_if_need_realloc(force_free);
|
||||
dscene->object_node.free_if_need_realloc(force_free);
|
||||
dscene->prim_type.free_if_need_realloc(force_free);
|
||||
dscene->prim_visibility.free_if_need_realloc(force_free);
|
||||
dscene->prim_index.free_if_need_realloc(force_free);
|
||||
dscene->prim_object.free_if_need_realloc(force_free);
|
||||
dscene->prim_time.free_if_need_realloc(force_free);
|
||||
dscene->tri_verts.free_if_need_realloc(force_free);
|
||||
dscene->tri_shader.free_if_need_realloc(force_free);
|
||||
dscene->tri_vnormal.free_if_need_realloc(force_free);
|
||||
dscene->tri_vindex.free_if_need_realloc(force_free);
|
||||
dscene->tri_patch.free_if_need_realloc(force_free);
|
||||
dscene->tri_patch_uv.free_if_need_realloc(force_free);
|
||||
dscene->curves.free_if_need_realloc(force_free);
|
||||
dscene->curve_keys.free_if_need_realloc(force_free);
|
||||
dscene->curve_segments.free_if_need_realloc(force_free);
|
||||
dscene->points.free_if_need_realloc(force_free);
|
||||
dscene->points_shader.free_if_need_realloc(force_free);
|
||||
dscene->patches.free_if_need_realloc(force_free);
|
||||
dscene->attributes_map.free_if_need_realloc(force_free);
|
||||
dscene->attributes_float.free_if_need_realloc(force_free);
|
||||
dscene->attributes_float2.free_if_need_realloc(force_free);
|
||||
dscene->attributes_float3.free_if_need_realloc(force_free);
|
||||
dscene->attributes_float4.free_if_need_realloc(force_free);
|
||||
dscene->attributes_uchar4.free_if_need_realloc(force_free);
|
||||
|
||||
dscene->device_free(force_free);
|
||||
#ifdef WITH_OSL
|
||||
OSLGlobals *og = (OSLGlobals *)device->get_cpu_osl_memory();
|
||||
|
||||
|
@ -1122,151 +1096,6 @@ void GeometryManager::clear_geometry_update_and_modified_tags(Scene *scene)
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Clears the modified tags for all elements of the device scene
|
||||
*/
|
||||
void GeometryManager::device_scene_clear_modified(DeviceScene *dscene)
|
||||
{
|
||||
dscene->bvh_nodes.clear_modified();
|
||||
dscene->bvh_leaf_nodes.clear_modified();
|
||||
dscene->object_node.clear_modified();
|
||||
dscene->prim_type.clear_modified();
|
||||
dscene->prim_visibility.clear_modified();
|
||||
dscene->prim_index.clear_modified();
|
||||
dscene->prim_object.clear_modified();
|
||||
dscene->prim_time.clear_modified();
|
||||
dscene->tri_verts.clear_modified();
|
||||
dscene->tri_shader.clear_modified();
|
||||
dscene->tri_vindex.clear_modified();
|
||||
dscene->tri_patch.clear_modified();
|
||||
dscene->tri_vnormal.clear_modified();
|
||||
dscene->tri_patch_uv.clear_modified();
|
||||
dscene->curves.clear_modified();
|
||||
dscene->curve_keys.clear_modified();
|
||||
dscene->curve_segments.clear_modified();
|
||||
dscene->points.clear_modified();
|
||||
dscene->points_shader.clear_modified();
|
||||
dscene->patches.clear_modified();
|
||||
dscene->attributes_map.clear_modified();
|
||||
dscene->attributes_float.clear_modified();
|
||||
dscene->attributes_float2.clear_modified();
|
||||
dscene->attributes_float3.clear_modified();
|
||||
dscene->attributes_float4.clear_modified();
|
||||
dscene->attributes_uchar4.clear_modified();
|
||||
dscene->objects.clear_modified();
|
||||
dscene->attributes_map.clear_modified();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Assigns the host pointers to the sub-devicescenes so
|
||||
* that they all have the same data sources
|
||||
*/
|
||||
void GeometryManager::device_update_host_pointers(Device *device,
|
||||
DeviceScene *dscene,
|
||||
DeviceScene *sub_dscene,
|
||||
const GeometrySizes *p_sizes)
|
||||
{
|
||||
if (p_sizes->tri_size != 0) {
|
||||
if (dscene->tri_verts.is_modified()) {
|
||||
sub_dscene->tri_verts.assign_mem(dscene->tri_verts);
|
||||
sub_dscene->tri_verts.tag_modified();
|
||||
}
|
||||
{
|
||||
if (dscene->tri_shader.is_modified()) {
|
||||
sub_dscene->tri_shader.assign_mem(dscene->tri_shader);
|
||||
sub_dscene->tri_shader.tag_modified();
|
||||
}
|
||||
}
|
||||
{
|
||||
if (dscene->tri_vnormal.is_modified()) {
|
||||
sub_dscene->tri_vnormal.assign_mem(dscene->tri_vnormal);
|
||||
sub_dscene->tri_vnormal.tag_modified();
|
||||
}
|
||||
}
|
||||
{
|
||||
if (dscene->tri_vindex.is_modified()) {
|
||||
sub_dscene->tri_vindex.assign_mem(dscene->tri_vindex);
|
||||
sub_dscene->tri_vindex.tag_modified();
|
||||
}
|
||||
}
|
||||
{
|
||||
if (dscene->tri_patch.is_modified()) {
|
||||
sub_dscene->tri_patch.assign_mem(dscene->tri_patch);
|
||||
sub_dscene->tri_patch.tag_modified();
|
||||
}
|
||||
}
|
||||
{
|
||||
if (dscene->tri_patch_uv.is_modified()) {
|
||||
sub_dscene->tri_patch_uv.assign_mem(dscene->tri_patch_uv);
|
||||
sub_dscene->tri_patch_uv.tag_modified();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (p_sizes->curve_segment_size != 0) {
|
||||
if (dscene->curve_keys.is_modified()) {
|
||||
sub_dscene->curve_keys.assign_mem(dscene->curve_keys);
|
||||
sub_dscene->curve_keys.tag_modified();
|
||||
}
|
||||
|
||||
if (dscene->curves.is_modified()) {
|
||||
sub_dscene->curves.assign_mem(dscene->curves);
|
||||
sub_dscene->curves.tag_modified();
|
||||
}
|
||||
|
||||
if (dscene->curve_segments.is_modified()) {
|
||||
sub_dscene->curve_segments.assign_mem(dscene->curve_segments);
|
||||
}
|
||||
}
|
||||
|
||||
if (p_sizes->point_size != 0) {
|
||||
// TODO: Why does this not check the modified tag?
|
||||
sub_dscene->points.assign_mem(dscene->points);
|
||||
// sub_dscene->points.tag_modified();
|
||||
|
||||
sub_dscene->points_shader.assign_mem(dscene->points_shader);
|
||||
// sub_dscene->points_shader.tag_modified();
|
||||
}
|
||||
|
||||
if (p_sizes->patch_size != 0 && dscene->patches.need_realloc()) {
|
||||
sub_dscene->patches.assign_mem(dscene->patches);
|
||||
}
|
||||
|
||||
// Update the Attributes
|
||||
if (dscene->attributes_map.is_modified()) {
|
||||
sub_dscene->attributes_map.assign_mem(dscene->attributes_map);
|
||||
sub_dscene->attributes_map.tag_modified();
|
||||
}
|
||||
if (dscene->attributes_float.is_modified()) {
|
||||
sub_dscene->attributes_float.assign_mem(dscene->attributes_float);
|
||||
sub_dscene->attributes_float.tag_modified();
|
||||
}
|
||||
if (dscene->attributes_float2.is_modified()) {
|
||||
sub_dscene->attributes_float2.assign_mem(dscene->attributes_float2);
|
||||
sub_dscene->attributes_float2.tag_modified();
|
||||
}
|
||||
if (dscene->attributes_float3.is_modified()) {
|
||||
sub_dscene->attributes_float3.assign_mem(dscene->attributes_float3);
|
||||
sub_dscene->attributes_float3.tag_modified();
|
||||
}
|
||||
if (dscene->attributes_float4.is_modified()) {
|
||||
sub_dscene->attributes_float4.assign_mem(dscene->attributes_float4);
|
||||
sub_dscene->attributes_float4.tag_modified();
|
||||
}
|
||||
if (dscene->attributes_uchar4.is_modified()) {
|
||||
sub_dscene->attributes_uchar4.assign_mem(dscene->attributes_uchar4);
|
||||
sub_dscene->attributes_uchar4.tag_modified();
|
||||
}
|
||||
if (dscene->objects.is_modified()) {
|
||||
sub_dscene->objects.assign_mem(dscene->objects);
|
||||
sub_dscene->objects.tag_modified();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Records all the geometry buffer sizes for later use
|
||||
*/
|
||||
|
@ -1390,9 +1219,9 @@ bool GeometryManager::displacement_and_curve_shadow_transparency(
|
|||
{"device_update (displacement: copy meshes to device)", time});
|
||||
}
|
||||
});
|
||||
device_update_host_pointers(sub_device, dscene, sub_dscene, &(scene->geom_sizes));
|
||||
device_update_attributes(sub_device, sub_dscene, &(scene->attrib_sizes), progress);
|
||||
device_update_mesh(sub_device, sub_dscene, &(scene->geom_sizes), progress);
|
||||
sub_dscene->device_update_host_pointers(sub_device, dscene, &(scene->geom_sizes));
|
||||
sub_dscene->device_update_attributes(sub_device, &(scene->attrib_sizes), progress);
|
||||
sub_dscene->device_update_mesh(sub_device, &(scene->geom_sizes), progress);
|
||||
}
|
||||
/* Copy constant data needed by shader evaluation. */
|
||||
sub_device->const_copy_to("data", &dscene->data, sizeof(dscene->data));
|
||||
|
|
|
@ -249,7 +249,6 @@ class GeometryManager {
|
|||
void tag_update(Scene *scene, uint32_t flag);
|
||||
|
||||
bool need_update() const;
|
||||
void device_scene_clear_modified(DeviceScene *dscene);
|
||||
|
||||
/* Statistics */
|
||||
void collect_statistics(const Scene *scene, RenderStats *stats);
|
||||
|
@ -309,15 +308,7 @@ class GeometryManager {
|
|||
|
||||
void device_update_mesh_preprocess(
|
||||
Device *device, DeviceScene *dscene, Scene *scene, Progress &progress);
|
||||
void device_update_mesh(Device *device,
|
||||
DeviceScene *dscene,
|
||||
const GeometrySizes *sizes,
|
||||
Progress &progress);
|
||||
void device_update_bvh2(Device *device, DeviceScene *dscene, Scene *scene, Progress &progress);
|
||||
void device_update_host_pointers(Device *device,
|
||||
DeviceScene *dscene,
|
||||
DeviceScene *sub_dscene,
|
||||
const GeometrySizes *p_sizes);
|
||||
bool displacement_and_curve_shadow_transparency(Scene *scene,
|
||||
Device *device,
|
||||
DeviceScene *dscene,
|
||||
|
@ -337,11 +328,6 @@ class GeometryManager {
|
|||
vector<AttributeRequestSet> &object_attributes,
|
||||
vector<AttributeSet> &object_attribute_values,
|
||||
Progress &progress);
|
||||
void device_update_attributes(Device *device,
|
||||
DeviceScene *dscene,
|
||||
const AttributeSizes *sizes,
|
||||
Progress &progress);
|
||||
|
||||
bool device_update_bvh_preprocess(Device *device,
|
||||
DeviceScene *dscene,
|
||||
Scene *scene,
|
||||
|
|
|
@ -375,25 +375,6 @@ void GeometryManager::update_attribute_element_offset(Geometry *geom,
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Copies the attribute buffer data to the devices
|
||||
*/
|
||||
void GeometryManager::device_update_attributes(Device *device,
|
||||
DeviceScene *dscene,
|
||||
const AttributeSizes *sizes,
|
||||
Progress &progress)
|
||||
{
|
||||
progress.set_status("Updating Mesh", "Copying Attributes to device");
|
||||
/* copy svm attributes to device */
|
||||
dscene->attributes_map.copy_to_device_if_modified();
|
||||
dscene->attributes_float.copy_to_device_if_modified(sizes->attr_float_size, 0);
|
||||
dscene->attributes_float2.copy_to_device_if_modified(sizes->attr_float2_size, 0);
|
||||
dscene->attributes_float3.copy_to_device_if_modified(sizes->attr_float3_size, 0);
|
||||
dscene->attributes_float4.copy_to_device_if_modified(sizes->attr_float4_size, 0);
|
||||
dscene->attributes_uchar4.copy_to_device_if_modified(sizes->attr_uchar4_size, 0);
|
||||
dscene->objects.copy_to_device_if_modified();
|
||||
}
|
||||
|
||||
/*
|
||||
* Packs the attribute buffers and records the sizes and offsets using
|
||||
* the attribute sets
|
||||
|
|
|
@ -32,40 +32,6 @@
|
|||
|
||||
CCL_NAMESPACE_BEGIN
|
||||
|
||||
/**
|
||||
* This copies the data to the devices if they have been modified
|
||||
*/
|
||||
void GeometryManager::device_update_mesh(Device *device,
|
||||
DeviceScene *dscene,
|
||||
const GeometrySizes *p_sizes,
|
||||
Progress &progress)
|
||||
{
|
||||
progress.set_status("Updating Mesh", "Copying Mesh to device");
|
||||
if (p_sizes->tri_size != 0) {
|
||||
dscene->tri_verts.copy_to_device_if_modified(p_sizes->vert_size, 0);
|
||||
dscene->tri_shader.copy_to_device_if_modified(p_sizes->tri_size, 0);
|
||||
dscene->tri_vnormal.copy_to_device_if_modified(p_sizes->vert_size, 0);
|
||||
dscene->tri_vindex.copy_to_device_if_modified(p_sizes->tri_size, 0);
|
||||
dscene->tri_patch.copy_to_device_if_modified(p_sizes->tri_size, 0);
|
||||
dscene->tri_patch_uv.copy_to_device_if_modified(p_sizes->vert_size, 0);
|
||||
}
|
||||
|
||||
if (p_sizes->curve_segment_size != 0) {
|
||||
dscene->curve_keys.copy_to_device_if_modified(p_sizes->curve_key_size, 0);
|
||||
dscene->curves.copy_to_device_if_modified(p_sizes->curve_size, 0);
|
||||
dscene->curve_segments.copy_to_device_if_modified(p_sizes->curve_segment_size, 0);
|
||||
}
|
||||
|
||||
if (p_sizes->point_size != 0) {
|
||||
dscene->points.copy_to_device(p_sizes->point_size, 0);
|
||||
dscene->points_shader.copy_to_device(p_sizes->point_size, 0);
|
||||
}
|
||||
|
||||
if (p_sizes->patch_size != 0 && dscene->patches.need_realloc()) {
|
||||
dscene->patches.copy_to_device(p_sizes->patch_size, 0);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Packs the geometry data into the device scene. That is it fills out
|
||||
* the geometry buffers
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include "scene/svm.h"
|
||||
#include "scene/tables.h"
|
||||
#include "scene/volume.h"
|
||||
#include "scene/devicescene.h"
|
||||
#include "session/session.h"
|
||||
|
||||
#include "util/foreach.h"
|
||||
|
@ -45,58 +46,7 @@ bool Scene::check_cancel_update(Progress &progress, Device *device) {
|
|||
return status || ((device != NULL) && device->have_error());
|
||||
}
|
||||
|
||||
DeviceScene::DeviceScene(Device *device)
|
||||
: bvh_nodes(device, "bvh_nodes", MEM_GLOBAL),
|
||||
bvh_leaf_nodes(device, "bvh_leaf_nodes", MEM_GLOBAL),
|
||||
object_node(device, "object_node", MEM_GLOBAL),
|
||||
prim_type(device, "prim_type", MEM_GLOBAL),
|
||||
prim_visibility(device, "prim_visibility", MEM_GLOBAL),
|
||||
prim_index(device, "prim_index", MEM_GLOBAL),
|
||||
prim_object(device, "prim_object", MEM_GLOBAL),
|
||||
prim_time(device, "prim_time", MEM_GLOBAL),
|
||||
tri_verts(device, "tri_verts", MEM_GLOBAL),
|
||||
tri_shader(device, "tri_shader", MEM_GLOBAL),
|
||||
tri_vnormal(device, "tri_vnormal", MEM_GLOBAL),
|
||||
tri_vindex(device, "tri_vindex", MEM_GLOBAL),
|
||||
tri_patch(device, "tri_patch", MEM_GLOBAL),
|
||||
tri_patch_uv(device, "tri_patch_uv", MEM_GLOBAL),
|
||||
curves(device, "curves", MEM_GLOBAL),
|
||||
curve_keys(device, "curve_keys", MEM_GLOBAL),
|
||||
curve_segments(device, "curve_segments", MEM_GLOBAL),
|
||||
patches(device, "patches", MEM_GLOBAL),
|
||||
points(device, "points", MEM_GLOBAL),
|
||||
points_shader(device, "points_shader", MEM_GLOBAL),
|
||||
objects(device, "objects", MEM_GLOBAL),
|
||||
object_motion_pass(device, "object_motion_pass", MEM_GLOBAL),
|
||||
object_motion(device, "object_motion", MEM_GLOBAL),
|
||||
object_flag(device, "object_flag", MEM_GLOBAL),
|
||||
object_volume_step(device, "object_volume_step", MEM_GLOBAL),
|
||||
object_prim_offset(device, "object_prim_offset", MEM_GLOBAL),
|
||||
camera_motion(device, "camera_motion", MEM_GLOBAL),
|
||||
attributes_map(device, "attributes_map", MEM_GLOBAL),
|
||||
attributes_float(device, "attributes_float", MEM_GLOBAL),
|
||||
attributes_float2(device, "attributes_float2", MEM_GLOBAL),
|
||||
attributes_float3(device, "attributes_float3", MEM_GLOBAL),
|
||||
attributes_float4(device, "attributes_float4", MEM_GLOBAL),
|
||||
attributes_uchar4(device, "attributes_uchar4", MEM_GLOBAL),
|
||||
light_distribution(device, "light_distribution", MEM_GLOBAL),
|
||||
lights(device, "lights", MEM_GLOBAL),
|
||||
light_background_marginal_cdf(device, "light_background_marginal_cdf", MEM_GLOBAL),
|
||||
light_background_conditional_cdf(device, "light_background_conditional_cdf", MEM_GLOBAL),
|
||||
light_tree_nodes(device, "light_tree_nodes", MEM_GLOBAL),
|
||||
light_tree_emitters(device, "light_tree_emitters", MEM_GLOBAL),
|
||||
light_to_tree(device, "light_to_tree", MEM_GLOBAL),
|
||||
object_lookup_offset(device, "object_lookup_offset", MEM_GLOBAL),
|
||||
triangle_to_tree(device, "triangle_to_tree", MEM_GLOBAL),
|
||||
particles(device, "particles", MEM_GLOBAL),
|
||||
svm_nodes(device, "svm_nodes", MEM_GLOBAL),
|
||||
shaders(device, "shaders", MEM_GLOBAL),
|
||||
lookup_table(device, "lookup_table", MEM_GLOBAL),
|
||||
sample_pattern_lut(device, "sample_pattern_lut", MEM_GLOBAL),
|
||||
ies_lights(device, "ies", MEM_GLOBAL)
|
||||
{
|
||||
memset((void *)&data, 0, sizeof(data));
|
||||
}
|
||||
|
||||
|
||||
Scene::Scene(const SceneParams ¶ms_, Device *device)
|
||||
: name("Scene"),
|
||||
|
|
|
@ -9,17 +9,13 @@
|
|||
#include "scene/film.h"
|
||||
#include "scene/image.h"
|
||||
#include "scene/shader.h"
|
||||
|
||||
#include "device/device.h"
|
||||
#include "device/memory.h"
|
||||
#include "scene/devicescene.h"
|
||||
|
||||
#include "util/param.h"
|
||||
#include "util/string.h"
|
||||
#include "util/system.h"
|
||||
#include "util/texture.h"
|
||||
#include "util/thread.h"
|
||||
#include "util/types.h"
|
||||
#include "util/vector.h"
|
||||
|
||||
CCL_NAMESPACE_BEGIN
|
||||
|
||||
|
@ -53,91 +49,7 @@ class BakeData;
|
|||
class RenderStats;
|
||||
class SceneUpdateStats;
|
||||
class Volume;
|
||||
|
||||
/* Scene Device Data */
|
||||
|
||||
class DeviceScene {
|
||||
public:
|
||||
/* BVH */
|
||||
device_vector<int4> bvh_nodes;
|
||||
device_vector<int4> bvh_leaf_nodes;
|
||||
device_vector<int> object_node;
|
||||
device_vector<int> prim_type;
|
||||
device_vector<uint> prim_visibility;
|
||||
device_vector<int> prim_index;
|
||||
device_vector<int> prim_object;
|
||||
device_vector<float2> prim_time;
|
||||
|
||||
/* mesh */
|
||||
device_vector<packed_float3> tri_verts;
|
||||
device_vector<uint> tri_shader;
|
||||
device_vector<packed_float3> tri_vnormal;
|
||||
device_vector<packed_uint3> tri_vindex;
|
||||
device_vector<uint> tri_patch;
|
||||
device_vector<float2> tri_patch_uv;
|
||||
|
||||
device_vector<KernelCurve> curves;
|
||||
device_vector<float4> curve_keys;
|
||||
device_vector<KernelCurveSegment> curve_segments;
|
||||
|
||||
device_vector<uint> patches;
|
||||
|
||||
/* point-cloud */
|
||||
device_vector<float4> points;
|
||||
device_vector<uint> points_shader;
|
||||
|
||||
/* objects */
|
||||
device_vector<KernelObject> objects;
|
||||
device_vector<Transform> object_motion_pass;
|
||||
device_vector<DecomposedTransform> object_motion;
|
||||
device_vector<uint> object_flag;
|
||||
device_vector<float> object_volume_step;
|
||||
device_vector<uint> object_prim_offset;
|
||||
|
||||
/* cameras */
|
||||
device_vector<DecomposedTransform> camera_motion;
|
||||
|
||||
/* attributes */
|
||||
device_vector<AttributeMap> attributes_map;
|
||||
device_vector<float> attributes_float;
|
||||
device_vector<float2> attributes_float2;
|
||||
device_vector<packed_float3> attributes_float3;
|
||||
device_vector<float4> attributes_float4;
|
||||
device_vector<uchar4> attributes_uchar4;
|
||||
|
||||
/* lights */
|
||||
device_vector<KernelLightDistribution> light_distribution;
|
||||
device_vector<KernelLight> lights;
|
||||
device_vector<float2> light_background_marginal_cdf;
|
||||
device_vector<float2> light_background_conditional_cdf;
|
||||
|
||||
/* light tree */
|
||||
device_vector<KernelLightTreeNode> light_tree_nodes;
|
||||
device_vector<KernelLightTreeEmitter> light_tree_emitters;
|
||||
device_vector<uint> light_to_tree;
|
||||
device_vector<uint> object_lookup_offset;
|
||||
device_vector<uint> triangle_to_tree;
|
||||
|
||||
/* particles */
|
||||
device_vector<KernelParticle> particles;
|
||||
|
||||
/* shaders */
|
||||
device_vector<int4> svm_nodes;
|
||||
device_vector<KernelShader> shaders;
|
||||
|
||||
/* lookup tables */
|
||||
device_vector<float> lookup_table;
|
||||
|
||||
/* integrator */
|
||||
device_vector<float> sample_pattern_lut;
|
||||
|
||||
/* IES lights */
|
||||
device_vector<float> ies_lights;
|
||||
|
||||
KernelData data;
|
||||
|
||||
DeviceScene(Device *device);
|
||||
};
|
||||
class DeviceScene;
|
||||
|
||||
/* Geometry Sizes */
|
||||
struct GeometrySizes {
|
||||
|
|
Loading…
Reference in New Issue