neuray API Programmer's Manual

target_code_types.h File Reference

Description

Types required for execution of generated native and CUDA code.

Code Example

target_code_types.h

‎/***************************************************************************************************
 * Copyright 2023 NVIDIA Corporation. All rights reserved.
 **************************************************************************************************/

#ifndef MI_NEURAYLIB_TARGET_CODE_TYPES_H
#define MI_NEURAYLIB_TARGET_CODE_TYPES_H

// Portable alignment macro supporting pre C++11.
#ifndef __align__
#ifdef _MSC_VER
#define __align__(n) __declspec(align(n))
#else
#define __align__(n) __attribute__((aligned(n)))
#endif
#endif


// If neither TARGET_CODE_USE_CUDA_TYPES nor TARGET_CODE_USE_NEURAY_TYPES is set,
// it will default to CUDA types when compiled by a CUDA compiler and use Neuray types otherwise.

#if defined(TARGET_CODE_USE_CUDA_TYPES) && defined(TARGET_CODE_USE_NEURAY_TYPES)
#error "Only one of TARGET_CODE_USE_CUDA_TYPES and TARGET_CODE_USE_NEURAY_TYPES may be defined."
#endif

#if !defined(TARGET_CODE_USE_NEURAY_TYPES) && \
    (defined(TARGET_CODE_USE_CUDA_TYPES) || defined(__CUDA_ARCH__))

#include <vector_types.h>

namespace mi {

namespace neuraylib {


typedef float      tct_float;

typedef float2     tct_float2;

typedef float3     tct_float3;

typedef float4     tct_float4;

typedef int        tct_int;

typedef unsigned   tct_uint;

#else

#include <mi/neuraylib/typedefs.h>

namespace mi {

namespace neuraylib {


typedef float                  tct_float;

typedef mi::Float32_2_struct   
               tct_float2;

typedef mi::Float32_3_struct   
               tct_float3;

typedef mi::Float32_4_struct   
               tct_float4;

typedef mi::Sint32             
               tct_int;

typedef mi::Uint32             
               tct_uint;

#endif

typedef bool  tct_bool;


template<typename T>
struct tct_deriv
{
    T val, dx, dy;
};

template<bool with_derivatives>
struct tct_traits;

template<>
struct tct_traits<false>
{
    typedef tct_float        tct_derivable_float;
    typedef tct_float2       tct_derivable_float2;
    typedef tct_float3       tct_derivable_float3;
    typedef tct_float4       tct_derivable_float4;
    typedef tct_float const  tct_coord2_type[2];
};

template<>
struct tct_traits<true>
{
    typedef tct_deriv<tct_float>          tct_derivable_float;
    typedef tct_deriv<tct_float2>         tct_derivable_float2;
    typedef tct_deriv<tct_float3>         tct_derivable_float3;
    typedef tct_deriv<tct_float4>         tct_derivable_float4;
    typedef tct_derivable_float2 const *  tct_coord2_type;
};

typedef tct_traits<true>::tct_derivable_float  tct_deriv_float;

typedef tct_traits<true>::tct_derivable_float2 tct_deriv_float2;

typedef tct_traits<true>::tct_derivable_float3 tct_deriv_float3;

typedef tct_traits<true>::tct_derivable_float4 tct_deriv_float4;

typedef tct_deriv< float[2]> 
               tct_deriv_arr_float_2;

typedef tct_deriv< float[3]> 
               tct_deriv_arr_float_3;

typedef tct_deriv< float[4]> 
               tct_deriv_arr_float_4;


struct Shading_state_environment {
    tct_float3            direction;

    char const           *ro_data_segment;
};


template<bool with_derivatives = false>
struct Shading_state_material_impl {
    typedef tct_traits<with_derivatives> traits;

    tct_float3            normal;

    tct_float3            geom_normal;

    typename traits::tct_derivable_float3 position;

    tct_float             animation_time;

    typename traits::tct_derivable_float3 const *text_coords;

    tct_float3 const     *tangent_u;

    tct_float3 const     *tangent_v;

    tct_float4           *text_results;

    char const           *ro_data_segment;

    tct_float4 const     *world_to_object;

    tct_float4 const     *object_to_world;

    tct_int               object_id;

    tct_float             meters_per_scene_unit;
};

typedef struct Shading_state_material_impl<false> Shading_state_material;

typedef struct Shading_state_material_impl<true> Shading_state_material_with_derivs;


enum Tex_wrap_mode {
    TEX_WRAP_CLAMP           = 0,

    TEX_WRAP_REPEAT          = 1,

    TEX_WRAP_MIRRORED_REPEAT = 2,

    TEX_WRAP_CLIP            = 3
};

enum Mbsdf_part
{
    MBSDF_DATA_REFLECTION = 0,

    MBSDF_DATA_TRANSMISSION = 1
};


// Forward declaration of texture handler structure.
struct Texture_handler_base;


template<bool with_derivatives = false>
struct Texture_handler_vtable_impl {
    typedef tct_traits<with_derivatives> traits;

    void (*m_tex_lookup_float4_2d)(
        tct_float                        result[4],
        Texture_handler_base const       *self,
        tct_uint                         texture_idx,
        typename traits::tct_coord2_type coord,
        Tex_wrap_mode                    wrap_u,
        Tex_wrap_mode                    wrap_v,
        tct_float const                  crop_u[2],
        tct_float const                  crop_v[2],
        tct_float                        frame);

    void (*m_tex_lookup_float3_2d)(
        tct_float                        result[3],
        Texture_handler_base const       *self,
        tct_uint                         texture_idx,
        typename traits::tct_coord2_type coord,
        Tex_wrap_mode                    wrap_u,
        Tex_wrap_mode                    wrap_v,
        tct_float const                  crop_u[2],
        tct_float const                  crop_v[2],
        tct_float                        frame);

    void (*m_tex_texel_float4_2d)(
        tct_float                  result[4],
        Texture_handler_base const *self,
        tct_uint                   texture_idx,
        tct_int const              coord[2],
        tct_int const              uv_tile[2],
        tct_float                  frame);

    void (*m_tex_lookup_float4_3d)(
        tct_float                  result[4],
        Texture_handler_base const *self,
        tct_uint                   texture_idx,
        tct_float const            coord[3],
        Tex_wrap_mode              wrap_u,
        Tex_wrap_mode              wrap_v,
        Tex_wrap_mode              wrap_w,
        tct_float const            crop_u[2],
        tct_float const            crop_v[2],
        tct_float const            crop_w[2],
        tct_float                  frame);

    void (*m_tex_lookup_float3_3d)(
        tct_float                  result[3],
        Texture_handler_base const *self,
        tct_uint                   texture_idx,
        tct_float const            coord[3],
        Tex_wrap_mode              wrap_u,
        Tex_wrap_mode              wrap_v,
        Tex_wrap_mode              wrap_w,
        tct_float const            crop_u[2],
        tct_float const            crop_v[2],
        tct_float const            crop_w[2],
        tct_float                  frame);

    void (*m_tex_texel_float4_3d)(
        tct_float                  result[4],
        Texture_handler_base const *self,
        tct_uint                   texture_idx,
        tct_int const              coord[3],
        tct_float                  frame);

    void (*m_tex_lookup_float4_cube)(
        tct_float                  result[4],
        Texture_handler_base const *self,
        tct_uint                   texture_idx,
        tct_float const            coord[3]);

    void (*m_tex_lookup_float3_cube)(
        tct_float                  result[3],
        Texture_handler_base const *self,
        tct_uint                   texture_idx,
        tct_float const            coord[3]);

    void (*m_tex_resolution_2d)(
        tct_int                    result[2],
        Texture_handler_base const *self,
        tct_uint                   texture_idx,
        tct_int const              uv_tile[2],
        tct_float                  frame);

    void (*m_tex_resolution_3d)(
        tct_int                    result[3],
        Texture_handler_base const *self,
        tct_uint                   texture_idx,
        tct_float                  frame);

    tct_bool (*m_tex_texture_isvalid)(
        Texture_handler_base const *self,
        tct_uint                   texture_idx);

    void (*m_tex_frame)(
        tct_int                    result[2],
        Texture_handler_base const *self,
        tct_uint                   texture_idx);

    tct_float (*m_df_light_profile_power)(
        Texture_handler_base const *self,
        tct_uint                   light_profile_index);

    tct_float (*m_df_light_profile_maximum)(
        Texture_handler_base const *self,
        tct_uint                   light_profile_index);

    tct_bool (*m_df_light_profile_isvalid)(
        Texture_handler_base const *self,
        tct_uint                   light_profile_index);

    tct_float (*m_df_light_profile_evaluate)(
        Texture_handler_base const *self,
        tct_uint                   light_profile_index,
        tct_float const            theta_phi[2]);       

    void (*m_df_light_profile_sample)(
        tct_float                  result[3],           
        Texture_handler_base const *self,
        tct_uint                   light_profile_index,
        tct_float const            xi[3]);

    tct_float (*m_df_light_profile_pdf)(
        Texture_handler_base const *self,
        tct_uint                   light_profile_index,
        tct_float const            theta_phi[2]);       

    tct_bool (*m_df_bsdf_measurement_isvalid)(
        Texture_handler_base const *self,
        tct_uint                   bsdf_measurement_index);

    void (*m_df_bsdf_measurement_resolution)(
        tct_uint                    result[3],
        Texture_handler_base const  *self,
        tct_uint                    bsdf_measurement_index,
        Mbsdf_part                  part);              

    void (*m_df_bsdf_measurement_evaluate)(
        tct_float                   result[3],
        Texture_handler_base const  *self,
        tct_uint                    bsdf_measurement_index,
        tct_float const             theta_phi_in[2],    
        tct_float const             theta_phi_out[2],   
        Mbsdf_part                  part);              

    void (*m_df_bsdf_measurement_sample)(
        tct_float                   result[3],          
        Texture_handler_base const  *self,
        tct_uint                    bsdf_measurement_index,
        tct_float const             theta_phi_out[2],   
        tct_float const             xi[3],              
        Mbsdf_part                  part);              

    tct_float (*m_df_bsdf_measurement_pdf)(
        Texture_handler_base const  *self,
        tct_uint                    bsdf_measurement_index,
        tct_float const             theta_phi_in[2],    
        tct_float const             theta_phi_out[2],   
        Mbsdf_part                  part);              

    void (*m_df_bsdf_measurement_albedos)(
        tct_float                   result[4],          
        Texture_handler_base const  *self,
        tct_uint                    bsdf_measurement_index,
        tct_float const             theta_phi[2]);      

    void (*m_adapt_normal)(
        tct_float                              result[3],
        Texture_handler_base const            *self_base,
        Shading_state_material                *state,
        tct_float const                        normal[3]);

    tct_bool (*m_scene_data_isvalid)(
        Texture_handler_base const            *self_base,
        Shading_state_material                *state,
        tct_uint                               scene_data_id);

    tct_float (*m_scene_data_lookup_float)(
        Texture_handler_base const            *self_base,
        Shading_state_material                *state,
        tct_uint                               scene_data_id,
        tct_float                              default_value,
        tct_bool                               uniform_lookup);

    void (*m_scene_data_lookup_float2)(
        tct_float                              result[2],
        Texture_handler_base const            *self_base,
        Shading_state_material                *state,
        tct_uint                               scene_data_id,
        tct_float const                        default_value[2],
        tct_bool                               uniform_lookup);

    void (*m_scene_data_lookup_float3)(
        tct_float                              result[3],
        Texture_handler_base const            *self_base,
        Shading_state_material                *state,
        tct_uint                               scene_data_id,
        tct_float const                        default_value[3],
        tct_bool                               uniform_lookup);

    void (*m_scene_data_lookup_float4)(
        tct_float                              result[4],
        Texture_handler_base const            *self_base,
        Shading_state_material                *state,
        tct_uint                               scene_data_id,
        tct_float const                        default_value[4],
        tct_bool                               uniform_lookup);

    tct_int (*m_scene_data_lookup_int)(
        Texture_handler_base const            *self_base,
        Shading_state_material                *state,
        tct_uint                               scene_data_id,
        tct_int                                default_value,
        tct_bool                               uniform_lookup);

    void (*m_scene_data_lookup_int2)(
        tct_int                                result[2],
        Texture_handler_base const            *self_base,
        Shading_state_material                *state,
        tct_uint                               scene_data_id,
        tct_int const                          default_value[2],
        tct_bool                               uniform_lookup);

    void (*m_scene_data_lookup_int3)(
        tct_int                                result[3],
        Texture_handler_base const            *self_base,
        Shading_state_material                *state,
        tct_uint                               scene_data_id,
        tct_int const                          default_value[3],
        tct_bool                               uniform_lookup);

    void (*m_scene_data_lookup_int4)(
        tct_int                                result[4],
        Texture_handler_base const            *self_base,
        Shading_state_material                *state,
        tct_uint                               scene_data_id,
        tct_int const                          default_value[4],
        tct_bool                               uniform_lookup);

    void (*m_scene_data_lookup_color)(
        tct_float                              result[3],
        Texture_handler_base const            *self_base,
        Shading_state_material                *state,
        tct_uint                               scene_data_id,
        tct_float const                        default_value[3],
        tct_bool                               uniform_lookup);

    void (*m_scene_data_lookup_float4x4)(
        tct_float                              result[16],
        Texture_handler_base const            *self_base,
        Shading_state_material                *state,
        tct_uint                               scene_data_id,
        tct_float const                        default_value[16],
        tct_bool                               uniform_lookup);
    //
    // The following functions are only used in the derivative variant,
    // and can be nullptr in the non-derivative variant
    //

    void (*m_scene_data_lookup_deriv_float)(
        tct_deriv_float                       *result,
        Texture_handler_base const            *self_base,
        Shading_state_material_with_derivs    *state,
        tct_uint                               scene_data_id,
        tct_deriv_float const                 *default_value,
        tct_bool                               uniform_lookup);

    void (*m_scene_data_lookup_deriv_float2)(
        tct_deriv_arr_float_2                 *result,
        Texture_handler_base const            *self_base,
        Shading_state_material_with_derivs    *state,
        tct_uint                               scene_data_id,
        tct_deriv_arr_float_2 const           *default_value,
        tct_bool                               uniform_lookup);

    void (*m_scene_data_lookup_deriv_float3)(
        tct_deriv_arr_float_3                 *result,
        Texture_handler_base const            *self_base,
        Shading_state_material_with_derivs    *state,
        tct_uint                               scene_data_id,
        tct_deriv_arr_float_3 const           *default_value,
        tct_bool                               uniform_lookup);

    void (*m_scene_data_lookup_deriv_float4)(
        tct_deriv_arr_float_4                 *result,
        Texture_handler_base const            *self_base,
        Shading_state_material_with_derivs    *state,
        tct_uint                               scene_data_id,
        tct_deriv_arr_float_4 const           *default_value,
        tct_bool                               uniform_lookup);

    void (*m_scene_data_lookup_deriv_color)(
        tct_deriv_arr_float_3                 *result,
        Texture_handler_base const            *self_base,
        Shading_state_material_with_derivs    *state,
        tct_uint                               scene_data_id,
        tct_deriv_arr_float_3 const           *default_value,
        tct_bool                               uniform_lookup);
};

typedef Texture_handler_vtable_impl< false> 
               Texture_handler_vtable;

typedef Texture_handler_vtable_impl< true> 
               Texture_handler_deriv_vtable;

struct Texture_handler_base {
    Texture_handler_vtable const  *vtable;
};

struct Texture_handler_deriv_base {
    Texture_handler_deriv_vtable const  *vtable;
};


struct Resource_data {
    void const                  *shared_data;      
    Texture_handler_base const  *texture_handler;  

};

enum Bsdf_event_type {
    BSDF_EVENT_ABSORB       = 0,

    BSDF_EVENT_DIFFUSE      = 1,
    BSDF_EVENT_GLOSSY       = 1 << 1,
    BSDF_EVENT_SPECULAR     = 1 << 2,
    BSDF_EVENT_REFLECTION   = 1 << 3,
    BSDF_EVENT_TRANSMISSION = 1 << 4,

    BSDF_EVENT_DIFFUSE_REFLECTION    = BSDF_EVENT_DIFFUSE  | BSDF_EVENT_REFLECTION,
    BSDF_EVENT_DIFFUSE_TRANSMISSION  = BSDF_EVENT_DIFFUSE  | BSDF_EVENT_TRANSMISSION,
    BSDF_EVENT_GLOSSY_REFLECTION     = BSDF_EVENT_GLOSSY   | BSDF_EVENT_REFLECTION,
    BSDF_EVENT_GLOSSY_TRANSMISSION   = BSDF_EVENT_GLOSSY   | BSDF_EVENT_TRANSMISSION,
    BSDF_EVENT_SPECULAR_REFLECTION   = BSDF_EVENT_SPECULAR | BSDF_EVENT_REFLECTION,
    BSDF_EVENT_SPECULAR_TRANSMISSION = BSDF_EVENT_SPECULAR | BSDF_EVENT_TRANSMISSION,

    BSDF_EVENT_FORCE_32_BIT = 0xffffffffU
};

#define MI_NEURAYLIB_BSDF_USE_MATERIAL_IOR (-1.0f)

struct __align__(16) Bsdf_sample_data {
    tct_float3       ior1;           
    tct_float3       ior2;           
    tct_float3       k1;             

    tct_float3       k2;             
    tct_float4       xi;             
    tct_float        pdf;            
    tct_float3       bsdf_over_pdf;  
    Bsdf_event_type  event_type;     
    tct_int          handle;         
};

enum Df_handle_slot_mode
{
    DF_HSM_POINTER = -2,    
    DF_HSM_NONE    = -1,    
    DF_HSM_FIXED_1 =  1,    
    DF_HSM_FIXED_2 =  2,    
    DF_HSM_FIXED_4 =  4,    
    DF_HSM_FIXED_8 =  8,    
};

struct __align__(16) Bsdf_evaluate_data_base {};

template<Df_handle_slot_mode N>
struct Bsdf_evaluate_data : public Bsdf_evaluate_data_base
{
    tct_float3       ior1;           
    tct_float3       ior2;           
    tct_float3       k1;             

    tct_float3       k2;             
    tct_int          handle_offset;  

    tct_float3       bsdf_diffuse[static_cast<size_t>(N)]; 

    tct_float3       bsdf_glossy[static_cast<size_t>(N)];  

    tct_float        pdf;            
};

template<>
struct Bsdf_evaluate_data<DF_HSM_POINTER> : public Bsdf_evaluate_data_base
{
    tct_float3       ior1;           
    tct_float3       ior2;           
    tct_float3       k1;             

    tct_float3       k2;             
    tct_int          handle_offset;  

    tct_int          handle_count;   
    tct_float3*      bsdf_diffuse;   
    tct_float3*      bsdf_glossy;    
    tct_float        pdf;            
};

template<>
struct Bsdf_evaluate_data<DF_HSM_NONE> : public Bsdf_evaluate_data_base
{
    tct_float3       ior1;           
    tct_float3       ior2;           
    tct_float3       k1;             

    tct_float3       k2;             
    tct_float3       bsdf_diffuse;   
    tct_float3       bsdf_glossy;    
    tct_float        pdf;            
};

struct __align__(16) Bsdf_pdf_data {
    tct_float3       ior1;           
    tct_float3       ior2;           
    tct_float3       k1;             

    tct_float3       k2;             
    tct_float        pdf;            
};

struct __align__(16) Bsdf_auxiliary_data_base {};

template<Df_handle_slot_mode N>
struct Bsdf_auxiliary_data : public Bsdf_auxiliary_data_base
{
    tct_float3       ior1;           
    tct_float3       ior2;           
    tct_float3       k1;             

    tct_int          handle_offset;  


    tct_float3       albedo[static_cast<size_t>(N)];    
    tct_float3       normal[static_cast<size_t>(N)];    
};

template<>
struct Bsdf_auxiliary_data<DF_HSM_POINTER> : public Bsdf_auxiliary_data_base
{
    tct_float3       ior1;           
    tct_float3       ior2;           
    tct_float3       k1;             

    tct_int          handle_offset;  


    tct_int          handle_count;   
    tct_float3*      albedo;         
    tct_float3*      normal;         
};

template<>
struct Bsdf_auxiliary_data<DF_HSM_NONE> : public Bsdf_auxiliary_data_base
{
    tct_float3       ior1;           
    tct_float3       ior2;           
    tct_float3       k1;             

    tct_float3       albedo;         
    tct_float3       normal;         
};

// Signatures for generated target code functions.

typedef void (Environment_function)(
    void                             *result,
    Shading_state_environment const  *state,
    Resource_data const              *res_data,
    void const                       *exception_state,
    char const                       *arg_block_data);


typedef void (Material_expr_function)(
    void                          *result,
    Shading_state_material const  *state,
    Resource_data const           *res_data,
    void const                    *exception_state,
    char const                    *arg_block_data);


typedef void (Material_expr_function_with_derivs)(
    void                                      *result,
    Shading_state_material_with_derivs const  *state,
    Resource_data const                       *res_data,
    void const                                *exception_state,
    char const                                *arg_block_data);


typedef void (Bsdf_init_function)(
    Shading_state_material  *state,
    Resource_data const     *res_data,
    void const              *exception_state,
    char const              *arg_block_data);


typedef void (Bsdf_init_function_with_derivs)(
    Shading_state_material_with_derivs  *state,
    Resource_data const                 *res_data,
    void const                          *exception_state,
    char const                          *arg_block_data);


typedef void (Bsdf_sample_function)(
    Bsdf_sample_data              *data,
    Shading_state_material const  *state,
    Resource_data const           *res_data,
    void const                    *exception_state,
    char const                    *arg_block_data);


typedef void (Bsdf_sample_function_with_derivs)(
    Bsdf_sample_data                          *data,
    Shading_state_material_with_derivs const  *state,
    Resource_data const                       *res_data,
    void const                                *exception_state,
    char const                                *arg_block_data);


typedef void (Bsdf_evaluate_function)(
    Bsdf_evaluate_data_base               *data,
    Shading_state_material const          *state,
    Resource_data const                   *res_data,
    void const                            *exception_state,
    char const                            *arg_block_data);


typedef void (Bsdf_evaluate_function_with_derivs)(
    Bsdf_evaluate_data_base                     *data,
    Shading_state_material_with_derivs const    *state,
    Resource_data const                         *res_data,
    void const                                  *exception_state,
    char const                                  *arg_block_data);


typedef void (Bsdf_pdf_function)(
    Bsdf_pdf_data                 *data,
    Shading_state_material const  *state,
    Resource_data const           *res_data,
    void const                    *exception_state,
    char const                    *arg_block_data);


typedef void (Bsdf_pdf_function_with_derivs)(
    Bsdf_pdf_data                             *data,
    Shading_state_material_with_derivs const  *state,
    Resource_data const                       *res_data,
    void const                                *exception_state,
    char const                                *arg_block_data);

typedef void (Bsdf_auxiliary_function)(
    Bsdf_auxiliary_data_base      *data,
    Shading_state_material const  *state,
    Resource_data const           *res_data,
    void const                    *exception_state,
    char const                    *arg_block_data);


typedef void (Bsdf_auxiliary_function_with_derivs)(
    Bsdf_auxiliary_data_base                  *data,
    Shading_state_material_with_derivs const  *state,
    Resource_data const                       *res_data,
    void const                                *exception_state,
    char const                                *arg_block_data);

enum Edf_event_type
{
    EDF_EVENT_NONE = 0,
    EDF_EVENT_EMISSION = 1,

    EDF_EVENT_FORCE_32_BIT = 0xffffffffU
};


struct __align__(16) Edf_sample_data
{
    tct_float4      xi;             
    tct_float3      k1;             
    tct_float       pdf;            
    tct_float3      edf_over_pdf;   
    Edf_event_type  event_type;     
    tct_int         handle;         
};

struct __align__(16) Edf_evaluate_data_base {};

template<Df_handle_slot_mode N>
struct Edf_evaluate_data : public Edf_evaluate_data_base
{
    tct_float3      k1;             
    tct_int         handle_offset;  

    tct_float       
               cos;                            
    tct_float3      edf[static_cast<size_t>(N)];    
    tct_float       pdf;                            
};

template<>
struct Edf_evaluate_data<DF_HSM_POINTER> : public Edf_evaluate_data_base
{
    tct_float3      k1;             
    tct_int         handle_offset;  

    tct_int         handle_count;   
    tct_float       
               cos;            
    tct_float3*     edf;            
    tct_float       pdf;            
};

template<>
struct Edf_evaluate_data<DF_HSM_NONE> : public Edf_evaluate_data_base
{
    tct_float3      k1;             
    tct_float       
               cos;            
    tct_float3      edf;            
    tct_float       pdf;            
};

struct __align__(16) Edf_pdf_data
{
    tct_float3      k1;             
    tct_float       pdf;            
};

struct __align__(16) Edf_auxiliary_data_base {};

template<Df_handle_slot_mode N>
struct Edf_auxiliary_data : public Edf_auxiliary_data_base
{
    tct_float3      k1;             
    tct_int         handle_offset;  

    // reserved for future use
};

template<>
struct Edf_auxiliary_data<DF_HSM_POINTER> : public Edf_auxiliary_data_base
{
    tct_float3      k1;             
    tct_int         handle_offset;  

    tct_int         handle_count;   

    // reserved for future use
};

template<>
struct Edf_auxiliary_data<DF_HSM_NONE> : public Edf_auxiliary_data_base
{
    tct_float3      k1;             

    // reserved for future use
};

typedef void (Edf_init_function)(
    Shading_state_material  *state,
    Resource_data const     *res_data,
    void const              *exception_state,
    char const              *arg_block_data);


typedef void (Edf_init_function_with_derivs)(
    Shading_state_material_with_derivs  *state,
    Resource_data const                 *res_data,
    void const                          *exception_state,
    char const                          *arg_block_data);


typedef void (Edf_sample_function)(
    Edf_sample_data               *data,
    Shading_state_material const  *state,
    Resource_data const           *res_data,
    void const                    *exception_state,
    char const                    *arg_block_data);


typedef void (Edf_sample_function_with_derivs)(
    Edf_sample_data                           *data,
    Shading_state_material_with_derivs const  *state,
    Resource_data const                       *res_data,
    void const                                *exception_state,
    char const                                *arg_block_data);


typedef void (Edf_evaluate_function)(
    Edf_evaluate_data_base       *data,
    Shading_state_material const  *state,
    Resource_data const           *res_data,
    void const                    *exception_state,
    char const                    *arg_block_data);


typedef void (Edf_evaluate_function_with_derivs)(
    Edf_evaluate_data_base                    *data,
    Shading_state_material_with_derivs const  *state,
    Resource_data const                       *res_data,
    void const                                *exception_state,
    char const                                *arg_block_data);


typedef void (Edf_pdf_function)(
    Edf_pdf_data                  *data,
    Shading_state_material const  *state,
    Resource_data const           *res_data,
    void const                    *exception_state,
    char const                    *arg_block_data);


typedef void (Edf_pdf_function_with_derivs)(
    Edf_pdf_data                              *data,
    Shading_state_material_with_derivs const  *state,
    Resource_data const                       *res_data,
    void const                                *exception_state,
    char const                                *arg_block_data);

typedef void (Edf_auxiliary_function)(
    Edf_auxiliary_data_base       *data,
    Shading_state_material const  *state,
    Resource_data const           *res_data,
    void const                    *exception_state,
    char const                    *arg_block_data);


typedef void (Edf_auxiliary_function_with_derivs)(
    Edf_auxiliary_data_base                   *data,
    Shading_state_material_with_derivs const  *state,
    Resource_data const                       *res_data,
    void const                                *exception_state,
    char const                                *arg_block_data);
 // end group mi_neuray_mdl_compiler

} // namespace neuraylib

} // namespace mi

#endif // MI_NEURAYLIB_TARGET_CODE_TYPES_H

Namespaces

namespace 
Common namespace for APIs of NVIDIA Advanced Rendering Center GmbH. More...
namespace 
Namespace for the neuray API. More...

Classes

struct 
More...
struct 
The MDL environment state structure inside the MDL SDK is a representation of the renderer state in the context of an environment lookup as defined in section 19 "Renderer state" in the MDL specification. More...
struct 
More...
struct 
More...
struct 
More...
struct 
More...
struct 
A template struct with derivatives. More...

Defines

#define  (-1.0f)
The calling code can mark the x component of an IOR field in *_data with MI_NEURAYLIB_BSDF_USE_MATERIAL_IOR, to make the BSDF functions use the MDL material's IOR for this IOR field. More...

Typedefs

typedef void(  
Signature of the auxiliary function for material distribution functions created via mi::neuraylib::IMdl_backend::translate_material_df() and mi::neuraylib::ILink_unit::add_material_df(). More...
typedef void(  
Signature of the auxiliary function for material distribution functions created via mi::neuraylib::IMdl_backend::translate_material_df() and mi::neuraylib::ILink_unit::add_material_df(). More...
typedef void(  
Signature of the evaluation function for material distribution functions created via mi::neuraylib::IMdl_backend::translate_material_df() and mi::neuraylib::ILink_unit::add_material_df(). More...
typedef void(  
Signature of the evaluation function for material distribution functions created via mi::neuraylib::IMdl_backend::translate_material_df() and mi::neuraylib::ILink_unit::add_material_df(). More...
typedef void(  
Signature of the initialization function for material distribution functions created via mi::neuraylib::IMdl_backend::translate_material_df() and mi::neuraylib::ILink_unit::add_material_df(). More...
typedef void(  
Signature of the initialization function for material distribution functions created via mi::neuraylib::IMdl_backend::translate_material_df() and mi::neuraylib::ILink_unit::add_material_df(). More...
typedef void(  
Signature of the probability density function for material distribution functions created via mi::neuraylib::IMdl_backend::translate_material_df() and mi::neuraylib::ILink_unit::add_material_df(). More...
typedef void(  
Signature of the probability density function for material distribution functions created via mi::neuraylib::IMdl_backend::translate_material_df() and mi::neuraylib::ILink_unit::add_material_df(). More...
typedef void(  
Signature of the importance sampling function for material distribution functions created via mi::neuraylib::IMdl_backend::translate_material_df() and mi::neuraylib::ILink_unit::add_material_df(). More...
typedef void(  
Signature of the importance sampling function for material distribution functions created via mi::neuraylib::IMdl_backend::translate_material_df() and mi::neuraylib::ILink_unit::add_material_df(). More...
typedef void(  
Signature of the auxiliary function for material distribution functions created via mi::neuraylib::IMdl_backend::translate_material_df() and mi::neuraylib::ILink_unit::add_material_df(). More...
typedef void(  
Signature of the auxiliary function for material distribution functions created via mi::neuraylib::IMdl_backend::translate_material_df() and mi::neuraylib::ILink_unit::add_material_df(). More...
typedef void(  
Signature of the evaluation function for material distribution functions created via mi::neuraylib::IMdl_backend::translate_material_df() and mi::neuraylib::ILink_unit::add_material_df(). More...
typedef void(  
Signature of the evaluation function for material distribution functions created via mi::neuraylib::IMdl_backend::translate_material_df() and mi::neuraylib::ILink_unit::add_material_df(). More...
typedef void(  
Signature of the initialization function for material distribution functions created via mi::neuraylib::IMdl_backend::translate_material_df() and mi::neuraylib::ILink_unit::add_material_df(). More...
typedef void(  
Signature of the initialization function for material distribution functions created via mi::neuraylib::IMdl_backend::translate_material_df() and mi::neuraylib::ILink_unit::add_material_df(). More...
typedef void(  
Signature of the probability density function for material distribution functions created via mi::neuraylib::IMdl_backend::translate_material_df() and mi::neuraylib::ILink_unit::add_material_df(). More...
typedef void(  
Signature of the probability density function for material distribution functions created via mi::neuraylib::IMdl_backend::translate_material_df() and mi::neuraylib::ILink_unit::add_material_df(). More...
typedef void(  
Signature of the importance sampling function for material distribution functions created via mi::neuraylib::IMdl_backend::translate_material_df() and mi::neuraylib::ILink_unit::add_material_df(). More...
typedef void(  
Signature of the importance sampling function for material distribution functions created via mi::neuraylib::IMdl_backend::translate_material_df() and mi::neuraylib::ILink_unit::add_material_df(). More...
typedef void(  
Signature of environment functions created via mi::neuraylib::IMdl_backend::translate_environment() and mi::neuraylib::ILink_unit::add_function(). More...
typedef void(  
Signature of material expression functions created via mi::neuraylib::IMdl_backend::translate_material_expression() and mi::neuraylib::ILink_unit::add_material_expression(). More...
typedef void(  
Signature of material expression functions created via mi::neuraylib::IMdl_backend::translate_material_expression() and mi::neuraylib::ILink_unit::add_material_expression(). More...
typedef struct Shading_state_material_impl< false>  
The MDL material state structure. More...
typedef struct Shading_state_material_impl< true>  
The MDL material state structure with derivatives for the texture coordinates. More...
typedef Texture_handler_vtable_impl< true>  
The texture handler vtable struct with derivatives for the texture coordinates. More...
typedef Texture_handler_vtable_impl< false>  
The texture handler vtable struct. More...
typedef bool  
A bool. More...
typedef tct_deriv< float[2]>  
A float[2] with derivatives (needed to avoid problems with wrong alignment). More...
typedef tct_deriv< float[3]>  
A float[3] with derivatives (needed to avoid problems with wrong alignment). More...
typedef tct_deriv< float[4]>  
A float[4] with derivatives (needed to avoid problems with wrong alignment). More...
typedef tct_traits< true>::tct_derivable_float  
A float with derivatives. More...
typedef tct_traits< true>::tct_derivable_float2  
A float2 with derivatives. More...
typedef tct_traits< true>::tct_derivable_float3  
A float3 with derivatives. More...
typedef tct_traits< true>::tct_derivable_float4  
A float4 with derivatives. More...
typedef float  
A float. More...
typedef mi::​Float32_2_struct 
A float2. More...
typedef mi::​Float32_3_struct 
A float3. More...
typedef mi::​Float32_4_struct 
A float4. More...
typedef mi::​Sint32 
An int. More...
typedef mi::​Uint32 
An unsigned int. More...

Enumerations

enum  {BSDF_EVENT_ABSORB = 0, BSDF_EVENT_DIFFUSE = 1, BSDF_EVENT_GLOSSY = 1<<1, BSDF_EVENT_SPECULAR = 1<<2, BSDF_EVENT_REFLECTION = 1<<3, BSDF_EVENT_TRANSMISSION = 1<<4, BSDF_EVENT_DIFFUSE_REFLECTION = BSDF_EVENT_DIFFUSE|BSDF_EVENT_REFLECTION, BSDF_EVENT_DIFFUSE_TRANSMISSION = BSDF_EVENT_DIFFUSE|BSDF_EVENT_TRANSMISSION, BSDF_EVENT_GLOSSY_REFLECTION = BSDF_EVENT_GLOSSY|BSDF_EVENT_REFLECTION, BSDF_EVENT_GLOSSY_TRANSMISSION = BSDF_EVENT_GLOSSY|BSDF_EVENT_TRANSMISSION, BSDF_EVENT_SPECULAR_REFLECTION = BSDF_EVENT_SPECULAR|BSDF_EVENT_REFLECTION, BSDF_EVENT_SPECULAR_TRANSMISSION = BSDF_EVENT_SPECULAR|BSDF_EVENT_TRANSMISSION, BSDF_EVENT_FORCE_32_BIT = 0xffffffffU }
The type of events created by BSDF importance sampling. More...
enum  {DF_HSM_POINTER = -2, DF_HSM_NONE = -1, DF_HSM_FIXED_1 = 1, DF_HSM_FIXED_2 = 2, DF_HSM_FIXED_4 = 4, DF_HSM_FIXED_8 = 8 }
Type of Bsdf_evaluate_data variants, depending on the backend and its configuration. More...
enum  {EDF_EVENT_NONE = 0, EDF_EVENT_EMISSION = 1, EDF_EVENT_FORCE_32_BIT = 0xffffffffU }
The type of events created by EDF importance sampling. More...
enum  {MBSDF_DATA_REFLECTION = 0, MBSDF_DATA_TRANSMISSION = 1 }
MBSDFs can consist of two parts, which can be selected using this enumeration. More...
enum  {TEX_WRAP_CLAMP = 0, TEX_WRAP_REPEAT = 1, TEX_WRAP_MIRRORED_REPEAT = 2, TEX_WRAP_CLIP = 3 }
The texture wrap modes as defined by tex::wrap_mode in the MDL specification. More...

Functions

struct  ( 16)
Input and output structure for BSDF sampling data. More...