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:
authorMichael Jones <michael_p_jones@apple.com>2021-11-18 16:25:05 +0300
committerBrecht Van Lommel <brecht@blender.org>2021-11-18 16:38:02 +0300
commitd19e35873f67c90b251ca38e007a83aa1eada211 (patch)
tree7e8659acea7f12b188077ada225e113b5df35e60 /intern/cycles/util/transform.h
parentc0d52db783eb3a6288c9af04298b2358fec76357 (diff)
Cycles: several small fixes and additions for MSL
This patch contains many small leftover fixes and additions that are required for Metal-enablement: - Address space fixes and a few other small compile fixes - Addition of missing functionality to the Metal adapter headers - Addition of various scattered `__KERNEL_METAL__` blocks (e.g. for atomic support & maths functions) Ref T92212 Differential Revision: https://developer.blender.org/D13263
Diffstat (limited to 'intern/cycles/util/transform.h')
-rw-r--r--intern/cycles/util/transform.h23
1 files changed, 19 insertions, 4 deletions
diff --git a/intern/cycles/util/transform.h b/intern/cycles/util/transform.h
index 7bfe747fcfb..1d78dfd1385 100644
--- a/intern/cycles/util/transform.h
+++ b/intern/cycles/util/transform.h
@@ -53,6 +53,15 @@ typedef struct DecomposedTransform {
/* Functions */
+#ifdef __KERNEL_METAL__
+/* transform_point specialized for ccl_global */
+ccl_device_inline float3 transform_point(ccl_global const Transform *t, const float3 a)
+{
+ ccl_global const float3x3 &b(*(ccl_global const float3x3 *)t);
+ return (a * b).xyz + make_float3(t->x.w, t->y.w, t->z.w);
+}
+#endif
+
ccl_device_inline float3 transform_point(ccl_private const Transform *t, const float3 a)
{
/* TODO(sergey): Disabled for now, causes crashes in certain cases. */
@@ -73,6 +82,9 @@ ccl_device_inline float3 transform_point(ccl_private const Transform *t, const f
tmp += w;
return float3(tmp.m128);
+#elif defined(__KERNEL_METAL__)
+ ccl_private const float3x3 &b(*(ccl_private const float3x3 *)t);
+ return (a * b).xyz + make_float3(t->x.w, t->y.w, t->z.w);
#else
float3 c = make_float3(a.x * t->x.x + a.y * t->x.y + a.z * t->x.z + t->x.w,
a.x * t->y.x + a.y * t->y.y + a.z * t->y.z + t->y.w,
@@ -99,6 +111,9 @@ ccl_device_inline float3 transform_direction(ccl_private const Transform *t, con
tmp = madd(shuffle<2>(aa), z, tmp);
return float3(tmp.m128);
+#elif defined(__KERNEL_METAL__)
+ ccl_private const float3x3 &b(*(ccl_private const float3x3 *)t);
+ return (a * b).xyz;
#else
float3 c = make_float3(a.x * t->x.x + a.y * t->x.y + a.z * t->x.z,
a.x * t->y.x + a.y * t->y.y + a.z * t->y.z,
@@ -450,8 +465,8 @@ ccl_device_inline void transform_compose(ccl_private Transform *tfm,
}
/* Interpolate from array of decomposed transforms. */
-ccl_device void transform_motion_array_interpolate(Transform *tfm,
- const DecomposedTransform *motion,
+ccl_device void transform_motion_array_interpolate(ccl_private Transform *tfm,
+ ccl_global const DecomposedTransform *motion,
uint numsteps,
float time)
{
@@ -460,8 +475,8 @@ ccl_device void transform_motion_array_interpolate(Transform *tfm,
int step = min((int)(time * maxstep), maxstep - 1);
float t = time * maxstep - step;
- const DecomposedTransform *a = motion + step;
- const DecomposedTransform *b = motion + step + 1;
+ ccl_global const DecomposedTransform *a = motion + step;
+ ccl_global const DecomposedTransform *b = motion + step + 1;
/* Interpolate rotation, translation and scale. */
DecomposedTransform decomp;