MDL SDK API nvidia_logo_transpbg.gif Up
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
imdl_backend.h
Go to the documentation of this file.
1 /***************************************************************************************************
2  * Copyright 2022 NVIDIA Corporation. All rights reserved.
3  **************************************************************************************************/
6 
7 #ifndef MI_NEURAYLIB_IMDL_BACKEND_H
8 #define MI_NEURAYLIB_IMDL_BACKEND_H
9 
12 #include <mi/neuraylib/ivalue.h>
14 
15 namespace mi {
16 
17 namespace neuraylib {
18 
19 class IBuffer;
20 class ICompiled_material;
21 class IFunction_call;
22 class ILink_unit;
23 class IMdl_execution_context;
24 class ITarget_code;
25 class ITarget_argument_block;
26 class ITransaction;
27 
28 struct Target_function_description;
29 
34 class IMdl_backend : public
36  mi::base::Interface_declare<0x9ecdd747,0x20b8,0x4a8a,0xb1,0xe2,0x62,0xb2,0x62,0x30,0xd3,0x67>
37 {
38 public:
72 #if !defined(MDL_SOURCE_RELEASE) && defined(MDL_ENABLE_INTERPRETER)
73 #endif
79 #ifndef MDL_SOURCE_RELEASE
166 #endif // MDL_SOURCE_RELEASE
308  virtual Sint32 set_option( const char* name, const char* value) = 0;
316 
331  virtual Sint32 set_option_binary(
332  const char* name,
333  const char* data,
334  Size size) = 0;
335 
340  virtual const Uint8* get_device_library( Size &size) const = 0;
341 
380  virtual const ITarget_code* translate_environment(
381  ITransaction* transaction,
382  const IFunction_call* call,
383  const char* fname,
384  IMdl_execution_context* context) = 0;
385 
423  virtual const ITarget_code* translate_material_expression(
424  ITransaction* transaction,
425  const ICompiled_material* material,
426  const char* path,
427  const char* fname,
428  IMdl_execution_context* context) = 0;
429 
462  virtual const ITarget_code* translate_material_df(
463  ITransaction* transaction,
464  const ICompiled_material* material,
465  const char* path,
466  const char* base_fname,
467  IMdl_execution_context* context) = 0;
468 
495  virtual const ITarget_code* translate_material(
496  ITransaction* transaction,
497  const ICompiled_material* material,
498  Target_function_description* function_descriptions,
499  Size description_count,
500  IMdl_execution_context* context) = 0;
501 
520  virtual ILink_unit* create_link_unit(
521  ITransaction* transaction,
522  IMdl_execution_context* context) = 0;
523 
538  virtual const ITarget_code* translate_link_unit(
539  const ILink_unit* lu, IMdl_execution_context* context) = 0;
540 
560  virtual const ITarget_code* deserialize_target_code(
561  ITransaction* transaction,
562  const IBuffer* buffer,
563  IMdl_execution_context* context) const = 0;
564 
585  virtual const ITarget_code* deserialize_target_code(
586  ITransaction* transaction,
587  const Uint8* buffer_data,
588  Size buffer_size,
589  IMdl_execution_context* context) const = 0;
590 };
591 
596  mi::base::Interface_declare<0xe7559a88,0x9a9a,0x41d8,0xa1,0x9c,0x4a,0x52,0x4e,0x4b,0x7b,0x66>
597 {
598 public:
615 #ifndef MDL_SOURCE_RELEASE
616 #endif // MDL_SOURCE_RELEASE
619  virtual Uint32 get_resource_index(IValue_resource const *resource) = 0;
624 
630  virtual Uint32 get_string_index(IValue_string const *s) = 0;
631 };
632 
640  mi::base::Interface_declare<0xf2a5db20,0x85ab,0x4c41,0x8c,0x5f,0x49,0xc8,0x29,0x4a,0x73,0x65>
641 {
642 public:
644  virtual const char* get_data() const = 0;
645 
647  virtual char* get_data() = 0;
648 
650  virtual Size get_size() const = 0;
651 
653  virtual ITarget_argument_block *clone() const = 0;
654 };
655 
658  Target_value_layout_state(mi::Uint32 state_offs = 0, mi::Uint32 data_offs = 0)
659  : m_state_offs(state_offs)
660  , m_data_offs(data_offs)
661  {}
662 
665 
668 };
669 
679 class ITarget_value_layout : public
680  mi::base::Interface_declare<0x1003351f,0x0c31,0x4a9d,0xb9,0x99,0x90,0xb5,0xe4,0xb4,0x71,0xe3>
681 {
682 public:
684  virtual Size get_size() const = 0;
685 
690  virtual Size get_num_elements(
692 
703  virtual Size get_layout(
704  IValue::Kind &kind,
705  Size &arg_size,
707 
718  Size i,
720 
737  virtual Sint32 set_value(
738  char *block,
739  IValue const *value,
740  ITarget_resource_callback *resource_callback,
742 };
743 
745 class ITarget_code : public
746  mi::base::Interface_declare<0xefca46ae,0xd530,0x4b97,0x9d,0xab,0x3a,0xdb,0x0c,0x58,0xc3,0xac>
747 {
748 public:
751  SU_POSITION = 0x0001u,
752  SU_NORMAL = 0x0002u,
753  SU_GEOMETRY_NORMAL = 0x0004u,
754  SU_MOTION = 0x0008u,
757  SU_TANGENT_SPACE = 0x0040u,
759  SU_DIRECTION = 0x0100u,
760  SU_ANIMATION_TIME = 0x0200u,
762 
764 
765  SU_TRANSFORMS = 0x0800u,
766  SU_OBJECT_ID = 0x1000u,
767 
769 
770  SU_FORCE_32_BIT = 0xFFFFFFFFu // Undocumented, for alignment only
771  }; // can be or'ed
772 
773  typedef Uint32 State_usage;
774 
782  Texture_shape_FORCE_32_BIT = 0xFFFFFFFFu // Undocumented, for alignment only
784  };
785 
788  SL_CUDA,
789  SL_PTX,
790  SL_HLSL,
791  SL_GLSL, // \if MDL_SOURCE_RELEASE Reserved\else GLSL\endif.
792  SL_NUM_LANGUAGES
793  };
794 
797  {
798  DK_NONE,
799  DK_BSDF,
800  DK_HAIR_BSDF,
801  DK_EDF,
802  DK_INVALID
803  };
804 
807  FK_INVALID,
808  FK_LAMBDA,
809  FK_SWITCH_LAMBDA,
810  FK_ENVIRONMENT,
811  FK_CONST,
812  FK_DF_INIT,
813  FK_DF_SAMPLE,
814  FK_DF_EVALUATE,
815  FK_DF_PDF,
816  FK_DF_AUXILIARY
817  };
818 
820  enum Gamma_mode {
821  GM_GAMMA_DEFAULT,
822  GM_GAMMA_LINEAR,
823  GM_GAMMA_SRGB,
824  GM_GAMMA_UNKNOWN
825  };
826 
829 
831  virtual const char* get_code() const = 0;
832 
834  virtual Size get_code_size() const = 0;
835 
837  virtual Size get_callable_function_count() const = 0;
838 
848  virtual const char* get_callable_function( Size index) const = 0;
849 
851 
852 
854  virtual Size get_texture_count() const = 0;
855 
862  virtual Size get_body_texture_count() const = 0;
863 
870  virtual const char* get_texture( Size index) const = 0;
871 
879  virtual const char* get_texture_url( Size index) const = 0;
880 
887  virtual const char* get_texture_owner_module( Size index) const = 0;
888 
894  virtual Gamma_mode get_texture_gamma( Size index) const = 0;
895 
902  virtual const char* get_texture_selector( Size index) const = 0;
903 
909  virtual Texture_shape get_texture_shape( Size index) const = 0;
910 
917  virtual Df_data_kind get_texture_df_data_kind( Size index) const = 0;
918 
930  virtual const Float32* get_texture_df_data(
931  Size index,
932  Size &rx,
933  Size &ry,
934  Size &rz) const = 0;
935 
937 
939 
941  virtual Size get_light_profile_count() const = 0;
942 
949  virtual Size get_body_light_profile_count() const = 0;
950 
956  virtual const char* get_light_profile(Size index) const = 0;
957 
965  virtual const char* get_light_profile_url( Size index) const = 0;
966 
973  virtual const char* get_light_profile_owner_module( Size index) const = 0;
974 
976 
978 
980  virtual Size get_bsdf_measurement_count() const = 0;
981 
988  virtual Size get_body_bsdf_measurement_count() const = 0;
989 
995  virtual const char* get_bsdf_measurement(Size index) const = 0;
996 
1004  virtual const char* get_bsdf_measurement_url( Size index) const = 0;
1005 
1012  virtual const char* get_bsdf_measurement_owner_module( Size index) const = 0;
1013 
1015 
1017  virtual Size get_ro_data_segment_count() const = 0;
1018 
1024  virtual const char* get_ro_data_segment_name( Size index) const = 0;
1025 
1030  virtual Size get_ro_data_segment_size( Size index) const = 0;
1031 
1037  virtual const char* get_ro_data_segment_data( Size index) const = 0;
1038 
1040  virtual Size get_code_segment_count() const = 0;
1041 
1046  virtual const char* get_code_segment( Size index) const = 0;
1047 
1052  virtual Size get_code_segment_size( Size index) const = 0;
1053 
1058  virtual const char* get_code_segment_description( Size index) const = 0;
1059 
1064  virtual State_usage get_render_state_usage() const = 0;
1065 
1067  virtual Size get_argument_block_count() const = 0;
1068 
1075  virtual const ITarget_argument_block *get_argument_block(Size index) const = 0;
1076 
1088  Size index,
1089  const ICompiled_material *material,
1090  ITarget_resource_callback *resource_callback) const = 0;
1091 
1093  virtual Size get_argument_layout_count() const = 0;
1094 
1100  virtual const ITarget_value_layout *get_argument_block_layout(Size index) const = 0;
1101 
1103  virtual Size get_string_constant_count() const = 0;
1104 
1110  virtual const char* get_string_constant(Size index) const = 0;
1111 
1118  ITransaction* transaction,
1119  IValue_resource const *resource) const = 0;
1120 
1128  virtual const char* get_callable_function_prototype( Size index, Prototype_language lang)
1129  const = 0;
1130 
1138 
1144  virtual Function_kind get_callable_function_kind( Size index) const = 0;
1145 
1152  virtual Size get_callable_function_argument_block_index( Size index) const = 0;
1153 
1170  virtual Sint32 execute_environment(
1171  Size index,
1172  const Shading_state_environment& state,
1173  Texture_handler_base* tex_handler,
1174  Spectrum_struct* result) const = 0;
1175 
1196  virtual Sint32 execute(
1197  Size index,
1198  const Shading_state_material& state,
1199  Texture_handler_base* tex_handler,
1200  const ITarget_argument_block *cap_args,
1201  void* result) const = 0;
1202 
1223  virtual Sint32 execute_bsdf_init(
1224  Size index,
1225  Shading_state_material& state,
1226  Texture_handler_base* tex_handler,
1227  const ITarget_argument_block *cap_args) const = 0;
1228 
1246  virtual Sint32 execute_bsdf_sample(
1247  Size index,
1248  Bsdf_sample_data *data,
1249  const Shading_state_material& state,
1250  Texture_handler_base* tex_handler,
1251  const ITarget_argument_block *cap_args) const = 0;
1252 
1271  virtual Sint32 execute_bsdf_evaluate(
1272  Size index,
1274  const Shading_state_material& state,
1275  Texture_handler_base* tex_handler,
1276  const ITarget_argument_block *cap_args) const = 0;
1277 
1296  virtual Sint32 execute_bsdf_pdf(
1297  Size index,
1298  Bsdf_pdf_data *data,
1299  const Shading_state_material& state,
1300  Texture_handler_base* tex_handler,
1301  const ITarget_argument_block *cap_args) const = 0;
1302 
1303 
1323  Size index,
1325  const Shading_state_material& state,
1326  Texture_handler_base* tex_handler,
1327  const ITarget_argument_block *cap_args) const = 0;
1328 
1329 
1350  virtual Sint32 execute_edf_init(
1351  Size index,
1352  Shading_state_material& state,
1353  Texture_handler_base* tex_handler,
1354  const ITarget_argument_block *cap_args) const = 0;
1355 
1373  virtual Sint32 execute_edf_sample(
1374  Size index,
1375  Edf_sample_data *data,
1376  const Shading_state_material& state,
1377  Texture_handler_base* tex_handler,
1378  const ITarget_argument_block *cap_args) const = 0;
1379 
1398  virtual Sint32 execute_edf_evaluate(
1399  Size index,
1400  Edf_evaluate_data_base *data,
1401  const Shading_state_material& state,
1402  Texture_handler_base* tex_handler,
1403  const ITarget_argument_block *cap_args) const = 0;
1404 
1423  virtual Sint32 execute_edf_pdf(
1424  Size index,
1425  Edf_pdf_data *data,
1426  const Shading_state_material& state,
1427  Texture_handler_base* tex_handler,
1428  const ITarget_argument_block *cap_args) const = 0;
1429 
1430 
1449  virtual Sint32 execute_edf_auxiliary(
1450  Size index,
1452  const Shading_state_material& state,
1453  Texture_handler_base* tex_handler,
1454  const ITarget_argument_block *cap_args) const = 0;
1455 
1462  virtual Size get_callable_function_df_handle_count( Size func_index) const = 0;
1463 
1471  virtual const char* get_callable_function_df_handle( Size func_index, Size handle_index)
1472  const = 0;
1473 
1476  virtual bool supports_serialization() const = 0;
1477 
1495  virtual const IBuffer* serialize( IMdl_execution_context* context) const = 0;
1496 
1504  virtual State_usage get_callable_function_render_state_usage( Size index) const = 0;
1505 };
1506 
1508 class ILink_unit : public
1509  mi::base::Interface_declare<0x1df9bbb0,0x5d96,0x475f,0x9a,0xf4,0x07,0xed,0x8c,0x2d,0xfd,0xdb>
1510 {
1511 public:
1530  virtual Sint32 add_environment(
1531  const IFunction_call *call,
1532  const char *fname,
1533  IMdl_execution_context *context = 0) = 0;
1534 
1561  const ICompiled_material* inst,
1562  const char* path,
1563  const char* fname,
1564  IMdl_execution_context* context) = 0;
1565 
1601  virtual Sint32 add_material_df(
1602  const ICompiled_material* material,
1603  const char* path,
1604  const char* base_fname,
1605  IMdl_execution_context* context) = 0;
1606 
1641  virtual Sint32 add_material(
1642  const ICompiled_material* material,
1643  Target_function_description* function_descriptions,
1644  Size description_count,
1645  IMdl_execution_context* context) = 0;
1646 };
1647 
1650 {
1652  const char* expression_path = 0,
1653  const char* base_function_name = 0)
1654  : path(expression_path)
1655  , base_fname(base_function_name)
1656  , argument_block_index(~Size(0))
1657  , function_index(~Size(0))
1658  , distribution_kind(ITarget_code::DK_INVALID)
1659  , return_code(~Sint32(0)) // not processed
1660  {
1661  }
1662 
1665  const char* path;
1666 
1671  const char* base_fname;
1672 
1678 
1688 
1692 
1722 };
1723 
1725 
1726 } // namespace neuraylib
1727 
1728 } // namespace mi
1729 
1730 #endif // MI_NEURAYLIB_IMDL_BACKEND_H