Commit: d5551729bf65b57b19ec447adc236fe8fb2013db
Author: Kévin Dietrich
Date:   Tue May 26 03:38:44 2015 +0200
Branches: openvdb
https://developer.blender.org/rBd5551729bf65b57b19ec447adc236fe8fb2013db

Wrap volume sampling call in a macro.

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

M       intern/cycles/kernel/kernel_compat_cpu.h
M       intern/cycles/kernel/kernel_types.h
M       intern/cycles/kernel/svm/svm_openvdb.h
M       intern/cycles/render/openvdb.cpp
M       intern/cycles/util/util_openvdb.h

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

diff --git a/intern/cycles/kernel/kernel_compat_cpu.h 
b/intern/cycles/kernel/kernel_compat_cpu.h
index 6da0021..acbfd67 100644
--- a/intern/cycles/kernel/kernel_compat_cpu.h
+++ b/intern/cycles/kernel/kernel_compat_cpu.h
@@ -417,6 +417,8 @@ typedef texture_image<uchar4> texture_image_uchar4;
 #define kernel_tex_image_interp(tex, x, y) ((tex < MAX_FLOAT_IMAGES) ? 
kg->texture_float_images[tex].interp(x, y) : kg->texture_byte_images[tex - 
MAX_FLOAT_IMAGES].interp(x, y))
 #define kernel_tex_image_interp_3d(tex, x, y, z) ((tex < MAX_FLOAT_IMAGES) ? 
kg->texture_float_images[tex].interp_3d(x, y, z) : kg->texture_byte_images[tex 
- MAX_FLOAT_IMAGES].interp_3d(x, y, z))
 #define kernel_tex_image_interp_3d_ex(tex, x, y, z, interpolation) ((tex < 
MAX_FLOAT_IMAGES) ? kg->texture_float_images[tex].interp_3d_ex(x, y, z, 
interpolation) : kg->texture_byte_images[tex - 
MAX_FLOAT_IMAGES].interp_3d_ex(x, y, z, interpolation))
+#define kernel_tex_voxel_float(tex, x, y, z, sampling) 
(kg->float_volumes[tex]->sample(x, y, z, sampling))
+#define kernel_tex_voxel_float3(tex, x, y, z, sampling) 
(kg->float3_volumes[tex]->sample(x, y, z, sampling))
 
 #define kernel_data (kg->__data)
 
diff --git a/intern/cycles/kernel/kernel_types.h 
b/intern/cycles/kernel/kernel_types.h
index d2a37fa..794cc86 100644
--- a/intern/cycles/kernel/kernel_types.h
+++ b/intern/cycles/kernel/kernel_types.h
@@ -977,7 +977,8 @@ typedef struct KernelCurves {
 
 typedef struct KernelTables {
        int beckmann_offset;
-       int pad1, pad2, pad3;
+       int num_volumes;
+       int pad1, pad2;
 } KernelTables;
 
 typedef struct KernelData {
diff --git a/intern/cycles/kernel/svm/svm_openvdb.h 
b/intern/cycles/kernel/svm/svm_openvdb.h
index c711f6c..8820dae 100644
--- a/intern/cycles/kernel/svm/svm_openvdb.h
+++ b/intern/cycles/kernel/svm/svm_openvdb.h
@@ -34,14 +34,14 @@ ccl_device void svm_node_openvdb(KernelGlobals *kg, 
ShaderData *sd, float *stack
        co = transform_point(&tfm, co);
 
        if(type == NODE_VDB_FLOAT) {
-               float out = kg->float_volumes[slot]->sample(sampling, co);
+               float out = kernel_tex_voxel_float(slot, co.x, co.y, co.z, 
sampling);
 
                if(stack_valid(out_offset)) {
                        stack_store_float(stack, out_offset, out);
                }
        }
        else if(type == NODE_VDB_FLOAT3) {
-               float3 out = kg->float3_volumes[slot]->sample(sampling, co);
+               float3 out = kernel_tex_voxel_float3(slot, co.x, co.y, co.z, 
sampling);
 
                if(stack_valid(out_offset)) {
                        stack_store_float3(stack, out_offset, out);
diff --git a/intern/cycles/render/openvdb.cpp b/intern/cycles/render/openvdb.cpp
index 1381c6c..618c585 100644
--- a/intern/cycles/render/openvdb.cpp
+++ b/intern/cycles/render/openvdb.cpp
@@ -223,6 +223,8 @@ void VolumeManager::device_update(Device *device, 
DeviceScene *dscene, Scene *sc
                return;
        }
 
+       dscene->data.tables.num_volumes = float_volumes.size() + 
float3_volumes.size();
+
        VLOG(1) << "Volume samplers allocate: __float_volume, " << 
float_volumes.size() * sizeof(float_volume) << " bytes";
        VLOG(1) << "Volume samplers allocate: __float3_volume, " << 
float3_volumes.size() * sizeof(float3_volume) << " bytes";
 
diff --git a/intern/cycles/util/util_openvdb.h 
b/intern/cycles/util/util_openvdb.h
index e24e18b..2bbadfc 100644
--- a/intern/cycles/util/util_openvdb.h
+++ b/intern/cycles/util/util_openvdb.h
@@ -19,7 +19,7 @@ enum {
 class float_volume {
 public:
        virtual ~float_volume() {}
-       virtual float sample(int sampling, float3 co) = 0;
+       virtual float sample(float x, float y, float z, int sampling) = 0;
        virtual bool intersect(const Ray *ray, Intersection *isect) = 0;
        virtual bool march(float *t0, float *t1) = 0;
 };
@@ -27,7 +27,7 @@ public:
 class float3_volume {
 public:
        virtual ~float3_volume() {}
-       virtual float3 sample(int sampling, float3 co) = 0;
+       virtual float3 sample(float x, float y, float z, int sampling) = 0;
        virtual bool intersect(const Ray *ray, Intersection *isect) = 0;
        virtual bool march(float *t0, float *t1) = 0;
 };
@@ -67,7 +67,7 @@ class vdb_float_volume : public float_volume {
 
        /* Main intersector, its purpose is to initialize the voxels' bounding 
box
         * so the ones for the various threads do not do this, rather they are
-        * generated from of copy of it */
+        * generated from a copy of it */
        isector_t *main_isector;
 
        bool uniform_voxels;
@@ -117,7 +117,7 @@ public:
                }
        }
 
-       ccl_always_inline float sample(int sampling, float3 co)
+       ccl_always_inline float sample(float x, float y, float z, int sampling)
        {
                pthread_t thread = pthread_self();
 
@@ -135,7 +135,7 @@ public:
                                sampler = iter->second;
                        }
 
-                       return sampler->wsSample(openvdb::Vec3d(co.x, co.y, 
co.z));
+                       return sampler->wsSample(openvdb::Vec3d(x, y, z));
                }
                else {
                        box_map::iterator iter = box_samplers.find(thread);
@@ -151,7 +151,7 @@ public:
                                sampler = iter->second;
                        }
 
-                       return sampler->wsSample(openvdb::Vec3d(co.x, co.y, 
co.z));
+                       return sampler->wsSample(openvdb::Vec3d(x, y, z));
                }
        }
 
@@ -182,7 +182,7 @@ public:
 
                if(vdb_isect->setWorldRay(vdb_ray)) {
                        // TODO
-//                     isect->t = t;
+//                     isect->t = vdb_ray.t1(); // (kevin) is this correct?
 //                     isect->u = isect->v = 1.0f;
 //                     isect->type = ;
 //                     isect->shad = shader;
@@ -252,7 +252,7 @@ class vdb_float3_volume : public float3_volume {
 
        /* Main intersector, its purpose is to initialize the voxels' bounding 
box
         * so the ones for the various threads do not do this, rather they are
-        * generated from of copy of it. */
+        * generated from a copy of it. */
        isector_t *main_isector;
 
        bool uniform_voxels;
@@ -302,7 +302,7 @@ public:
                }
        }
 
-       ccl_always_inline float3 sample(int sampling, float3 co)
+       ccl_always_inline float3 sample(float x, float y, float z, int sampling)
        {
                openvdb::Vec3s r;
                pthread_t thread = pthread_self();
@@ -321,7 +321,7 @@ public:
                                sampler = iter->second;
                        }
 
-                       r = sampler->wsSample(openvdb::Vec3d(co.x, co.y, co.z));
+                       r = sampler->wsSample(openvdb::Vec3d(x, y, z));
                }
                else {
                        box_map::iterator iter = box_samplers.find(thread);
@@ -337,7 +337,7 @@ public:
                                sampler = iter->second;
                        }
 
-                       r = sampler->wsSample(openvdb::Vec3d(co.x, co.y, co.z));
+                       r = sampler->wsSample(openvdb::Vec3d(x, y, z));
                }
 
                return make_float3(r.x(), r.y(), r.z());
@@ -370,7 +370,7 @@ public:
 
                if(vdb_isect->setWorldRay(vdb_ray)) {
                        // TODO
-//                     isect->t = t;
+//                     isect->t = vdb_ray.t1(); // (kevin) is this correct?
 //                     isect->u = isect->v = 1.0f;
 //                     isect->type = ;
 //                     isect->shad = shader;

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to