The interface class representing user-defined parameter buffers for user-programmable rendering kernel components. More...
#include <irendering_kernel_programs.h>
Inherits mi::base::Interface_declare< 0x82ad1cdf, ... >.
Public Member Functions | |
virtual mi::Uint32 | get_nb_buffer_slots () const =0 |
Returns the number of valid buffer slots available to assign user-defined data to. More... | |
virtual mi::Size | get_max_buffer_size () const =0 |
Returns the maximum size of an individual buffer assignable to an individual buffer slot. More... | |
virtual mi::Size | get_array_offset_alignment () const =0 |
Returns the alignment in bytes of array components in a single buffer assigned to a buffer slot. More... | |
virtual bool | set_buffer_data (mi::Uint32 slot_idx, const void *data, mi::Size data_size)=0 |
Assigns the buffer contents to a particular buffer slot. More... | |
The interface class representing user-defined parameter buffers for user-programmable rendering kernel components.
User-defined parameter buffers allow the application to define custom input to IRendering_kernel_program
instances. Such input can be utilized to implement custom rendering kernel programs independent of the input made available through the NVIDIA IndeX rendering kernel interfaces. For instance, an application is enabled to implement a specialized material shading method that is not pre-defined by any existing NVIDIA IndeX rendering properties. The required material parameters, unknown to the actual rendering system, are passed through this interface class to NVIDIA IndeX, which handles the distribution of such data to each rendering node and rendering device. The interface class acts as a scene attribute to scene elements enabled to utilize rendering kernel components (IRendering_kernel_program
).
Each instance of this interface allows for a certain number of data buffers to be added. The buffer data is assigned to so called buffer slots. These buffer slots are a way to identify the actual buffers and access them in the rendering kernel programs, as shown in the following example code snippet of a volume sample program.
This example illustrates the input of clip-plane parameters on the application side:
This example illustrates how to access clip-plane information defined by the application in a rendering kernel program:
or to access the same data through the separate entries:
As shown in the above example the association of data input through this interface class and the actual data at runtime happens through the buffer slot identifiers. Further, the example illustrates that a buffer slot can actually hold an array of structures (in this example an array of Plane_data_buffer
instances). It is possible to access such arrays in a straightforward way through the array index operator or by binding the contents of the array to individual variables. The function to perform the binding (state.bind_parameter_buffer()
) allows both use cases:
The buffer_slot_offset
parameter allows to select a particular array element. The offset unit is the actual number of array elements to offset the binding.
It is important to note that the contents of the buffer data input through this interface must conform to certain rules to ensure data consistency between the host and device data. Especially, data alignment of buffer contents must be regarded. For example, certain vector data types require alignment to special boundaries inside structures: https://docs.nvidia.com/cuda/cuda-c-programming-guide/index.html#device-memory-accesses
Example for misaligned data between host and device:
In this example the 'color' entry of the structure is not correctly aligned to the struct. A float4
variable requires a 16 byte alignment. Such cases can be corrected by manually adding padding data:
Similarly, when storing multiple elements in an array of structures, the individual structures require alignment to a certain boundary. This required array offset alignment can be queried through this interface using the get_array_offset_alignment()
method. In order to achieve correct structure alignment, padding data can be used:
|
pure virtual |
Returns the alignment in bytes of array components in a single buffer assigned to a buffer slot.
|
pure virtual |
Returns the maximum size of an individual buffer assignable to an individual buffer slot.
|
pure virtual |
Returns the number of valid buffer slots available to assign user-defined data to.
|
pure virtual |
Assigns the buffer contents to a particular buffer slot.
IRendering_kernel_program_parameters
class does not take ownership of the user data passed through the set_buffer_data()
method. The buffer data is copied for internal use.[in] | slot_idx | The buffer slot index to assign the buffer data to. |
[in] | data | A raw pointer to the buffer data to assign to the buffer slot. |
[in] | data_size | The size in bytes of the buffer data to assign to the buffer slot. |