7#ifndef MI_NEURAYLIB_TARGET_CODE_TYPES_H
8#define MI_NEURAYLIB_TARGET_CODE_TYPES_H
13#define __align__(n) __declspec(align(n))
15#define __align__(n) __attribute__((aligned(n)))
23#if defined(TARGET_CODE_USE_CUDA_TYPES) && defined(TARGET_CODE_USE_NEURAY_TYPES)
24#error "Only one of TARGET_CODE_USE_CUDA_TYPES and TARGET_CODE_USE_NEURAY_TYPES may be defined."
27#if !defined(TARGET_CODE_USE_NEURAY_TYPES) && \
28 (defined(TARGET_CODE_USE_CUDA_TYPES) || defined(__CUDA_ARCH__))
30#include <vector_types.h>
102template<
bool with_derivatives>
112 typedef tct_float const tct_coord2_type[2];
122 typedef tct_derivable_float2
const * tct_coord2_type;
209template<
bool with_derivatives = false>
338struct Texture_handler_base;
343template<
bool with_derivatives = false>
348 void (*m_tex_lookup_float4_2d)(
352 typename traits::tct_coord2_type coord,
360 void (*m_tex_lookup_float3_2d)(
364 typename traits::tct_coord2_type coord,
372 void (*m_tex_texel_float4_2d)(
381 void (*m_tex_lookup_float4_3d)(
395 void (*m_tex_lookup_float3_3d)(
409 void (*m_tex_texel_float4_3d)(
417 void (*m_tex_lookup_float4_cube)(
424 void (*m_tex_lookup_float3_cube)(
433 void (*m_tex_resolution_2d)(
443 void (*m_tex_resolution_3d)(
483 void (*m_df_light_profile_sample)(
505 void (*m_df_bsdf_measurement_resolution)(
512 void (*m_df_bsdf_measurement_evaluate)(
521 void (*m_df_bsdf_measurement_sample)(
540 void (*m_df_bsdf_measurement_albedos)(
552 void (*m_adapt_normal)(
573 void (*m_scene_data_lookup_float2)(
582 void (*m_scene_data_lookup_float3)(
591 void (*m_scene_data_lookup_float4)(
608 void (*m_scene_data_lookup_int2)(
613 tct_int const default_value[2],
617 void (*m_scene_data_lookup_int3)(
622 tct_int const default_value[3],
626 void (*m_scene_data_lookup_int4)(
631 tct_int const default_value[4],
635 void (*m_scene_data_lookup_color)(
645 void (*m_scene_data_lookup_float4x4)(
658 void (*m_scene_data_lookup_deriv_float)(
667 void (*m_scene_data_lookup_deriv_float2)(
676 void (*m_scene_data_lookup_deriv_float3)(
685 void (*m_scene_data_lookup_deriv_float4)(
694 void (*m_scene_data_lookup_deriv_color)(
737 BSDF_EVENT_ABSORB = 0,
739 BSDF_EVENT_DIFFUSE = 1,
740 BSDF_EVENT_GLOSSY = 1 << 1,
741 BSDF_EVENT_SPECULAR = 1 << 2,
742 BSDF_EVENT_REFLECTION = 1 << 3,
743 BSDF_EVENT_TRANSMISSION = 1 << 4,
745 BSDF_EVENT_DIFFUSE_REFLECTION =
BSDF_EVENT_DIFFUSE |
BSDF_EVENT_REFLECTION,
746 BSDF_EVENT_DIFFUSE_TRANSMISSION =
BSDF_EVENT_DIFFUSE |
BSDF_EVENT_TRANSMISSION,
747 BSDF_EVENT_GLOSSY_REFLECTION =
BSDF_EVENT_GLOSSY |
BSDF_EVENT_REFLECTION,
748 BSDF_EVENT_GLOSSY_TRANSMISSION =
BSDF_EVENT_GLOSSY |
BSDF_EVENT_TRANSMISSION,
749 BSDF_EVENT_SPECULAR_REFLECTION =
BSDF_EVENT_SPECULAR |
BSDF_EVENT_REFLECTION,
750 BSDF_EVENT_SPECULAR_TRANSMISSION =
BSDF_EVENT_SPECULAR |
BSDF_EVENT_TRANSMISSION,
752 BSDF_EVENT_FORCE_32_BIT = 0xffffffffU
758#define MI_NEURAYLIB_BSDF_USE_MATERIAL_IOR (-1.0f)
788template<Df_handle_slot_mode N>
799 tct_float3 bsdf_diffuse[
static_cast<size_t>(N)];
801 tct_float3 bsdf_glossy[
static_cast<size_t>(N)];
807struct Bsdf_evaluate_data<
DF_HSM_POINTER> :
public Bsdf_evaluate_data_base
823struct Bsdf_evaluate_data<
DF_HSM_NONE> :
public Bsdf_evaluate_data_base
848template<Df_handle_slot_mode N>
858 tct_float3 albedo_diffuse[
static_cast<size_t>(N)];
860 tct_float3 albedo_glossy[
static_cast<size_t>(N)];
867struct Bsdf_auxiliary_data<
DF_HSM_POINTER> :
public Bsdf_auxiliary_data_base
885struct Bsdf_auxiliary_data<
DF_HSM_NONE> :
public Bsdf_auxiliary_data_base
912 char const *arg_block_data);
927 char const *arg_block_data);
942 char const *arg_block_data);
948struct Material_function
962 char const *arg_block_data);
973 typedef T (Type_with_derivs)(
976 char const *arg_block_data);
995 char const *arg_block_data);
1012 char const *arg_block_data);
1027 char const *arg_block_data);
1042 char const *arg_block_data);
1057 char const *arg_block_data);
1072 char const *arg_block_data);
1087 char const *arg_block_data);
1102 char const *arg_block_data);
1116 char const *arg_block_data);
1131 char const *arg_block_data);
1137 EDF_EVENT_EMISSION = 1,
1139 EDF_EVENT_FORCE_32_BIT = 0xffffffffU
1157template<Df_handle_slot_mode N>
1170struct Edf_evaluate_data<
DF_HSM_POINTER> :
public Edf_evaluate_data_base
1183struct Edf_evaluate_data<
DF_HSM_NONE> :
public Edf_evaluate_data_base
1201template<Df_handle_slot_mode N>
1213struct Edf_auxiliary_data<
DF_HSM_POINTER> :
public Edf_auxiliary_data_base
1225struct Edf_auxiliary_data<
DF_HSM_NONE> :
public Edf_auxiliary_data_base
1246 char const *arg_block_data);
1263 char const *arg_block_data);
1278 char const *arg_block_data);
1293 char const *arg_block_data);
1308 char const *arg_block_data);
1323 char const *arg_block_data);
1338 char const *arg_block_data);
1353 char const *arg_block_data);
1367 char const *arg_block_data);
1382 char const *arg_block_data);
unsigned int Uint32
32-bit unsigned integer.
Definition: types.h:49
signed int Sint32
32-bit signed integer.
Definition: types.h:46
Color cos(const Color &c)
Returns a color with the elementwise cosine of the color c.
Definition: color.h:558
tct_traits<true>::tct_derivable_float2 tct_deriv_float2
A float2 with derivatives.
Definition: target_code_types.h:129
void() Bsdf_pdf_function_with_derivs(Bsdf_pdf_data *data, Shading_state_material_with_derivs const *state, Resource_data const *res_data, char const *arg_block_data)
Signature of the probability density function for material distribution functions created via mi::neu...
Definition: target_code_types.h:1098
void() Bsdf_init_function_with_derivs(Shading_state_material_with_derivs *state, Resource_data const *res_data, char const *arg_block_data)
Signature of the initialization function for material distribution functions created via mi::neurayli...
Definition: target_code_types.h:1009
mi::Float32_2_struct tct_float2
A float2.
Definition: target_code_types.h:74
void() Bsdf_evaluate_function(Bsdf_evaluate_data_base *data, Shading_state_material const *state, Resource_data const *res_data, char const *arg_block_data)
Signature of the evaluation function for material distribution functions created via mi::neuraylib::I...
Definition: target_code_types.h:1053
void() Material_expr_function_with_derivs(void *result, Shading_state_material_with_derivs const *state, Resource_data const *res_data, char const *arg_block_data)
Signature of material expression functions created via mi::neuraylib::IMdl_backend::translate_materia...
Definition: target_code_types.h:938
bool tct_bool
A bool.
Definition: target_code_types.h:91
void() Bsdf_sample_function_with_derivs(Bsdf_sample_data *data, Shading_state_material_with_derivs const *state, Resource_data const *res_data, char const *arg_block_data)
Signature of the importance sampling function for material distribution functions created via mi::neu...
Definition: target_code_types.h:1038
void() Bsdf_init_function(Shading_state_material *state, Resource_data const *res_data, char const *arg_block_data)
Signature of the initialization function for material distribution functions created via mi::neurayli...
Definition: target_code_types.h:992
mi::Uint32 tct_uint
An unsigned int.
Definition: target_code_types.h:86
void() Edf_pdf_function_with_derivs(Edf_pdf_data *data, Shading_state_material_with_derivs const *state, Resource_data const *res_data, char const *arg_block_data)
Signature of the probability density function for material distribution functions created via mi::neu...
Definition: target_code_types.h:1349
void() Bsdf_evaluate_function_with_derivs(Bsdf_evaluate_data_base *data, Shading_state_material_with_derivs const *state, Resource_data const *res_data, char const *arg_block_data)
Signature of the evaluation function for material distribution functions created via mi::neuraylib::I...
Definition: target_code_types.h:1068
void() Bsdf_auxiliary_function(Bsdf_auxiliary_data_base *data, Shading_state_material const *state, Resource_data const *res_data, char const *arg_block_data)
Signature of the auxiliary function for material distribution functions created via mi::neuraylib::IM...
Definition: target_code_types.h:1112
Mbsdf_part
MBSDFs can consist of two parts, which can be selected using this enumeration.
Definition: target_code_types.h:328
tct_deriv< float[4]> tct_deriv_arr_float_4
A float[4] with derivatives (needed to avoid problems with wrong alignment).
Definition: target_code_types.h:144
tct_traits<true>::tct_derivable_float3 tct_deriv_float3
A float3 with derivatives.
Definition: target_code_types.h:132
void() Edf_evaluate_function_with_derivs(Edf_evaluate_data_base *data, Shading_state_material_with_derivs const *state, Resource_data const *res_data, char const *arg_block_data)
Signature of the evaluation function for material distribution functions created via mi::neuraylib::I...
Definition: target_code_types.h:1319
void() Edf_sample_function(Edf_sample_data *data, Shading_state_material const *state, Resource_data const *res_data, char const *arg_block_data)
Signature of the importance sampling function for material distribution functions created via mi::neu...
Definition: target_code_types.h:1274
Edf_event_type
The type of events created by EDF importance sampling.
Definition: target_code_types.h:1135
void() Material_expr_function(void *result, Shading_state_material const *state, Resource_data const *res_data, char const *arg_block_data)
Signature of material expression functions created via mi::neuraylib::IMdl_backend::translate_materia...
Definition: target_code_types.h:923
tct_traits<true>::tct_derivable_float tct_deriv_float
A float with derivatives.
Definition: target_code_types.h:126
mi::Float32_3_struct tct_float3
A float3.
Definition: target_code_types.h:77
Tex_wrap_mode
The texture wrap modes as defined by tex::wrap_mode in the MDL specification.
Definition: target_code_types.h:309
void() Edf_pdf_function(Edf_pdf_data *data, Shading_state_material const *state, Resource_data const *res_data, char const *arg_block_data)
Signature of the probability density function for material distribution functions created via mi::neu...
Definition: target_code_types.h:1334
void() Edf_sample_function_with_derivs(Edf_sample_data *data, Shading_state_material_with_derivs const *state, Resource_data const *res_data, char const *arg_block_data)
Signature of the importance sampling function for material distribution functions created via mi::neu...
Definition: target_code_types.h:1289
mi::Float32_4_struct tct_float4
A float4.
Definition: target_code_types.h:80
tct_deriv< float[2]> tct_deriv_arr_float_2
A float[2] with derivatives (needed to avoid problems with wrong alignment).
Definition: target_code_types.h:138
tct_traits<true>::tct_derivable_float4 tct_deriv_float4
A float4 with derivatives.
Definition: target_code_types.h:135
void() Bsdf_auxiliary_function_with_derivs(Bsdf_auxiliary_data_base *data, Shading_state_material_with_derivs const *state, Resource_data const *res_data, char const *arg_block_data)
Signature of the auxiliary function for material distribution functions created via mi::neuraylib::IM...
Definition: target_code_types.h:1127
tct_deriv< float[3]> tct_deriv_arr_float_3
A float[3] with derivatives (needed to avoid problems with wrong alignment).
Definition: target_code_types.h:141
void() Edf_init_function_with_derivs(Shading_state_material_with_derivs *state, Resource_data const *res_data, char const *arg_block_data)
Signature of the initialization function for material distribution functions created via mi::neurayli...
Definition: target_code_types.h:1260
Bsdf_event_type
The type of events created by BSDF importance sampling.
Definition: target_code_types.h:736
mi::Sint32 tct_int
An int.
Definition: target_code_types.h:83
void() Bsdf_sample_function(Bsdf_sample_data *data, Shading_state_material const *state, Resource_data const *res_data, char const *arg_block_data)
Signature of the importance sampling function for material distribution functions created via mi::neu...
Definition: target_code_types.h:1023
Texture_handler_vtable_impl<false> Texture_handler_vtable
The texture handler vtable struct.
Definition: target_code_types.h:704
float tct_float
A float.
Definition: target_code_types.h:71
Df_handle_slot_mode
Type of Bsdf_evaluate_data variants, depending on the backend and its configuration.
Definition: target_code_types.h:776
void() Bsdf_pdf_function(Bsdf_pdf_data *data, Shading_state_material const *state, Resource_data const *res_data, char const *arg_block_data)
Signature of the probability density function for material distribution functions created via mi::neu...
Definition: target_code_types.h:1083
void() Edf_auxiliary_function_with_derivs(Edf_auxiliary_data_base *data, Shading_state_material_with_derivs const *state, Resource_data const *res_data, char const *arg_block_data)
Signature of the auxiliary function for material distribution functions created via mi::neuraylib::IM...
Definition: target_code_types.h:1378
void() Edf_auxiliary_function(Edf_auxiliary_data_base *data, Shading_state_material const *state, Resource_data const *res_data, char const *arg_block_data)
Signature of the auxiliary function for material distribution functions created via mi::neuraylib::IM...
Definition: target_code_types.h:1363
void() Environment_function(void *result, Shading_state_environment const *state, Resource_data const *res_data, char const *arg_block_data)
Signature of environment functions created via mi::neuraylib::IMdl_backend::translate_environment() a...
Definition: target_code_types.h:908
void() Edf_init_function(Shading_state_material *state, Resource_data const *res_data, char const *arg_block_data)
Signature of the initialization function for material distribution functions created via mi::neurayli...
Definition: target_code_types.h:1243
void() Edf_evaluate_function(Edf_evaluate_data_base *data, Shading_state_material const *state, Resource_data const *res_data, char const *arg_block_data)
Signature of the evaluation function for material distribution functions created via mi::neuraylib::I...
Definition: target_code_types.h:1304
Texture_handler_vtable_impl<true> Texture_handler_deriv_vtable
The texture handler vtable struct with derivatives for the texture coordinates.
Definition: target_code_types.h:707
@ MBSDF_DATA_TRANSMISSION
the bidirectional transmission distribution function (BTDF)
Definition: target_code_types.h:333
@ MBSDF_DATA_REFLECTION
the bidirectional reflection distribution function (BRDF)
Definition: target_code_types.h:330
@ TEX_WRAP_CLIP
tex::wrap_clip: makes the texture lookup return zero for texture coordinates outside of the range
Definition: target_code_types.h:323
@ TEX_WRAP_MIRRORED_REPEAT
tex::wrap_mirrored_repeat: like wrap_repeat but takes one minus the fractional part every other inter...
Definition: target_code_types.h:319
@ TEX_WRAP_REPEAT
tex::wrap_repeat: takes the fractional part of the lookup coordinate effectively repeating the textur...
Definition: target_code_types.h:315
@ TEX_WRAP_CLAMP
tex::wrap_clamp: clamps the lookup coordinate to the range
Definition: target_code_types.h:311
@ DF_HSM_POINTER
Uses renderer defined buffers; not supported by all backends.
Definition: target_code_types.h:777
@ DF_HSM_FIXED_2
fixed size array for processing 2 handle at a time
Definition: target_code_types.h:780
@ DF_HSM_NONE
No slots, handles are ignored completely.
Definition: target_code_types.h:778
@ DF_HSM_FIXED_8
fixed size array for processing 8 handle at a time
Definition: target_code_types.h:782
@ DF_HSM_FIXED_1
fixed size array for processing 1 handle at a time
Definition: target_code_types.h:779
@ DF_HSM_FIXED_4
fixed size array for processing 4 handle at a time
Definition: target_code_types.h:781
Common namespace for APIs of NVIDIA Advanced Rendering Center GmbH.
Definition: example_derivatives.dox:5
Generic storage class template for math vector representations storing DIM elements of type T.
Definition: vector.h:135
Input and output structure for BSDF auxiliary calculation data.
Definition: target_code_types.h:846
Input and output structure for BSDF evaluation data.
Definition: target_code_types.h:786
Input and output structure for BSDF PDF calculation data.
Definition: target_code_types.h:836
tct_float3 ior2
mutual input: IOR other side
Definition: target_code_types.h:838
tct_float3 k2
input: incoming direction
Definition: target_code_types.h:841
tct_float3 ior1
mutual input: IOR current medium
Definition: target_code_types.h:837
tct_float pdf
output: pdf (non-projected hemisphere)
Definition: target_code_types.h:842
tct_float3 k1
mutual input: outgoing direction
Definition: target_code_types.h:839
Input and output structure for BSDF sampling data.
Definition: target_code_types.h:761
tct_float4 xi
input: pseudo-random sample numbers in range [0, 1)
Definition: target_code_types.h:767
tct_float pdf
output: pdf (non-projected hemisphere)
Definition: target_code_types.h:768
tct_int handle
output: handle of the sampled elemental BSDF (lobe)
Definition: target_code_types.h:771
tct_float3 ior2
mutual input: IOR other side
Definition: target_code_types.h:763
tct_float3 k1
mutual input: outgoing direction
Definition: target_code_types.h:764
tct_float3 k2
output: incoming direction
Definition: target_code_types.h:766
Bsdf_event_type event_type
output: the type of event for the generated sample
Definition: target_code_types.h:770
tct_float3 ior1
mutual input: IOR current medium
Definition: target_code_types.h:762
tct_float3 bsdf_over_pdf
output: bsdf * dot(normal, k2) / pdf
Definition: target_code_types.h:769
Input and output structure for EDF auxiliary calculation data.
Definition: target_code_types.h:1199
Input and output structure for EDF evaluation data.
Definition: target_code_types.h:1155
Input and output structure for EDF PDF calculation data.
Definition: target_code_types.h:1193
tct_float pdf
output: pdf (non-projected hemisphere)
Definition: target_code_types.h:1195
tct_float3 k1
input: outgoing direction
Definition: target_code_types.h:1194
Input and output structure for EDF sampling data.
Definition: target_code_types.h:1145
tct_int handle
output: handle of the sampled elemental EDF (lobe)
Definition: target_code_types.h:1151
tct_float3 k1
output: outgoing direction
Definition: target_code_types.h:1147
tct_float3 edf_over_pdf
output: edf * dot(normal,k1) / pdf
Definition: target_code_types.h:1149
tct_float pdf
output: pdf (non-projected hemisphere)
Definition: target_code_types.h:1148
tct_float4 xi
input: pseudo-random sample numbers in range [0, 1)
Definition: target_code_types.h:1146
Edf_event_type event_type
output: the type of event for the generated sample
Definition: target_code_types.h:1150
The data structure providing access to resources for generated code.
Definition: target_code_types.h:729
void const * shared_data
currently unused, should be NULL
Definition: target_code_types.h:730
Texture_handler_base const * texture_handler
will be provided as "self" parameter to texture functions
Definition: target_code_types.h:731
The MDL environment state structure inside the MDL SDK is a representation of the renderer state in t...
Definition: target_code_types.h:160
tct_float3 direction
The result of state::direction().
Definition: target_code_types.h:163
char const * ro_data_segment
A pointer to a read-only data segment.
Definition: target_code_types.h:178
The MDL material state structure inside the MDL SDK is a representation of the renderer state as defi...
Definition: target_code_types.h:210
tct_float3 normal
The result of state::normal().
Definition: target_code_types.h:217
char const * ro_data_segment
A pointer to a read-only data segment.
Definition: target_code_types.h:271
tct_int object_id
The result of state::object_id().
Definition: target_code_types.h:291
traits::tct_derivable_float3 position
The result of state::position().
Definition: target_code_types.h:225
tct_float4 const * world_to_object
A 4x4 transformation matrix in row-major order transforming from world to object coordinates.
Definition: target_code_types.h:278
tct_float3 const * tangent_v
An array containing the results of state::texture_tangent_v(i).
Definition: target_code_types.h:248
tct_float4 const * object_to_world
A 4x4 transformation matrix in row-major order transforming from object to world coordinates.
Definition: target_code_types.h:285
traits::tct_derivable_float3 const * text_coords
An array containing the results of state::texture_coordinate(i).
Definition: target_code_types.h:234
tct_float animation_time
The result of state::animation_time().
Definition: target_code_types.h:229
tct_float3 geom_normal
The result of state::geometry_normal().
Definition: target_code_types.h:221
tct_float3 const * tangent_u
An array containing the results of state::texture_tangent_u(i).
Definition: target_code_types.h:241
tct_float meters_per_scene_unit
The result of state::meters_per_scene_unit().
Definition: target_code_types.h:296
tct_float4 * text_results
The texture results lookup table.
Definition: target_code_types.h:256
The texture handler structure that is passed to the texturing functions.
Definition: target_code_types.h:712
Texture_handler_vtable const * vtable
In vtable-mode, the vtable field is used to call the texturing functions.
Definition: target_code_types.h:715
The texture handler structure that is passed to the texturing functions with derivative support.
Definition: target_code_types.h:721
Texture_handler_deriv_vtable const * vtable
In vtable-mode, the vtable field is used to call the texturing functions.
Definition: target_code_types.h:724
The runtime for bitmap texture access for the generated target code can optionally be implemented in ...
Definition: target_code_types.h:344
A template struct with derivatives.
Definition: target_code_types.h:97
Helper traits struct to switch between derivative and non-derivative types.
Definition: target_code_types.h:103
Typedefs for types from the math API.