Size of dynamic float4 OptiX 7 (x component count)

Using older versions of OptiX 5/6, I can pass an array/buffer of float4 and then get the number of x components inside of a RT_PROGRAM with the following:

rtBuffer<float4, 2> ray_buffer4;
RT_PROGRAM void orthographic()
{
// get number of x components
int w = ray_buffer4.size().x;
}

Converting this to OptiX 7.0 I create a separate file with this parameter called sys_param.h:

struct SysParam
{
float4 *ray_buffer4;
};

Then inside my shader file myShader.cu:

extern “C” constant SysParam spm;
extern “C” global void shader()
{
int w = spm.ray_buffer4.size().x; // DOES NOT EXIST in OptiX 7
}

The line int w = spm.ray_buffer4.size().x will obviously not work in OptiX 7 - is there a similar utility offered in OptiX 7.0 that I could employ to determine the number of x components from the float4 array ?

Thank you to anyone who has any idea/hint(s) regarding this question.

You could add a uint2 variable with the sizes in it inside your SysParam struct, would that suffice?


David.

There is no other method. You must track that yourself. As shown here for example:
https://github.com/NVIDIA/OptiX_Apps/blob/master/apps/rtigo3/shaders/system_data.h#L49

The CUdeviveptr outputBuffer 2D dimensions are tracked by the int2 resolution further down in the launch parameters.
In this case that is used to make the rendering resolution independent of the launch dimension, which is required in that example to distribute the workload to multiple GPUs.
The simpler intro_* examples in that repository have outputBuffer dimension == launch dimension and do not need to track the resolution separately.
Mind that this is tracking the dimension, not the element format. Using a CUdeviceptr here allows to interpret that data as needed later, e.g. when the renderer can handle float4, half4 or uchar4 buffers you wouldn’t need to change the launch parameter struct, only the code interpreting the data format.

Similar tracking of the number of elements of these 1D arrays:

CameraDefinition*   cameraDefinitions;
LightDefinition*    lightDefinitions;
MaterialDefinition* materialDefinitions;

and their respective 1D sizes

int numCameras;
int numLights;
int numMaterials;

(Note that the old API buffer.size() functions returns size_t types, not int.)

Thank you for the reply @dhart. I suppose I could define a uint2 variable with sizes.

Thank you @droettger - as usual good information in response. As I replied to @dhart, I think I will just embed a uint2 variable with x and y sizes in it.