From f613c4c0953ebaf993ecd55b12bab9cf2196dac4 Mon Sep 17 00:00:00 2001 From: Michael Jones Date: Mon, 29 Nov 2021 15:06:22 +0000 Subject: Cycles: MetalRT support (kernel side) This patch adds MetalRT support to Cycles kernel code. It is mostly additive in nature or confined to Metal-specific code, however there are a few areas where this interacts with other code: - MetalRT closely follows the Optix implementation, and in some cases (notably handling of transforms) it makes sense to extend Optix special-casing to MetalRT. For these generalisations we now have `__KERNEL_GPU_RAYTRACING__` instead of `__KERNEL_OPTIX__`. - MetalRT doesn't support primitive offsetting (as with `primitiveIndexOffset` in Optix), so we define and populate a new kernel texture, `__object_prim_offset`, containing per-object primitive / curve-segment offsets. This is referenced and applied in MetalRT intersection handlers. - Two new BVH layout enum values have been added: `BVH_LAYOUT_METAL` and `BVH_LAYOUT_MULTI_METAL_EMBREE` for XPU mode). Some host-side enum case handling has been updated where it is trivial to do so. Ref T92212 Reviewed By: brecht Maniphest Tasks: T92212 Differential Revision: https://developer.blender.org/D13353 --- intern/cycles/util/math_float3.h | 4 ++-- intern/cycles/util/transform.h | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'intern/cycles/util') diff --git a/intern/cycles/util/math_float3.h b/intern/cycles/util/math_float3.h index 1a0213f2a6d..74f1c98e649 100644 --- a/intern/cycles/util/math_float3.h +++ b/intern/cycles/util/math_float3.h @@ -233,7 +233,7 @@ ccl_device_inline float3 operator/=(float3 &a, float f) return a = a * invf; } -#if !(defined(__KERNEL_METAL__) || defined(__KERNEL_CUDA__)) +# if !(defined(__KERNEL_METAL__) || defined(__KERNEL_CUDA__)) ccl_device_inline packed_float3 operator*=(packed_float3 &a, const float3 &b) { a = float3(a) * b; @@ -257,7 +257,7 @@ ccl_device_inline packed_float3 operator/=(packed_float3 &a, float f) a = float3(a) / f; return a; } -#endif +# endif ccl_device_inline bool operator==(const float3 &a, const float3 &b) { diff --git a/intern/cycles/util/transform.h b/intern/cycles/util/transform.h index 1d78dfd1385..80cd37d35e2 100644 --- a/intern/cycles/util/transform.h +++ b/intern/cycles/util/transform.h @@ -366,10 +366,10 @@ ccl_device_inline Transform transform_empty() ccl_device_inline float4 quat_interpolate(float4 q1, float4 q2, float t) { - /* Optix is using lerp to interpolate motion transformations. */ -#ifdef __KERNEL_OPTIX__ + /* Optix and MetalRT are using lerp to interpolate motion transformations. */ +#if defined(__KERNEL_GPU_RAYTRACING__) return normalize((1.0f - t) * q1 + t * q2); -#else /* __KERNEL_OPTIX__ */ +#else /* defined(__KERNEL_GPU_RAYTRACING__) */ /* note: this does not ensure rotation around shortest angle, q1 and q2 * are assumed to be matched already in transform_motion_decompose */ float costheta = dot(q1, q2); @@ -387,7 +387,7 @@ ccl_device_inline float4 quat_interpolate(float4 q1, float4 q2, float t) float thetap = theta * t; return q1 * cosf(thetap) + qperp * sinf(thetap); } -#endif /* __KERNEL_OPTIX__ */ +#endif /* defined(__KERNEL_GPU_RAYTRACING__) */ } ccl_device_inline Transform transform_quick_inverse(Transform M) -- cgit v1.2.3