diff options
author | Sergey Sharybin <sergey@blender.org> | 2022-02-10 16:12:35 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey@blender.org> | 2022-02-10 16:12:35 +0300 |
commit | d16e5babaf5c3bcb6fb407b49811d0b2f7c6456f (patch) | |
tree | 8060af46373a84733948560c161f5e984bb2183f /intern/cycles | |
parent | e2befa425a84c9e4ec715442e85624a5d3669a4f (diff) | |
parent | 04d55038ee52fc1155cc0ece916d90fd535c2364 (diff) |
Merge branch 'blender-v3.1-release'
Diffstat (limited to 'intern/cycles')
-rw-r--r-- | intern/cycles/bvh/embree.cpp | 6 | ||||
-rw-r--r-- | intern/cycles/device/device.cpp | 2 | ||||
-rw-r--r-- | intern/cycles/device/memory.h | 2 | ||||
-rw-r--r-- | intern/cycles/device/metal/bvh.mm | 2 | ||||
-rw-r--r-- | intern/cycles/device/optix/device_impl.cpp | 4 | ||||
-rw-r--r-- | intern/cycles/scene/hair.cpp | 12 | ||||
-rw-r--r-- | intern/cycles/scene/light.cpp | 4 | ||||
-rw-r--r-- | intern/cycles/scene/mesh.cpp | 2 | ||||
-rw-r--r-- | intern/cycles/scene/pointcloud.cpp | 2 | ||||
-rw-r--r-- | intern/cycles/util/algorithm.h | 2 | ||||
-rw-r--r-- | intern/cycles/util/math.h | 36 | ||||
-rw-r--r-- | intern/cycles/util/murmurhash.cpp | 2 |
12 files changed, 54 insertions, 22 deletions
diff --git a/intern/cycles/bvh/embree.cpp b/intern/cycles/bvh/embree.cpp index 616b6273e6a..731fef52063 100644 --- a/intern/cycles/bvh/embree.cpp +++ b/intern/cycles/bvh/embree.cpp @@ -471,7 +471,7 @@ void BVHEmbree::add_instance(Object *ob, int i) assert(instance_bvh != NULL); const size_t num_object_motion_steps = ob->use_motion() ? ob->get_motion().size() : 1; - const size_t num_motion_steps = min(num_object_motion_steps, RTC_MAX_TIME_STEP_COUNT); + const size_t num_motion_steps = min(num_object_motion_steps, (size_t)RTC_MAX_TIME_STEP_COUNT); assert(num_object_motion_steps <= RTC_MAX_TIME_STEP_COUNT); RTCGeometry geom_id = rtcNewGeometry(rtc_device, RTC_GEOMETRY_TYPE_INSTANCE); @@ -522,7 +522,7 @@ void BVHEmbree::add_triangles(const Object *ob, const Mesh *mesh, int i) } assert(num_motion_steps <= RTC_MAX_TIME_STEP_COUNT); - num_motion_steps = min(num_motion_steps, RTC_MAX_TIME_STEP_COUNT); + num_motion_steps = min(num_motion_steps, (size_t)RTC_MAX_TIME_STEP_COUNT); const size_t num_triangles = mesh->num_triangles(); @@ -775,7 +775,7 @@ void BVHEmbree::add_curves(const Object *ob, const Hair *hair, int i) } assert(num_motion_steps <= RTC_MAX_TIME_STEP_COUNT); - num_motion_steps = min(num_motion_steps, RTC_MAX_TIME_STEP_COUNT); + num_motion_steps = min(num_motion_steps, (size_t)RTC_MAX_TIME_STEP_COUNT); const size_t num_curves = hair->num_curves(); size_t num_segments = 0; diff --git a/intern/cycles/device/device.cpp b/intern/cycles/device/device.cpp index 14c97affb76..4d981e45ff1 100644 --- a/intern/cycles/device/device.cpp +++ b/intern/cycles/device/device.cpp @@ -335,7 +335,7 @@ DeviceInfo Device::get_multi_device(const vector<DeviceInfo> &subdevices, if (device.type == DEVICE_CPU && subdevices.size() > 1) { if (background) { int orig_cpu_threads = (threads) ? threads : TaskScheduler::max_concurrency(); - int cpu_threads = max(orig_cpu_threads - (subdevices.size() - 1), 0); + int cpu_threads = max(orig_cpu_threads - (subdevices.size() - 1), size_t(0)); VLOG(1) << "CPU render threads reduced from " << orig_cpu_threads << " to " << cpu_threads << ", to dedicate to GPU."; diff --git a/intern/cycles/device/memory.h b/intern/cycles/device/memory.h index 2db3ac9a440..5d7f1981e46 100644 --- a/intern/cycles/device/memory.h +++ b/intern/cycles/device/memory.h @@ -311,7 +311,7 @@ template<typename T> class device_only_memory : public device_memory { : device_memory(device, name, allow_host_memory_fallback ? MEM_READ_WRITE : MEM_DEVICE_ONLY) { data_type = device_type_traits<T>::data_type; - data_elements = max(device_type_traits<T>::num_elements, 1); + data_elements = max(device_type_traits<T>::num_elements, size_t(1)); } device_only_memory(device_only_memory &&other) noexcept : device_memory(std::move(other)) diff --git a/intern/cycles/device/metal/bvh.mm b/intern/cycles/device/metal/bvh.mm index 8b252f1a5ec..6c8288a7e0f 100644 --- a/intern/cycles/device/metal/bvh.mm +++ b/intern/cycles/device/metal/bvh.mm @@ -761,7 +761,7 @@ bool BVHMetal::build_TLAS(Progress &progress, num_instances++; if (ob->use_motion()) { - num_motion_transforms += max(1, ob->get_motion().size()); + num_motion_transforms += max((size_t)1, ob->get_motion().size()); } else { num_motion_transforms++; diff --git a/intern/cycles/device/optix/device_impl.cpp b/intern/cycles/device/optix/device_impl.cpp index cb6c36d5ea6..e49c67c7f91 100644 --- a/intern/cycles/device/optix/device_impl.cpp +++ b/intern/cycles/device/optix/device_impl.cpp @@ -1586,7 +1586,7 @@ void OptiXDevice::build_bvh(BVH *bvh, Progress &progress, bool refit) if (ob->is_traceable() && ob->use_motion()) { total_motion_transform_size = align_up(total_motion_transform_size, OPTIX_TRANSFORM_BYTE_ALIGNMENT); - const size_t motion_keys = max(ob->get_motion().size(), 2) - 2; + const size_t motion_keys = max(ob->get_motion().size(), (size_t)2) - 2; total_motion_transform_size = total_motion_transform_size + sizeof(OptixSRTMotionTransform) + motion_keys * sizeof(OptixSRTData); @@ -1660,7 +1660,7 @@ void OptiXDevice::build_bvh(BVH *bvh, Progress &progress, bool refit) /* Insert motion traversable if object has motion. */ if (motion_blur && ob->use_motion()) { - size_t motion_keys = max(ob->get_motion().size(), 2) - 2; + size_t motion_keys = max(ob->get_motion().size(), (size_t)2) - 2; size_t motion_transform_size = sizeof(OptixSRTMotionTransform) + motion_keys * sizeof(OptixSRTData); diff --git a/intern/cycles/scene/hair.cpp b/intern/cycles/scene/hair.cpp index 2951a609ae9..9ac502e2727 100644 --- a/intern/cycles/scene/hair.cpp +++ b/intern/cycles/scene/hair.cpp @@ -119,7 +119,7 @@ void Hair::Curve::motion_keys(const float3 *curve_keys, { /* Figure out which steps we need to fetch and their interpolation factor. */ const size_t max_step = num_steps - 1; - const size_t step = min((int)(time * max_step), max_step - 1); + const size_t step = std::min((size_t)(time * max_step), max_step - 1); const float t = time * max_step - step; /* Fetch vertex coordinates. */ float4 curr_keys[2]; @@ -147,7 +147,7 @@ void Hair::Curve::cardinal_motion_keys(const float3 *curve_keys, { /* Figure out which steps we need to fetch and their interpolation factor. */ const size_t max_step = num_steps - 1; - const size_t step = min((int)(time * max_step), max_step - 1); + const size_t step = min((size_t)(time * max_step), max_step - 1); const float t = time * max_step - step; /* Fetch vertex coordinates. */ float4 curr_keys[4]; @@ -191,8 +191,8 @@ void Hair::Curve::keys_for_step(const float3 *curve_keys, size_t k1, float4 r_keys[2]) const { - k0 = max(k0, 0); - k1 = min(k1, num_keys - 1); + k0 = max(k0, (size_t)0); + k1 = min(k1, (size_t)(num_keys - 1)); const size_t center_step = ((num_steps - 1) / 2); if (step == center_step) { /* Center step: regular key location. */ @@ -237,8 +237,8 @@ void Hair::Curve::cardinal_keys_for_step(const float3 *curve_keys, size_t k3, float4 r_keys[4]) const { - k0 = max(k0, 0); - k3 = min(k3, num_keys - 1); + k0 = max(k0, (size_t)0); + k3 = min(k3, (size_t)(num_keys - 1)); const size_t center_step = ((num_steps - 1) / 2); if (step == center_step) { /* Center step: regular key location. */ diff --git a/intern/cycles/scene/light.cpp b/intern/cycles/scene/light.cpp index 83e531f42ef..415c4044aee 100644 --- a/intern/cycles/scene/light.cpp +++ b/intern/cycles/scene/light.cpp @@ -606,8 +606,8 @@ void LightManager::device_update_background(Device *device, ImageMetaData metadata; if (!env->handle.empty()) { ImageMetaData metadata = env->handle.metadata(); - environment_res.x = max(environment_res.x, metadata.width); - environment_res.y = max(environment_res.y, metadata.height); + environment_res.x = max(environment_res.x, (int)metadata.width); + environment_res.y = max(environment_res.y, (int)metadata.height); } } if (node->type == SkyTextureNode::get_node_type()) { diff --git a/intern/cycles/scene/mesh.cpp b/intern/cycles/scene/mesh.cpp index c381d7a54ff..f53dca88ee0 100644 --- a/intern/cycles/scene/mesh.cpp +++ b/intern/cycles/scene/mesh.cpp @@ -53,7 +53,7 @@ void Mesh::Triangle::motion_verts(const float3 *verts, { /* Figure out which steps we need to fetch and their interpolation factor. */ const size_t max_step = num_steps - 1; - const size_t step = min((int)(time * max_step), max_step - 1); + const size_t step = min((size_t)(time * max_step), max_step - 1); const float t = time * max_step - step; /* Fetch vertex coordinates. */ float3 curr_verts[3]; diff --git a/intern/cycles/scene/pointcloud.cpp b/intern/cycles/scene/pointcloud.cpp index 4f88fe9db3d..6356a5030f3 100644 --- a/intern/cycles/scene/pointcloud.cpp +++ b/intern/cycles/scene/pointcloud.cpp @@ -55,7 +55,7 @@ float4 PointCloud::Point::motion_key(const float3 *points, /* Figure out which steps we need to fetch and their * interpolation factor. */ const size_t max_step = num_steps - 1; - const size_t step = min((int)(time * max_step), max_step - 1); + const size_t step = min((size_t)(time * max_step), max_step - 1); const float t = time * max_step - step; /* Fetch vertex coordinates. */ const float4 curr_key = point_for_step( diff --git a/intern/cycles/util/algorithm.h b/intern/cycles/util/algorithm.h index 63abd4e92a3..7a37ca0fdf4 100644 --- a/intern/cycles/util/algorithm.h +++ b/intern/cycles/util/algorithm.h @@ -21,8 +21,6 @@ CCL_NAMESPACE_BEGIN -using std::max; -using std::min; using std::remove; using std::sort; using std::stable_sort; diff --git a/intern/cycles/util/math.h b/intern/cycles/util/math.h index 605a19aaef0..2bfd4ba19b6 100644 --- a/intern/cycles/util/math.h +++ b/intern/cycles/util/math.h @@ -124,7 +124,41 @@ ccl_device_inline int min(int a, int b) return (a < b) ? a : b; } -ccl_device_inline uint min(uint a, uint b) +ccl_device_inline uint32_t max(uint32_t a, uint32_t b) +{ + return (a > b) ? a : b; +} + +ccl_device_inline uint32_t min(uint32_t a, uint32_t b) +{ + return (a < b) ? a : b; +} + +ccl_device_inline uint64_t max(uint64_t a, uint64_t b) +{ + return (a > b) ? a : b; +} + +ccl_device_inline uint64_t min(uint64_t a, uint64_t b) +{ + return (a < b) ? a : b; +} + +/* NOTE: On 64bit Darwin the `size_t` is defined as `unsigned long int` and `uint64_t` is defined + * as `unsigned long long`. Both of the definitions are 64 bit unsigned integer, but the automatic + * substitution does not allow to automatically pick function defined for `uint64_t` as it is not + * exactly the same type definition. + * Work this around by adding a templated function enabled for `size_t` type which will be used + * when there is no explicit specialization of `min()`/`max()` above. */ + +template<class T> +ccl_device_inline typename std::enable_if_t<std::is_same_v<T, size_t>, T> max(T a, T b) +{ + return (a > b) ? a : b; +} + +template<class T> +ccl_device_inline typename std::enable_if_t<std::is_same_v<T, size_t>, T> min(T a, T b) { return (a < b) ? a : b; } diff --git a/intern/cycles/util/murmurhash.cpp b/intern/cycles/util/murmurhash.cpp index 9ba0a282cc2..603e4a717a1 100644 --- a/intern/cycles/util/murmurhash.cpp +++ b/intern/cycles/util/murmurhash.cpp @@ -23,7 +23,7 @@ #include <stdlib.h> #include <string.h> -#include "util/algorithm.h" +#include "util/math.h" #include "util/murmurhash.h" #if defined(_MSC_VER) |