[Bf-blender-cvs] [216320127c4] cycles_oneapi: Fix oneAPI kernel compilation after recent refactor

Sergey Sharybin noreply at git.blender.org
Mon Jun 20 18:24:04 CEST 2022


Commit: 216320127c4617e707285ce4563093a9b397debc
Author: Sergey Sharybin
Date:   Mon Jun 20 18:21:13 2022 +0200
Branches: cycles_oneapi
https://developer.blender.org/rB216320127c4617e707285ce4563093a9b397debc

Fix oneAPI kernel compilation after recent refactor

Didn't notice such breaking changes while working on the build system.

This is a minimum possible change which seems to pass compilation of the
oneAPI kernel. Testing on the actual device would take a while.

More proper approach seems to wrap those fields into a structure within
the global data, so that no prefixing of the name is needed.

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

M	intern/cycles/kernel/device/oneapi/globals.h
M	intern/cycles/kernel/device/oneapi/image.h
M	intern/cycles/kernel/device/oneapi/kernel.cpp

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

diff --git a/intern/cycles/kernel/device/oneapi/globals.h b/intern/cycles/kernel/device/oneapi/globals.h
index 4b3186a309f..d60f4f135ba 100644
--- a/intern/cycles/kernel/device/oneapi/globals.h
+++ b/intern/cycles/kernel/device/oneapi/globals.h
@@ -18,9 +18,9 @@ struct IntegratorQueueCounter;
 
 typedef struct KernelGlobalsGPU {
 
-#define KERNEL_TEX(type, name) const type *name = nullptr;
-#include "kernel/textures.h"
-#undef KERNEL_TEX
+#define KERNEL_DATA_ARRAY(type, name) const type *__##name = nullptr;
+#include "kernel/data_arrays.h"
+#undef KERNEL_DATA_ARRAY
   IntegratorStateGPU *integrator_state;
   const KernelData *__data;
 #ifdef WITH_ONEAPI_SYCL_HOST_ENABLED
@@ -41,7 +41,7 @@ typedef ccl_global KernelGlobalsGPU *ccl_restrict KernelGlobals;
 
 /* data lookup defines */
 
-#define kernel_tex_fetch(tex, index) tex[index]
-#define kernel_tex_array(tex) tex
+#define kernel_data_fetch(name, index) __##name[index]
+#define kernel_data_array(name) __##name
 
 CCL_NAMESPACE_END
diff --git a/intern/cycles/kernel/device/oneapi/image.h b/intern/cycles/kernel/device/oneapi/image.h
index f4debcd806a..892558d40bf 100644
--- a/intern/cycles/kernel/device/oneapi/image.h
+++ b/intern/cycles/kernel/device/oneapi/image.h
@@ -74,7 +74,7 @@ ccl_device_inline float4 svm_image_texture_read(const TextureInfo &info, int x,
 
 ccl_device_inline float4 svm_image_texture_read_2d(int id, int x, int y)
 {
-  const TextureInfo &info = kernel_tex_fetch(__texture_info, id);
+  const TextureInfo &info = kernel_data_fetch(texture_info, id);
 
   /* Wrap */
   if (info.extension == EXTENSION_REPEAT) {
@@ -91,7 +91,7 @@ ccl_device_inline float4 svm_image_texture_read_2d(int id, int x, int y)
 
 ccl_device_inline float4 svm_image_texture_read_3d(int id, int x, int y, int z)
 {
-  const TextureInfo &info = kernel_tex_fetch(__texture_info, id);
+  const TextureInfo &info = kernel_data_fetch(texture_info, id);
 
   /* Wrap */
   if (info.extension == EXTENSION_REPEAT) {
@@ -126,7 +126,7 @@ static float svm_image_texture_frac(float x, int *ix)
 
 ccl_device float4 kernel_tex_image_interp(KernelGlobals, 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 (info.extension == EXTENSION_CLIP) {
     if (x < 0.0f || y < 0.0f || x > 1.0f || y > 1.0f) {
@@ -279,7 +279,7 @@ template<typename T> struct NanoVDBInterpolator {
 
 ccl_device float4 kernel_tex_image_interp_3d(KernelGlobals, int id, float3 P, int interp)
 {
-  const TextureInfo &info = kernel_tex_fetch(__texture_info, id);
+  const TextureInfo &info = kernel_data_fetch(texture_info, id);
 
   if (info.use_transform_3d) {
     Transform tfm = info.transform_3d;
diff --git a/intern/cycles/kernel/device/oneapi/kernel.cpp b/intern/cycles/kernel/device/oneapi/kernel.cpp
index 10579fa8873..6352fd9977f 100644
--- a/intern/cycles/kernel/device/oneapi/kernel.cpp
+++ b/intern/cycles/kernel/device/oneapi/kernel.cpp
@@ -215,27 +215,27 @@ void oneapi_set_global_memory(SyclQueue *queue_,
   std::string matched_name(memory_name);
 
 // This macros will change global ptr of KernelGlobals via name matching
-#  define KERNEL_TEX(type, name) \
+#  define KERNEL_DATA_ARRAY(type, name) \
     else if (#name == matched_name) \
     { \
-      globals->name = (type *)memory_device_pointer; \
+      globals->__##name = (type *)memory_device_pointer; \
       return; \
     }
   if (false) {
   }
-  else if ("__integrator_state" == matched_name) {
+  else if ("integrator_state" == matched_name) {
     globals->integrator_state = (IntegratorStateGPU *)memory_device_pointer;
     return;
   }
-  KERNEL_TEX(KernelData, __data)
-#  include "kernel/textures.h"
+  KERNEL_DATA_ARRAY(KernelData, data)
+#  include "kernel/data_arrays.h"
   else
   {
     std::cerr << "Can't found global/constant memory with name \"" << matched_name << "\"!"
               << std::endl;
     assert(false);
   }
-#  undef KERNEL_TEX
+#  undef KERNEL_DATA_ARRAY
 }
 
 // TODO: Move device information to OneapiDevice initialized on creation and use it.



More information about the Bf-blender-cvs mailing list