[Bf-blender-cvs] [0f48740d34c] cycles_procedural_api: fix compile errors with GTEST and Optix

Kévin Dietrich noreply at git.blender.org
Sat Sep 26 19:24:35 CEST 2020


Commit: 0f48740d34c22e27143fa93cbbcd415dba71bcc1
Author: Kévin Dietrich
Date:   Thu Sep 24 15:55:54 2020 +0200
Branches: cycles_procedural_api
https://developer.blender.org/rB0f48740d34c22e27143fa93cbbcd415dba71bcc1

fix compile errors with GTEST and Optix

===================================================================

M	intern/cycles/bvh/bvh_optix.cpp
M	intern/cycles/device/device_optix.cpp
M	intern/cycles/test/render_graph_finalize_test.cpp

===================================================================

diff --git a/intern/cycles/bvh/bvh_optix.cpp b/intern/cycles/bvh/bvh_optix.cpp
index 4ceb2880b49..e5c41c40db8 100644
--- a/intern/cycles/bvh/bvh_optix.cpp
+++ b/intern/cycles/bvh/bvh_optix.cpp
@@ -77,7 +77,7 @@ void BVHOptiX::pack_blas()
       // 'pack.prim_time' is only used in geom_curve_intersect.h
       // It is not needed because of OPTIX_MOTION_FLAG_[START|END]_VANISH
 
-      uint type = (hair->use_motion_blur &&
+      uint type = (hair->get_use_motion_blur() &&
                    hair->attributes.find(ATTR_STD_MOTION_VERTEX_POSITION)) ?
                       ((hair->curve_shape == CURVE_RIBBON) ? PRIMITIVE_MOTION_CURVE_RIBBON :
                                                              PRIMITIVE_MOTION_CURVE_THICK) :
@@ -104,7 +104,7 @@ void BVHOptiX::pack_blas()
       pack.prim_object.reserve(pack.prim_object.size() + num_triangles);
 
       uint type = PRIMITIVE_TRIANGLE;
-      if (mesh->use_motion_blur && mesh->attributes.find(ATTR_STD_MOTION_VERTEX_POSITION))
+      if (mesh->get_use_motion_blur() && mesh->attributes.find(ATTR_STD_MOTION_VERTEX_POSITION))
         type = PRIMITIVE_MOTION_TRIANGLE;
 
       for (size_t k = 0; k < num_triangles; ++k) {
@@ -116,14 +116,14 @@ void BVHOptiX::pack_blas()
   }
 
   // Initialize visibility to zero and later update it during top-level build
-  uint prev_visibility = objects[0]->visibility;
-  objects[0]->visibility = 0;
+  uint prev_visibility = objects[0]->get_visibility();
+  objects[0]->set_visibility(0);
 
   // Update 'pack.prim_tri_index', 'pack.prim_tri_verts' and 'pack.prim_visibility'
   pack_primitives();
 
   // Reset visibility after packing
-  objects[0]->visibility = prev_visibility;
+  objects[0]->set_visibility(prev_visibility);
 }
 
 void BVHOptiX::pack_tlas()
@@ -167,7 +167,7 @@ void BVHOptiX::pack_tlas()
     int object_index = 0;  // Unused for instanced geometry
     int object_visibility = 0;
     foreach (Object *ob, objects) {
-      if (ob->geometry == geom) {
+      if (ob->get_geometry() == geom) {
         object_visibility |= ob->visibility_for_tracing();
         if (!geom->is_instanced()) {
           object_index = ob->get_device_index();
diff --git a/intern/cycles/device/device_optix.cpp b/intern/cycles/device/device_optix.cpp
index 399328effe4..ad899950f53 100644
--- a/intern/cycles/device/device_optix.cpp
+++ b/intern/cycles/device/device_optix.cpp
@@ -1214,13 +1214,13 @@ class OptiXDevice : public CUDADevice {
     // Note: Always keep this logic in sync with bvh_optix.cpp!
     for (Object *ob : bvh->objects) {
       // Skip geometry for which acceleration structure already exists
-      Geometry *geom = ob->geometry;
+      Geometry *geom = ob->get_geometry();
       if (geometry.find(geom) != geometry.end())
         continue;
 
       if (geom->geometry_type == Geometry::HAIR) {
         // Build BLAS for curve primitives
-        Hair *const hair = static_cast<Hair *const>(ob->geometry);
+        Hair *const hair = static_cast<Hair *const>(ob->get_geometry());
         if (hair->num_curves() == 0) {
           continue;
         }
@@ -1229,8 +1229,8 @@ class OptiXDevice : public CUDADevice {
 
         size_t num_motion_steps = 1;
         Attribute *motion_keys = hair->attributes.find(ATTR_STD_MOTION_VERTEX_POSITION);
-        if (motion_blur && hair->use_motion_blur && motion_keys) {
-          num_motion_steps = hair->motion_steps;
+        if (motion_blur && hair->get_use_motion_blur() && motion_keys) {
+          num_motion_steps = hair->get_motion_steps();
         }
 
         device_vector<OptixAabb> aabb_data(this, "temp_aabb_data", MEM_READ_ONLY);
@@ -1250,16 +1250,17 @@ class OptiXDevice : public CUDADevice {
         // Get AABBs for each motion step
         for (size_t step = 0; step < num_motion_steps; ++step) {
           // The center step for motion vertices is not stored in the attribute
-          const float3 *keys = hair->curve_keys.data();
+          const float3 *keys = hair->get_curve_keys().data();
           size_t center_step = (num_motion_steps - 1) / 2;
           if (step != center_step) {
             size_t attr_offset = (step > center_step) ? step - 1 : step;
             // Technically this is a float4 array, but sizeof(float3) is the same as sizeof(float4)
-            keys = motion_keys->data_float3() + attr_offset * hair->curve_keys.size();
+            keys = motion_keys->data_float3() + attr_offset * hair->get_curve_keys().size();
           }
 
           for (size_t j = 0, i = 0; j < hair->num_curves(); ++j) {
             const Hair::Curve curve = hair->get_curve(j);
+            const array<float> &curve_radius = hair->get_curve_radius();
 
             for (int segment = 0; segment < curve.num_segments(); ++segment, ++i) {
 #  if OPTIX_ABI_VERSION >= 36
@@ -1272,10 +1273,10 @@ class OptiXDevice : public CUDADevice {
                 const float4 px = make_float4(keys[ka].x, keys[k0].x, keys[k1].x, keys[kb].x);
                 const float4 py = make_float4(keys[ka].y, keys[k0].y, keys[k1].y, keys[kb].y);
                 const float4 pz = make_float4(keys[ka].z, keys[k0].z, keys[k1].z, keys[kb].z);
-                const float4 pw = make_float4(hair->curve_radius[ka],
-                                              hair->curve_radius[k0],
-                                              hair->curve_radius[k1],
-                                              hair->curve_radius[kb]);
+                const float4 pw = make_float4(curve_radius[ka],
+                                              curve_radius[k0],
+                                              curve_radius[k1],
+                                              curve_radius[kb]);
 
                 // Convert Catmull-Rom data to Bezier spline
                 static const float4 cr2bsp0 = make_float4(+7, -4, +5, -2) / 6.f;
@@ -1298,7 +1299,7 @@ class OptiXDevice : public CUDADevice {
 #  endif
               {
                 BoundBox bounds = BoundBox::empty;
-                curve.bounds_grow(segment, keys, hair->curve_radius.data(), bounds);
+                curve.bounds_grow(segment, keys, hair->get_curve_radius().data(), bounds);
 
                 const size_t index = step * num_segments + i;
                 aabb_data[index].minX = bounds.min.x;
@@ -1383,7 +1384,7 @@ class OptiXDevice : public CUDADevice {
         // Allocate memory for new BLAS and build it
         OptixTraversableHandle handle;
         if (build_optix_bvh(build_input, num_motion_steps, handle)) {
-          geometry.insert({ob->geometry, handle});
+          geometry.insert({ob->get_geometry(), handle});
         }
         else {
           return false;
@@ -1391,27 +1392,27 @@ class OptiXDevice : public CUDADevice {
       }
       else if (geom->geometry_type == Geometry::MESH || geom->geometry_type == Geometry::VOLUME) {
         // Build BLAS for triangle primitives
-        Mesh *const mesh = static_cast<Mesh *const>(ob->geometry);
+        Mesh *const mesh = static_cast<Mesh *const>(ob->get_geometry());
         if (mesh->num_triangles() == 0) {
           continue;
         }
 
-        const size_t num_verts = mesh->verts.size();
+        const size_t num_verts = mesh->get_verts().size();
 
         size_t num_motion_steps = 1;
         Attribute *motion_keys = mesh->attributes.find(ATTR_STD_MOTION_VERTEX_POSITION);
-        if (motion_blur && mesh->use_motion_blur && motion_keys) {
-          num_motion_steps = mesh->motion_steps;
+        if (motion_blur && mesh->get_use_motion_blur() && motion_keys) {
+          num_motion_steps = mesh->get_motion_steps();
         }
 
         device_vector<int> index_data(this, "temp_index_data", MEM_READ_ONLY);
-        index_data.alloc(mesh->triangles.size());
-        memcpy(index_data.data(), mesh->triangles.data(), mesh->triangles.size() * sizeof(int));
+        index_data.alloc(mesh->get_triangles().size());
+        memcpy(index_data.data(), mesh->get_triangles().data(), mesh->get_triangles().size() * sizeof(int));
         device_vector<float3> vertex_data(this, "temp_vertex_data", MEM_READ_ONLY);
         vertex_data.alloc(num_verts * num_motion_steps);
 
         for (size_t step = 0; step < num_motion_steps; ++step) {
-          const float3 *verts = mesh->verts.data();
+          const float3 *verts = mesh->get_verts().data();
 
           size_t center_step = (num_motion_steps - 1) / 2;
           // The center step for motion vertices is not stored in the attribute
@@ -1455,7 +1456,7 @@ class OptiXDevice : public CUDADevice {
         // Allocate memory for new BLAS and build it
         OptixTraversableHandle handle;
         if (build_optix_bvh(build_input, num_motion_steps, handle)) {
-          geometry.insert({ob->geometry, handle});
+          geometry.insert({ob->get_geometry(), handle});
         }
         else {
           return false;
@@ -1475,7 +1476,7 @@ class OptiXDevice : public CUDADevice {
         continue;
 
       // Create separate instance for triangle/curve meshes of an object
-      auto handle_it = geometry.find(ob->geometry);
+      auto handle_it = geometry.find(ob->get_geometry());
       if (handle_it == geometry.end()) {
         continue;
       }
@@ -1503,18 +1504,18 @@ class OptiXDevice : public CUDADevice {
       // Have to have at least one bit in the mask, or else instance would always be culled
       instance.visibilityMask = 1;
 
-      if (ob->geometry->has_volume) {
+      if (ob->get_geometry()->has_volume) {
         // Volumes have a special bit set in the visibility mask so a trace can mask only volumes
         instance.visibilityMask |= 2;
       }
 
-      if (ob->geometry->geometry_type == Geometry::HAIR) {
+      if (ob->get_geometry()->geometry_type == Geometry::HAIR) {
         // Same applies to curves (so they can be skipped in local trace calls)
         instance.visibilityMask |= 4;
 
 #  if OPTIX_ABI_VERSION >= 36
-        if (motion_blur && ob->geometry->has_motion_blur() && DebugFlags().optix.curves_api &&
-            static_cast<const Hair *>(ob->geometry)->curve_shape == CURVE_THICK) {
+        if (motion_blur && ob->get_geometry()->has_motion_blur() && DebugFlags().optix.curves_api &&
+            static_cast<const Hair *>(ob->get_geome

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list