[Bf-blender-cvs] [65dcb5ebd34] master: Cycles: Semantically separate 2D and 3D texture objects

Stefan Werner noreply at git.blender.org
Fri Apr 1 20:09:18 CEST 2022


Commit: 65dcb5ebd3440b096637c47807777fb07d430904
Author: Stefan Werner
Date:   Fri Apr 1 19:44:31 2022 +0200
Branches: master
https://developer.blender.org/rB65dcb5ebd3440b096637c47807777fb07d430904

Cycles: Semantically separate 2D and 3D texture objects

Currently there are no functional changes.

Preparing for an upcoming oneAPI integration where such separation
in types is needed.

===================================================================

M	intern/cycles/kernel/device/cuda/compat.h
M	intern/cycles/kernel/device/gpu/image.h
M	intern/cycles/kernel/device/hip/compat.h
M	intern/cycles/kernel/device/metal/context_begin.h
M	intern/cycles/kernel/device/optix/compat.h

===================================================================

diff --git a/intern/cycles/kernel/device/cuda/compat.h b/intern/cycles/kernel/device/cuda/compat.h
index b392455c740..51e1381d552 100644
--- a/intern/cycles/kernel/device/cuda/compat.h
+++ b/intern/cycles/kernel/device/cuda/compat.h
@@ -76,10 +76,11 @@ typedef unsigned long long uint64_t;
 /* GPU texture objects */
 
 typedef unsigned long long CUtexObject;
-typedef CUtexObject ccl_gpu_tex_object;
+typedef CUtexObject ccl_gpu_tex_object_2D;
+typedef CUtexObject ccl_gpu_tex_object_3D;
 
 template<typename T>
-ccl_device_forceinline T ccl_gpu_tex_object_read_2D(const ccl_gpu_tex_object texobj,
+ccl_device_forceinline T ccl_gpu_tex_object_read_2D(const ccl_gpu_tex_object_2D texobj,
                                                     const float x,
                                                     const float y)
 {
@@ -87,7 +88,7 @@ ccl_device_forceinline T ccl_gpu_tex_object_read_2D(const ccl_gpu_tex_object tex
 }
 
 template<typename T>
-ccl_device_forceinline T ccl_gpu_tex_object_read_3D(const ccl_gpu_tex_object texobj,
+ccl_device_forceinline T ccl_gpu_tex_object_read_3D(const ccl_gpu_tex_object_3D texobj,
                                                     const float x,
                                                     const float y,
                                                     const float z)
diff --git a/intern/cycles/kernel/device/gpu/image.h b/intern/cycles/kernel/device/gpu/image.h
index 83e7aa869c1..c5bc7d88e02 100644
--- a/intern/cycles/kernel/device/gpu/image.h
+++ b/intern/cycles/kernel/device/gpu/image.h
@@ -56,7 +56,7 @@ ccl_device_noinline T kernel_tex_image_interp_bicubic(ccl_global const TextureIn
                                                       float x,
                                                       float y)
 {
-  ccl_gpu_tex_object tex = (ccl_gpu_tex_object)info.data;
+  ccl_gpu_tex_object_2D tex = (ccl_gpu_tex_object_2D)info.data;
 
   x = (x * info.width) - 0.5f;
   y = (y * info.height) - 0.5f;
@@ -85,7 +85,7 @@ template<typename T>
 ccl_device_noinline T
 kernel_tex_image_interp_tricubic(ccl_global const TextureInfo &info, float x, float y, float z)
 {
-  ccl_gpu_tex_object tex = (ccl_gpu_tex_object)info.data;
+  ccl_gpu_tex_object_3D tex = (ccl_gpu_tex_object_3D)info.data;
 
   x = (x * info.width) - 0.5f;
   y = (y * info.height) - 0.5f;
@@ -190,7 +190,7 @@ ccl_device float4 kernel_tex_image_interp(KernelGlobals kg, int id, float x, flo
       return kernel_tex_image_interp_bicubic<float4>(info, x, y);
     }
     else {
-      ccl_gpu_tex_object tex = (ccl_gpu_tex_object)info.data;
+      ccl_gpu_tex_object_2D tex = (ccl_gpu_tex_object_2D)info.data;
       return ccl_gpu_tex_object_read_2D<float4>(tex, x, y);
     }
   }
@@ -202,7 +202,7 @@ ccl_device float4 kernel_tex_image_interp(KernelGlobals kg, int id, float x, flo
       f = kernel_tex_image_interp_bicubic<float>(info, x, y);
     }
     else {
-      ccl_gpu_tex_object tex = (ccl_gpu_tex_object)info.data;
+      ccl_gpu_tex_object_2D tex = (ccl_gpu_tex_object_2D)info.data;
       f = ccl_gpu_tex_object_read_2D<float>(tex, x, y);
     }
 
@@ -245,7 +245,7 @@ ccl_device float4 kernel_tex_image_interp_3d(KernelGlobals kg,
       return kernel_tex_image_interp_tricubic<float4>(info, x, y, z);
     }
     else {
-      ccl_gpu_tex_object tex = (ccl_gpu_tex_object)info.data;
+      ccl_gpu_tex_object_3D tex = (ccl_gpu_tex_object_3D)info.data;
       return ccl_gpu_tex_object_read_3D<float4>(tex, x, y, z);
     }
   }
@@ -256,7 +256,7 @@ ccl_device float4 kernel_tex_image_interp_3d(KernelGlobals kg,
       f = kernel_tex_image_interp_tricubic<float>(info, x, y, z);
     }
     else {
-      ccl_gpu_tex_object tex = (ccl_gpu_tex_object)info.data;
+      ccl_gpu_tex_object_3D tex = (ccl_gpu_tex_object_3D)info.data;
       f = ccl_gpu_tex_object_read_3D<float>(tex, x, y, z);
     }
 
diff --git a/intern/cycles/kernel/device/hip/compat.h b/intern/cycles/kernel/device/hip/compat.h
index 29fbc119cd1..9c93d87fd87 100644
--- a/intern/cycles/kernel/device/hip/compat.h
+++ b/intern/cycles/kernel/device/hip/compat.h
@@ -73,10 +73,11 @@ typedef unsigned long long uint64_t;
 #define ccl_gpu_ballot(predicate) __ballot(predicate)
 
 /* GPU texture objects */
-typedef hipTextureObject_t ccl_gpu_tex_object;
+typedef hipTextureObject_t ccl_gpu_tex_object_2D;
+typedef hipTextureObject_t ccl_gpu_tex_object_3D;
 
 template<typename T>
-ccl_device_forceinline T ccl_gpu_tex_object_read_2D(const ccl_gpu_tex_object texobj,
+ccl_device_forceinline T ccl_gpu_tex_object_read_2D(const ccl_gpu_tex_object_2D texobj,
                                                     const float x,
                                                     const float y)
 {
@@ -84,7 +85,7 @@ ccl_device_forceinline T ccl_gpu_tex_object_read_2D(const ccl_gpu_tex_object tex
 }
 
 template<typename T>
-ccl_device_forceinline T ccl_gpu_tex_object_read_3D(const ccl_gpu_tex_object texobj,
+ccl_device_forceinline T ccl_gpu_tex_object_read_3D(const ccl_gpu_tex_object_3D texobj,
                                                     const float x,
                                                     const float y,
                                                     const float z)
diff --git a/intern/cycles/kernel/device/metal/context_begin.h b/intern/cycles/kernel/device/metal/context_begin.h
index 4c9d6b6e405..99cb1e3826e 100644
--- a/intern/cycles/kernel/device/metal/context_begin.h
+++ b/intern/cycles/kernel/device/metal/context_begin.h
@@ -19,17 +19,18 @@ class MetalKernelContext {
     {}
 
     /* texture fetch adapter functions */
-    typedef uint64_t ccl_gpu_tex_object;
+    typedef uint64_t ccl_gpu_tex_object_2D;
+    typedef uint64_t ccl_gpu_tex_object_3D;
 
     template<typename T>
     inline __attribute__((__always_inline__))
-    T ccl_gpu_tex_object_read_2D(ccl_gpu_tex_object tex, float x, float y) const {
+    T ccl_gpu_tex_object_read_2D(ccl_gpu_tex_object_2D tex, float x, float y) const {
       kernel_assert(0);
       return 0;
     }
     template<typename T>
     inline __attribute__((__always_inline__))
-    T ccl_gpu_tex_object_read_3D(ccl_gpu_tex_object tex, float x, float y, float z) const {
+    T ccl_gpu_tex_object_read_3D(ccl_gpu_tex_object_3D tex, float x, float y, float z) const {
       kernel_assert(0);
       return 0;
     }
@@ -37,14 +38,14 @@ class MetalKernelContext {
     // texture2d
     template<>
     inline __attribute__((__always_inline__))
-    float4 ccl_gpu_tex_object_read_2D(ccl_gpu_tex_object tex, float x, float y) const {
+    float4 ccl_gpu_tex_object_read_2D(ccl_gpu_tex_object_2D tex, float x, float y) const {
       const uint tid(tex);
       const uint sid(tex >> 32);
       return metal_ancillaries->textures_2d[tid].tex.sample(metal_samplers[sid], float2(x, y));
     }
     template<>
     inline __attribute__((__always_inline__))
-    float ccl_gpu_tex_object_read_2D(ccl_gpu_tex_object tex, float x, float y) const {
+    float ccl_gpu_tex_object_read_2D(ccl_gpu_tex_object_2D tex, float x, float y) const {
       const uint tid(tex);
       const uint sid(tex >> 32);
       return metal_ancillaries->textures_2d[tid].tex.sample(metal_samplers[sid], float2(x, y)).x;
@@ -53,14 +54,14 @@ class MetalKernelContext {
     // texture3d
     template<>
     inline __attribute__((__always_inline__))
-    float4 ccl_gpu_tex_object_read_3D(ccl_gpu_tex_object tex, float x, float y, float z) const {
+    float4 ccl_gpu_tex_object_read_3D(ccl_gpu_tex_object_3D tex, float x, float y, float z) const {
       const uint tid(tex);
       const uint sid(tex >> 32);
       return metal_ancillaries->textures_3d[tid].tex.sample(metal_samplers[sid], float3(x, y, z));
     }
     template<>
     inline __attribute__((__always_inline__))
-    float ccl_gpu_tex_object_read_3D(ccl_gpu_tex_object tex, float x, float y, float z) const {
+    float ccl_gpu_tex_object_read_3D(ccl_gpu_tex_object_3D tex, float x, float y, float z) const {
       const uint tid(tex);
       const uint sid(tex >> 32);
       return metal_ancillaries->textures_3d[tid].tex.sample(metal_samplers[sid], float3(x, y, z)).x;
diff --git a/intern/cycles/kernel/device/optix/compat.h b/intern/cycles/kernel/device/optix/compat.h
index ae7a0309e51..aa4a6321a8b 100644
--- a/intern/cycles/kernel/device/optix/compat.h
+++ b/intern/cycles/kernel/device/optix/compat.h
@@ -78,10 +78,11 @@ typedef unsigned long long uint64_t;
 /* GPU texture objects */
 
 typedef unsigned long long CUtexObject;
-typedef CUtexObject ccl_gpu_tex_object;
+typedef CUtexObject ccl_gpu_tex_object_2D;
+typedef CUtexObject ccl_gpu_tex_object_3D;
 
 template<typename T>
-ccl_device_forceinline T ccl_gpu_tex_object_read_2D(const ccl_gpu_tex_object texobj,
+ccl_device_forceinline T ccl_gpu_tex_object_read_2D(const ccl_gpu_tex_object_2D texobj,
                                                     const float x,
                                                     const float y)
 {
@@ -89,7 +90,7 @@ ccl_device_forceinline T ccl_gpu_tex_object_read_2D(const ccl_gpu_tex_object tex
 }
 
 template<typename T>
-ccl_device_forceinline T ccl_gpu_tex_object_read_3D(const ccl_gpu_tex_object texobj,
+ccl_device_forceinline T ccl_gpu_tex_object_read_3D(const ccl_gpu_tex_object_3D texobj,
                                                     const float x,
                                                     const float y,
                                                     const float z)



More information about the Bf-blender-cvs mailing list