From aeb103fb501ee54112c66aba184d5fe6e9918eda Mon Sep 17 00:00:00 2001 From: Xavier Hallade Date: Mon, 8 Sep 2025 09:22:32 +0200 Subject: [PATCH] Cycles: Pack uint3/int3 structs for oneAPI This recently changed after a fix in 28f93d544301b3dd8201350dc0cdd70bfdd3f29c but we get better performance by ensuring int3 is packed instead. Packing int3 currently gives a 7% speedup when rendering wdas_cloud on Intel Arc B580. Pull Request: https://projects.blender.org/blender/blender/pulls/145593 --- intern/cycles/util/types_int3.h | 9 +++++++-- intern/cycles/util/types_uint3.h | 4 ++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/intern/cycles/util/types_int3.h b/intern/cycles/util/types_int3.h index d170c066a0b..8e8af27b55e 100644 --- a/intern/cycles/util/types_int3.h +++ b/intern/cycles/util/types_int3.h @@ -9,7 +9,12 @@ CCL_NAMESPACE_BEGIN #ifndef __KERNEL_NATIVE_VECTOR_TYPES__ +# ifdef __KERNEL_ONEAPI__ +/* Keep structure packed for oneAPI. */ +struct int3 +# else struct ccl_try_align(16) int3 +# endif { # ifdef __KERNEL_GPU__ /* Compact structure on the GPU. */ @@ -98,8 +103,8 @@ ccl_device_inline void print_int3(const ccl_private char *label, const int3 a) #if defined(__KERNEL_METAL__) /* Metal has native packed_int3. */ -#elif defined(__KERNEL_CUDA__) -/* CUDA is already packed. */ +#elif defined(__KERNEL_CUDA__) || defined(__KERNEL_ONEAPI__) +/* CUDA/oneAPI int3 is already packed. */ typedef int3 packed_int3; #else /* HIP int3 is not packed (https://github.com/ROCm-Developer-Tools/HIP/issues/706). */ diff --git a/intern/cycles/util/types_uint3.h b/intern/cycles/util/types_uint3.h index 7b9dda8022b..e107a0af38b 100644 --- a/intern/cycles/util/types_uint3.h +++ b/intern/cycles/util/types_uint3.h @@ -36,8 +36,8 @@ ccl_device_inline uint3 make_uint3(const uint x, const uint y, uint z) #if defined(__KERNEL_METAL__) /* Metal has native packed_float3. */ -#elif defined(__KERNEL_CUDA__) -/* CUDA uint3 is already packed. */ +#elif defined(__KERNEL_CUDA__) || defined(__KERNEL_ONEAPI__) +/* CUDA/oneAPI uint3 is already packed. */ using packed_uint3 = uint3; #else /* HIP uint3 is not packed (https://github.com/ROCm-Developer-Tools/HIP/issues/706). */