Material Definition Language API nvidia_logo_transpbg.gif Up
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
ifunction_definition.h
Go to the documentation of this file.
1 /***************************************************************************************************
2  * Copyright 2020 NVIDIA Corporation. All rights reserved.
3  **************************************************************************************************/
6 
7 #ifndef MI_NEURAYLIB_IFUNCTION_DEFINITION_H
8 #define MI_NEURAYLIB_IFUNCTION_DEFINITION_H
9 
10 #include <cstring>
11 
14 
15 namespace mi {
16 
17 namespace neuraylib {
18 
23 class IFunction_call;
24 class IMdl_execution_context;
25 
35 class IFunction_definition : public
36  mi::base::Interface_declare<0x3504744d,0xd45b,0x4a99,0xb6,0x21,0x10,0x9e,0xd5,0xcb,0x36,0xc1,
37  neuraylib::IScene_element>
38 {
39 public:
40 
45  enum Semantics
46  {
47  DS_UNKNOWN = 0,
48 
57 
59 
60  // Unary operators
61  DS_OPERATOR_FIRST = 0x0200,
62  DS_UNARY_FIRST = DS_OPERATOR_FIRST,
63  DS_BITWISE_COMPLEMENT = DS_UNARY_FIRST,
72  DS_UNARY_LAST = DS_CAST,
73 
74  // Binary operators
75  DS_BINARY_FIRST,
76  DS_SELECT = DS_BINARY_FIRST,
110  DS_BINARY_LAST = DS_SEQUENCE,
111 
112  // Ternary operator
114  DS_OPERATOR_LAST = DS_TERNARY,
115 
116  // ::math module intrinsics
117  DS_INTRINSIC_MATH_FIRST = 0x0300,
119  = DS_INTRINSIC_MATH_FIRST,
177  DS_INTRINSIC_MATH_LAST = DS_INTRINSIC_MATH_DY,
178 
179  // ::state module intrinsics
180  DS_INTRINSIC_STATE_FIRST = 0x0400,
182  = DS_INTRINSIC_STATE_FIRST,
207  DS_INTRINSIC_STATE_LAST = DS_INTRINSIC_STATE_WAVELENGTH_MAX,
208 
209  // ::tex module intrinsics
210  DS_INTRINSIC_TEX_FIRST = 0x0500,
212  = DS_INTRINSIC_TEX_FIRST,
226  DS_INTRINSIC_TEX_LAST = DS_INTRINSIC_TEX_TEXTURE_ISVALID,
227 
228  // ::df module intrinsics
229  DS_INTRINSIC_DF_FIRST = 0x0600,
230 
232  = DS_INTRINSIC_DF_FIRST,
236 
258  DS_INTRINSIC_DF_MICROFACET_BECKMANN_SMITH_BSDF,
273  DS_INTRINSIC_DF_COLOR_MEASURED_CURVE_LAYER,
279  DS_INTRINSIC_DF_LAST = DS_INTRINSIC_DF_CHIANG_HAIR_BSDF,
280 
281 #ifndef MDL_SOURCE_RELEASE
282  // ::nvidia::df module intrinsics
283  DS_INTRINSIC_NVIDIA_DF_FIRST = 0x0700,
284 
305 
306 
307  DS_INTRINSIC_NVIDIA_DF_MICROFACET_SIN_K_VC_BSDF,
308  DS_INTRINSIC_NVIDIA_DF_MICROFACET_MS_TEST_BSDF,
309 
310  DS_INTRINSIC_NVIDIA_DF_LAST = DS_INTRINSIC_NVIDIA_DF_MICROFACET_SIN_K_VC_BSDF,
311 #endif
312 
313  // ::scene module intrinsics
314  DS_INTRINSIC_SCENE_FIRST = 0x0800,
315 
316  DS_INTRINSIC_SCENE_DATA_ISVALID
317  = DS_INTRINSIC_SCENE_FIRST,
336  DS_INTRINSIC_SCENE_LAST = DS_INTRINSIC_SCENE_DATA_LOOKUP_UNIFORM_COLOR,
337 
338  // ::debug module intrinsics
339  DS_INTRINSIC_DEBUG_FIRST = 0x0900,
340 
342  = DS_INTRINSIC_DEBUG_FIRST,
345  DS_INTRINSIC_DEBUG_LAST = DS_INTRINSIC_DEBUG_PRINT,
346 
347  // DAG backend intrinsics
348  DS_INTRINSIC_DAG_FIRST = 0x0A00,
350  DS_INTRINSIC_DAG_FIELD_ACCESS = DS_INTRINSIC_DAG_FIRST,
353  DS_INTRINSIC_DAG_LAST = DS_INTRINSIC_DAG_ARRAY_LENGTH,
354 
355  DS_FORCE_32_BIT = 0xffffffffU // Undocumented, for alignment only.
356  };
357 
361  virtual const char* get_module() const = 0;
362 
369  virtual const char* get_mdl_name() const = 0;
370 
373  virtual const char* get_prototype() const = 0;
374 
376  virtual Semantics get_semantic() const = 0;
377 
381  inline bool is_array_constructor() const { return strcmp( get_mdl_name(), "T[](...)") == 0; }
382 
384  virtual bool is_exported() const = 0;
385 
391  virtual bool is_uniform() const = 0;
392 
396  virtual const IType* get_return_type() const = 0;
397 
408  template<class T>
409  const T* get_return_type() const
410  {
411  const IType* ptr_itype = get_return_type();
412  if ( !ptr_itype)
413  return 0;
414  const T* ptr_T = static_cast<const T*>( ptr_itype->get_interface( typename T::IID()));
415  ptr_itype->release();
416  return ptr_T;
417  }
418 
420  virtual Size get_parameter_count() const = 0;
421 
426  virtual const char* get_parameter_name( Size index) const = 0;
427 
432  virtual Size get_parameter_index( const char* name) const = 0;
433 
435  virtual const IType_list* get_parameter_types() const = 0;
436 
442  virtual const IExpression_list* get_defaults() const = 0;
443 
450  virtual const IExpression_list* get_enable_if_conditions() const = 0;
451 
458  virtual Size get_enable_if_users(Size index) const = 0;
459 
467  virtual Size get_enable_if_user(Size index, Size u_index) const = 0;
468 
471  virtual const IAnnotation_block* get_annotations() const = 0;
472 
475  virtual const IAnnotation_block* get_return_annotations() const = 0;
476 
483  virtual const IAnnotation_list* get_parameter_annotations() const = 0;
484 
492  virtual const char* get_thumbnail() const = 0;
493 
504  virtual bool is_valid(IMdl_execution_context* context) const = 0;
505 
539  const IExpression_list* arguments, Sint32* errors = 0) const = 0;
540 
547  virtual const IExpression_direct_call* get_body() const = 0;
548 
550  virtual Size get_temporary_count() const = 0;
551 
557  virtual const IExpression* get_temporary( Size index) const = 0;
558 
569  virtual const char* get_temporary_name( Size index) const = 0;
570 
583  template<class T>
584  const T* get_temporary( Size index) const
585  {
586  const IExpression* ptr_iexpression = get_temporary( index);
587  if ( !ptr_iexpression)
588  return 0;
589  const T* ptr_T = static_cast<const T*>( ptr_iexpression->get_interface( typename T::IID()));
590  ptr_iexpression->release();
591  return ptr_T;
592  }
593 
594 };
595 
597  // end group mi_neuray_mdl_elements
599 
600 } // namespace neuraylib
601 
602 } // namespace mi
603 
604 #endif // MI_NEURAYLIB_IFUNCTION_DEFINITION_H