Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Sharybin <sergey@blender.org>2022-02-10 12:37:00 +0300
committerSergey Sharybin <sergey@blender.org>2022-02-10 14:39:41 +0300
commit04d55038ee52fc1155cc0ece916d90fd535c2364 (patch)
treec216c00833a652d914a3a7012751bdd4c2fb90a9 /intern/cycles/device/optix/device_impl.cpp
parent87d2de88fdeec75c7dcd77f93d51ee71542b45ce (diff)
Fix size_t -> int -> size_t round trip in Cycles
There are two things achieved by this change: - No possible downcast of size_t to int when calculating motion steps. - Disambiguate call to `min()` which was for some reason considered ambiguous on 32bit platforms `min(int, unsigned int)`. - Do the same for the `max()` call to keep them symmetrical. On an implementation side the `min()` is defined for a fixed width integer type to disambiguate uint from size_t on 32bit platforms, and yet be able to use it for 32bit operands on 64bit platforms without upcast. This ended up in a bit bigger change as the conditional compile-in of functions is easiest if the functions is templated. Making the functions templated required to remove the other source of ambiguity which is `algorithm.h` which was pulling min/max from std. Now it is the `math.h` which is the source of truth for min/max. It was only one place which was relying on `algorithm.h` for these functions, hence the choice of `math.h` as the safest and least intrusive. Fixes 32bit platforms (such as i386) in Debian package build system. Differential Revision: https://developer.blender.org/D14062
Diffstat (limited to 'intern/cycles/device/optix/device_impl.cpp')
-rw-r--r--intern/cycles/device/optix/device_impl.cpp4
1 files changed, 2 insertions, 2 deletions
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);