From 65dcb5ebd3440b096637c47807777fb07d430904 Mon Sep 17 00:00:00 2001 From: Stefan Werner Date: Fri, 1 Apr 2022 19:44:31 +0200 Subject: 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. --- intern/cycles/kernel/device/cuda/compat.h | 7 ++++--- intern/cycles/kernel/device/gpu/image.h | 12 ++++++------ intern/cycles/kernel/device/hip/compat.h | 7 ++++--- intern/cycles/kernel/device/metal/context_begin.h | 15 ++++++++------- intern/cycles/kernel/device/optix/compat.h | 7 ++++--- 5 files changed, 26 insertions(+), 22 deletions(-) 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 -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 -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 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(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(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(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(tex, x, y); } @@ -245,7 +245,7 @@ ccl_device float4 kernel_tex_image_interp_3d(KernelGlobals kg, return kernel_tex_image_interp_tricubic(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(tex, x, y, z); } } @@ -256,7 +256,7 @@ ccl_device float4 kernel_tex_image_interp_3d(KernelGlobals kg, f = kernel_tex_image_interp_tricubic(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(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 -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 -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 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 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 -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 -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) -- cgit v1.2.3