How to manage .cl data?

I was looking for some code and I find myself using data such as kernelglobals *kg and shaderData *sd and similar: i don’t know what these are but I’d like to learn, can someone teach how?

In a specific case:
I wanted to variate the sample in cmj and a kind developer helped me there, but now, for the sake of knowledge and learning, I’d like to see if what i was thinking about was correct:
I want to pass to kernel_bake_evaluate the shaderData to which i might apply camera_distance(kg,sd->P).
I thought that something like ccl_device void kernel_bake_evaluate( KernelGlobals *kg, shaderData *sd, ccl_global float *buffer, int sample, int x, int y, int offset, int stride ) should have worked together with kernel_bake_evaluate(kg, sd, buffer, sample, x, y, offset, stride ); in but builder says nope.

thanks to those who will help

Please notice: I don’t want to face other ways, i want to do this to see how this work :wink:
In other words just an engineer engineering…


I wanto to pass in cmj_sample_2D the distance between sampling pixel and first object in scene.
In order to do so I searched for the first calling function that has the coordinate of sampling pixel, so i found kernel_bake.h to be the closest function callling it in kernel_bake_evaluate.
so i wrote:

ccl_device void kernel_bake_evaluate(
    KernelGlobals *kg, ccl_global float *buffer,const ShaderData *sd, int sample, int x, int y, int offset, int stride ) 
  /* Setup render buffers. */

    float distScene = camera_distance(kg,sd->P);

and in i wrote

	KernelGlobals kglobals, *kg = &kglobals;
	SharedData sdata, *sd= &sdata;


	if(x < sx + sw && y < sy + sh) {
#ifndef __NO_BAKING__
		kernel_bake_evaluate(kg,  buffer,sd, sample, x, y, offset, stride );

When i build i receive several of the following Error:

cycles_device.lib(device_cpu.obj) : error LNK2019: riferimento al simbolo esterno "void __cdecl ccl::kernel_cpu_path_tr
ace(struct ccl::KernelGlobals *,float *,int,int,int,int,int)" (?kernel_cpu_path_trace@ccl@@YAXPEAUKernelGlobals@1@PEAMH
HHHH@Z) non risolto nella funzione "public: __cdecl ccl::CPUDevice::CPUDevice(class ccl::DeviceInfo &,class ccl::Stats
&,class ccl::Profiler &,bool)" (??0CPUDevice@ccl@@QEAA@AEAVDeviceInfo@1@AEAVStats@1@AEAVProfiler@1@_N@Z) [C:\blender-gi

that should be translated as:

cycles_device.lib(device_cpu.obj) : error LNK2019: reference to external simbol "void __cdecl ccl::kernel_cpu_path_tr
ace(struct ccl::KernelGlobals *,float *,int,int,int,int,int)" (?kernel_cpu_path_trace@ccl@@YAXPEAUKernelGlobals@1@PEAMH
HHHH@Z) not resolved in function "public: __cdecl ccl::CPUDevice::CPUDevice(class ccl::DeviceInfo &,class ccl::Stats
&,class ccl::Profiler &,bool)" (??0CPUDevice@ccl@@QEAA@AEAVDeviceInfo@1@AEAVStats@1@AEAVProfiler@1@_N@Z) [C:\blender-gi

I’m all for helping someone out, but you’ll have to make a little bit of an effort to make a coherent question, try stating your goal, and laying out step by step what you did to reach it and what errors you encountered along the way or what is unclear at any point.

“I made some assumptions but the builder said nope!” is not something that can be given a satisfactory answer.

I edited the question, hope that’s enough to understand. Sorry for the inconvenience, i’m still new in this world.

You changed the function signature to pass an extra parameter, most of the cycles code is shared between CPU/Cuda/OpenCL so if you make changes like that you’ll also have to adjust for those same changes in all other codepaths.

I’d probably look in kernel_cpu_impl.h and see what adjustments are required there.