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:
authorBrecht Van Lommel <brecht@blender.org>2022-06-17 18:16:37 +0300
committerBrecht Van Lommel <brecht@blender.org>2022-06-20 13:30:48 +0300
commitff1883307f12a8b734bfcf87b01743dc73afae75 (patch)
tree95fbecc1e681e89f6a5d030cb5f5f96879dc7fa7 /intern/cycles/kernel/device/cpu
parentb73a52302edcd99f086fc26fc62a8ed4db29d562 (diff)
Cleanup: renaming and consistency for kernel data
* Rename "texture" to "data array". This has not used textures for a long time, there are just global memory arrays now. (On old CUDA GPUs there was a cache for textures but not global memory, so we used to put all data in textures.) * For CUDA and HIP, put globals in KernelParams struct like other devices. * Drop __ prefix for data array names, no possibility for naming conflict now that these are in a struct.
Diffstat (limited to 'intern/cycles/kernel/device/cpu')
-rw-r--r--intern/cycles/kernel/device/cpu/compat.h14
-rw-r--r--intern/cycles/kernel/device/cpu/globals.h26
-rw-r--r--intern/cycles/kernel/device/cpu/image.h4
-rw-r--r--intern/cycles/kernel/device/cpu/kernel.cpp8
4 files changed, 25 insertions, 27 deletions
diff --git a/intern/cycles/kernel/device/cpu/compat.h b/intern/cycles/kernel/device/cpu/compat.h
index e1c20169582..3bfc37e98ee 100644
--- a/intern/cycles/kernel/device/cpu/compat.h
+++ b/intern/cycles/kernel/device/cpu/compat.h
@@ -35,20 +35,6 @@ CCL_NAMESPACE_BEGIN
#define kernel_assert(cond) assert(cond)
-/* Texture types to be compatible with CUDA textures. These are really just
- * simple arrays and after inlining fetch hopefully revert to being a simple
- * pointer lookup. */
-template<typename T> struct texture {
- ccl_always_inline const T &fetch(int index) const
- {
- kernel_assert(index >= 0 && index < width);
- return data[index];
- }
-
- T *data;
- int width;
-};
-
/* Macros to handle different memory storage on different devices */
#ifdef __KERNEL_SSE2__
diff --git a/intern/cycles/kernel/device/cpu/globals.h b/intern/cycles/kernel/device/cpu/globals.h
index 7e080d428ea..309afae412e 100644
--- a/intern/cycles/kernel/device/cpu/globals.h
+++ b/intern/cycles/kernel/device/cpu/globals.h
@@ -12,7 +12,7 @@
CCL_NAMESPACE_BEGIN
/* On the CPU, we pass along the struct KernelGlobals to nearly everywhere in
- * the kernel, to access constant data. These are all stored as "textures", but
+ * the kernel, to access constant data. These are all stored as flat arrays.
* these are really just standard arrays. We can't use actually globals because
* multiple renders may be running inside the same process. */
@@ -22,11 +22,23 @@ struct OSLThreadData;
struct OSLShadingSystem;
#endif
+/* Array for kernel data, with size to be able to assert on invalid data access. */
+template<typename T> struct kernel_array {
+ ccl_always_inline const T &fetch(int index) const
+ {
+ kernel_assert(index >= 0 && index < width);
+ return data[index];
+ }
+
+ T *data;
+ int width;
+};
+
typedef struct KernelGlobalsCPU {
-#define KERNEL_TEX(type, name) texture<type> name;
-#include "kernel/textures.h"
+#define KERNEL_DATA_ARRAY(type, name) kernel_array<type> name;
+#include "kernel/data_arrays.h"
- KernelData __data;
+ KernelData data;
#ifdef __OSL__
/* On the CPU, we also have the OSL globals here. Most data structures are shared
@@ -44,8 +56,8 @@ typedef struct KernelGlobalsCPU {
typedef const KernelGlobalsCPU *ccl_restrict KernelGlobals;
/* Abstraction macros */
-#define kernel_tex_fetch(tex, index) (kg->tex.fetch(index))
-#define kernel_tex_array(tex) (kg->tex.data)
-#define kernel_data (kg->__data)
+#define kernel_data_fetch(name, index) (kg->name.fetch(index))
+#define kernel_data_array(name) (kg->name.data)
+#define kernel_data (kg->data)
CCL_NAMESPACE_END
diff --git a/intern/cycles/kernel/device/cpu/image.h b/intern/cycles/kernel/device/cpu/image.h
index 7809ec5f4a7..320e6309128 100644
--- a/intern/cycles/kernel/device/cpu/image.h
+++ b/intern/cycles/kernel/device/cpu/image.h
@@ -733,7 +733,7 @@ template<typename TexT, typename OutT = float4> struct NanoVDBInterpolator {
ccl_device float4 kernel_tex_image_interp(KernelGlobals kg, int id, float x, float y)
{
- const TextureInfo &info = kernel_tex_fetch(__texture_info, id);
+ const TextureInfo &info = kernel_data_fetch(texture_info, id);
if (UNLIKELY(!info.data)) {
return zero_float4();
@@ -776,7 +776,7 @@ ccl_device float4 kernel_tex_image_interp_3d(KernelGlobals kg,
float3 P,
InterpolationType interp)
{
- const TextureInfo &info = kernel_tex_fetch(__texture_info, id);
+ const TextureInfo &info = kernel_data_fetch(texture_info, id);
if (UNLIKELY(!info.data)) {
return zero_float4();
diff --git a/intern/cycles/kernel/device/cpu/kernel.cpp b/intern/cycles/kernel/device/cpu/kernel.cpp
index b12e3089378..01087c96dd6 100644
--- a/intern/cycles/kernel/device/cpu/kernel.cpp
+++ b/intern/cycles/kernel/device/cpu/kernel.cpp
@@ -53,8 +53,8 @@ CCL_NAMESPACE_BEGIN
void kernel_const_copy(KernelGlobalsCPU *kg, const char *name, void *host, size_t)
{
- if (strcmp(name, "__data") == 0) {
- kg->__data = *(KernelData *)host;
+ if (strcmp(name, "data") == 0) {
+ kg->data = *(KernelData *)host;
}
else {
assert(0);
@@ -66,13 +66,13 @@ void kernel_global_memory_copy(KernelGlobalsCPU *kg, const char *name, void *mem
if (0) {
}
-#define KERNEL_TEX(type, tname) \
+#define KERNEL_DATA_ARRAY(type, tname) \
else if (strcmp(name, #tname) == 0) \
{ \
kg->tname.data = (type *)mem; \
kg->tname.width = size; \
}
-#include "kernel/textures.h"
+#include "kernel/data_arrays.h"
else {
assert(0);
}