RixInterfaces.h Source File

RixInterfaces.h
1 #ifndef RixInterfaces_h
2 #define RixInterfaces_h
3 /* $Revision: #6 $ $Date: 2016/06/14 $ */
4 /*
5 # ------------------------------------------------------------------------------
6 #
7 # Copyright (c) 2006-2015 Pixar Animation Studios. All rights reserved.
8 #
9 # The information in this file (the "Software") is provided for the
10 # exclusive use of the software licensees of Pixar. Licensees have
11 # the right to incorporate the Software into other products for use
12 # by other authorized software licensees of Pixar, without fee.
13 # Except as expressly permitted herein, the Software may not be
14 # disclosed to third parties, copied or duplicated in any form, in
15 # whole or in part, without the prior written permission of
16 # Pixar Animation Studios.
17 #
18 # The copyright notices in the Software and this entire statement,
19 # including the above license grant, this restriction and the
20 # following disclaimer, must be included in all copies of the
21 # Software, in whole or in part, and all permitted derivative works of
22 # the Software, unless such copies or derivative works are solely
23 # in the form of machine-executable object code generated by a
24 # source language processor.
25 #
26 # PIXAR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
27 # ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT
28 # SHALL PIXAR BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES
29 # OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
30 # WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
31 # ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
32 # SOFTWARE.
33 #
34 # Pixar
35 # 1200 Park Ave
36 # Emeryville CA 94608
37 #
38 # ------------------------------------------------------------------------------
39 */
40 
41 #include "ri.h"
42 #include <stddef.h> // for size_t
43 
44 
124 enum RixInterfaceId
126 {
127  k_RixThreadUtils = 0,
128  k_RixMessages,
129  k_RixStatsV1,
130  k_RixGlobalData,
131  k_RixThreadData,
132  k_RixLocalData,
133  k_RixGlobalTokenData,
134  k_RixSubdivEvalV1,
135  k_RixSessionData = 8,
136  k_RixXcpt,
137  k_RixRIB,
138  k_RixDeepTexture,
139  k_RixSubdivisionSurfaceEvaluation,
140  k_RixRIBParser,
141  k_RixTexture2d,
142  k_RixStats,
143  k_RixTimer,
144  k_RixAreaShadow,
145  k_RixRNGDeprecated,
146  k_RixMemoryPool,
147  k_RixRenderState,
148  k_RixSloInfo,
149  k_RixRiCtl,
150  k_RixSymbolResolver,
151  k_RixLightingServices,
152  k_RixGeoDebugger,
153  k_RixTexture,
154  k_RixShadeFunctions,
155  k_RixTransform,
156  k_RixResourceResolver,
157  k_RixLPEInfo,
158  k_RixCustomLPE,
159 };
160 
166 {
167 public:
170  virtual int GetVersion() const { return m_version; }
171 
172 protected:
175 
177  RixInterface(int version) : m_version(version) { }
178 
180  virtual ~RixInterface() { }
181 };
182 
188 {
189 public:
192  virtual RixInterface* GetRixInterface(RixInterfaceId id) const = 0;
193 
195  virtual ~RixContext() { }
196 };
197 
198 
206 class RixXcpt : public RixInterface
207 {
208 public:
211  class XcptHandler
212  {
213  public:
214  virtual void HandleXcpt(int code, int severity, const char *msg) = 0;
215  virtual void HandleExitRequest(int code) = 0;
216 
217  protected:
218  virtual ~XcptHandler() {}
219  };
220 
224  virtual void Register(XcptHandler *) = 0;
225 
227  virtual void Unregister(XcptHandler *) = 0;
228 
229 protected:
230  RixXcpt() : RixInterface(1) { }
231 };
232 
241 class RixMutex
242 {
243 public:
245  virtual ~RixMutex() { }
246 
248  virtual void Lock() = 0;
249 
251  virtual void Unlock() = 0;
252 };
253 
254 
259 {
260 public:
262  virtual RixMutex* NewMutex() const = 0;
263 
264 protected:
267 };
268 
269 
272 class RixMessages : public RixInterface
273 {
274 public:
282  virtual void Error(const char* format, ...) = 0;
283 
285  virtual void ErrorAlways(const char* format, ...) = 0;
286 
288  virtual void Warning(const char* format, ...) = 0;
289 
291  virtual void WarningAlways(const char* format, ...) = 0;
292 
294  virtual void Info(const char* format, ...) = 0;
295 
297  virtual void InfoAlways(const char* format, ...) = 0;
298 
299 protected:
302 };
303 
314 class RixTimer : public RixInterface
315 {
316 public:
318  virtual RtUInt64 SampleTime() = 0;
320  virtual float ConvertIntervalToSeconds(RtUInt64 interval) = 0;
321 
322 protected:
323  RixTimer() : RixInterface(1) {}
324 };
325 
329 {
330 public:
336  virtual void WriteXml(const char* format, ...) = 0;
337 
340  virtual void WriteText(const char* format, ...) = 0;
341 
343  virtual ~RixXmlFile() { }
344 
345  // Helper functions for writings stats.
346  void WriteStat(char const *name, char const *desc, int value)
347  {
348  WriteXml("<int name=\"%s\"", name);
349  if (desc) WriteXml(" description=\"%s\"", desc);
350  WriteXml("> %i </int>\n", value);
351  }
352 
353  void WriteStat(char const *name, char const *desc, RtUInt64 value)
354  {
355  WriteXml("<int name=\"%s\"", name);
356  if (desc) WriteXml(" description=\"%s\"", desc);
357  WriteXml("> %llu </int>\n", value);
358  }
359 
360  void WriteStat(char const *name, char const *desc, float value)
361  {
362  WriteXml("<float name=\"%s\"", name);
363  if (desc) WriteXml(" description=\"%s\"", desc);
364  WriteXml("> %f </float>\n", value);
365  }
366 
367  void WriteStat(char const *name, char const *desc, char const *value)
368  {
369  WriteXml("<string name=\"%s\"", name);
370  if (desc) WriteXml(" description=\"%s\"", desc);
371  WriteXml("> %s </string>\n", value);
372  }
373 
374  void WriteTime(char const *name, char const *desc, float time)
375  {
376  WriteXml("<timer name=\"%s\"", name);
377  if (desc) WriteXml(" description=\"%s\"", desc);
378  WriteXml("><elapsed>%f</elapsed></timer>\n", time);
379  }
380 };
381 
396 class RixStats : public RixInterface
397 {
398 public:
405  virtual void AddTimerStat(float* seconds, const char* name,
406  const char* description) = 0;
407 
416  {
417  public:
418  enum Fmt
419  {
420  k_fmtAsTimeInterval,
421  k_fmtAsMemory,
422  k_fmtAsUInt,
423  k_fmtAsInt,
424  k_fmtAsFloat
425  };
426  virtual ~SimpleStat() {}
427  virtual void Reset() = 0;
428  virtual const char *GetName() = 0;
429  virtual const char *GetDescription() = 0;
430  virtual void GetResults(RtUInt64 *result, Fmt *fmt) = 0;
431  };
432  virtual int AddSimpleStat(SimpleStat *)=0;
433 
440  virtual void AddMemoryStat(size_t* bytes, const char* name,
441  const char* description) = 0;
442 
445  typedef void (*Reporter)(class RixXmlFile* file);
446  typedef void (*ReporterCtx)(void *ctx, class RixXmlFile *);
447 
465  virtual void AddReporter(Reporter func) = 0;
466  virtual void AddReporterCtx(ReporterCtx func, void *ctx) = 0;
467 
473  virtual void AddFileLogStat(const char *filename, const char *path) = 0;
474 
475 protected:
478 };
479 
481 typedef void (*RixCleanupFunc)(RixContext* context, void* data);
482 
540 class RixStorage : public RixInterface
541 {
542 public:
544  virtual void* Get(const char* key) = 0;
545 
549  virtual void Set(const char* key, void* data,
550  RixCleanupFunc cleanup = NULL) = 0;
551 
554  virtual void Clear(const char* key) = 0;
555 
557  virtual void Lock() = 0;
558 
560  virtual void Unlock() = 0;
561 
562 protected:
565 };
566 
567 
574 {
575 public:
581  virtual const char *GetToken(const char *input) = 0;
582 
583 protected:
586 };
587 
608 {
609 public:
610  enum resultType
611  {
612  k_floatResult,
613  k_integerResult,
614  k_stringResult,
615  k_colorResult,
616  k_normalResult,
617  k_vectorResult,
618  k_pointResult,
619  k_hpointResult,
620  k_mpointResult,
621  k_matrixResult
622  };
623 
628  virtual int TextureInfo(const RtString filename, const char *query,
629  void *result, int resultlen,
630  resultType *resulttype, int *resultcount,
631  int faceindex = -1)=0;
632 
636  virtual int TexturePoints1V(const RtString filename, RtInt nPoints,
637  RtInt firstchannel, RtInt nchannels,
638  RtFloat *s, RtFloat *t, RtFloat *result,
639  RtInt n, RtToken tokens[], RtPointer parms[])=0;
640 
644  virtual int TexturePoints4V(const RtString filename, RtInt nPoints,
645  RtInt firstchannel, RtInt nchannels,
646  RtFloat *s0, RtFloat *t0,
647  RtFloat *s1, RtFloat *t1,
648  RtFloat *s2, RtFloat *t2,
649  RtFloat *s3, RtFloat *t3,
650  RtFloat *result, RtInt n, RtToken tokens[],
651  RtPointer parms[])=0;
652 
656  virtual int TexturePointsFrV(const RtString filename, RtInt nPoints,
657  RtInt firstchannel, RtInt nchannels,
658  RtFloat *fr, RtFloat *result,
659  RtInt n, RtToken tokens[], RtPointer parms[])=0;
660 
664  virtual int PTexturePointsFrV(const RtString filename, RtInt nPoints,
665  RtInt firstchannel, RtInt nchannels,
666  RtFloat *faceId, RtFloat *fr,
667  RtFloat *result,
668  RtInt n, RtToken tokens[],
669  RtPointer parms[])=0;
670 
674  virtual int PTexturePointsV(const RtString filename, RtInt nPoints,
675  RtInt firstchannel, RtInt nchannels,
676  RtFloat *faceId,
677  RtFloat *u, RtFloat *v,
678  RtFloat *du1, RtFloat *dv1,
679  RtFloat *du2, RtFloat *dv2,
680  RtFloat *result,
681  RtInt n, RtToken tokens[],
682  RtPointer parms[])=0;
683 
684 protected:
687 };
688 
705 class RixTexture : public RixInterface
706 {
707 public:
708  enum ErrType {
709  Ok = 0,
710  FileNotFound,
711  PartNotFound,
712  InvalidFaceIndex,
713  TextureAccessErr,
714  InvalidDerivatives,
715  InvalidFilter,
716  InvalidFile
717  };
718 
719  struct TxProperties {
720  public:
722  enum TextureType {
723  texture = 0,
724  ptexture,
725  latlong,
726  cubeface,
727  shadow,
728  deepshadow,
729  };
730 
733  : version(1),
734  fileHandle(NULL),
735  nchannels(0),
736  channelTypes(NULL),
737  nparts(0),
738  width(0),
739  height(0),
740  type(texture)
741  { }
742 
743  int version; // Version of this struct
744  RtPointer fileHandle; // If NULL, the file could not be acquired
745  int nchannels; // The # of channels in the texture
746  unsigned char *channelTypes; // The types of the channels
747  // 0 - unknown
748  // 1 - 8 bit
749  // 2 - 16 bit
750  // 3 - 32 bit
751  // 4 - float
752  // 5 - half
753  int nparts; // The number of parts present
754  int width, height; // Width and height of texture
755  TextureType type; // What type of texture?
756  };
757 
758  struct TxParams {
759  public:
761  enum FilterType {
762  Nearest = 0, // *WARNING* disables MIPMAP! No filtering
763  Box, // Fast "box" like filter
764  Bilinear, // Slower, supports derivatives
765  Bspline, // Slower bicubic filter, supports derivatives
766  Mitchell, // Negative lobed, fast, bicubic filter
767  Catmullrom, // Negative lobed, fast, bicubic filter
768  Gaussian, // Gaussian fast filter
769  Lagrangian // Fastest (SSE based) filter
770  };
771 
774  : version(1),
775  nchannels(1),
776  firstchannel(0),
777  lerp(true),
778  filter(Box),
779  sblur(NULL),
780  tblur(NULL),
781  sblurVarying(true),
782  tblurVarying(true),
783  swidth(1.0f),
784  twidth(1.0f),
785  fill(0.0f),
786  faceIndex(NULL)
787  { }
788 
789  int version; // Version of this struct
790  int nchannels; // The number of channels to lookup
791  int firstchannel; // The channel to start the lookup
792  bool lerp; // Should MIP levels be interpolated
793  FilterType filter; // Which filter should be used
794  const float *sblur; // Amount of blur to apply to lookup
795  const float *tblur;
796  bool sblurVarying; // Is the blur uniform?
797  bool tblurVarying;
798  float swidth; // Multiplier for filter radius
799  float twidth;
800  float fill; // Color to fill missing channels
801  float *faceIndex; // a faceIndex to access ptexture
802  };
803 
811  virtual int AcquireTexture (
812  const char *filename,
813  TxProperties &txProperties,
814  bool persistentFilename = false) = 0;
815 
816 
820  virtual int AcquireTexturePart (
821  int partIndex,
822  TxProperties const &txProperties,
823  TxProperties &partProperties) = 0;
824 
825 
828  virtual int ReleaseTexture (TxProperties const &txProperties) = 0;
829 
830 
840  virtual int Texture (
841  TxProperties const &txProperties,
842  TxParams const &txParams,
843  RtInt nPoints,
844  RtFloat2 const *st,
845  RtFloat const *stRadius,
846  RtFloat *result,
847  int *runFlags = NULL) = 0;
848 
849 
865  virtual int TextureDerivatives (
866  TxProperties const &txProperties,
867  TxParams const &txParams,
868  RtInt nPoints,
869  RtFloat2 const *st,
870  RtFloat const *dsdu,
871  RtFloat const *dtdu,
872  RtFloat const *dsdv,
873  RtFloat const *dtdv,
874  RtFloat *result,
875  RtFloat *dresultds, RtFloat *dresultdt,
876  int *runFlags = NULL) = 0;
877 
894  virtual int Ptexture (
895  TxProperties const &txProperties,
896  TxParams const &txParams,
897  RtInt nPoints,
898  RtFloat2 const *uv,
899  RtFloat const *uWidth,
900  RtFloat const *vWidth,
901  RtFloat *result,
902  int *runFlags = NULL) = 0;
903 
904 
908  // NOTE: No filtering is applied to the data being read.
909  virtual int TextureData (
910  TxProperties const &txProperties,
911  TxParams const &txParams,
912  int mipLevel,
913  int cubeFace,
914  void *result) = 0;
915 
916 protected:
919 };
920 
925 {
926 public:
928  virtual RtFloat Noise(RtFloat in) = 0;
929  virtual RtFloat Noise(RtFloat2 const &in) = 0;
930  virtual RtFloat Noise(RtFloat3 const &in) = 0;
931  virtual RtFloat Noise(RtFloat3 const &in, RtFloat inF) = 0;
932 
933  virtual RtFloat3 Noise3(RtFloat in) = 0;
934  virtual RtFloat3 Noise3(RtFloat2 const &in) = 0;
935  virtual RtFloat3 Noise3(RtFloat3 const &in) = 0;
936  virtual RtFloat3 Noise3(RtFloat3 const &in, RtFloat inF) = 0;
937 
939  virtual RtFloat PNoise(RtFloat in, RtFloat period) = 0;
940  virtual RtFloat PNoise(RtFloat2 const &in, RtFloat2 const &period) = 0;
941  virtual RtFloat PNoise(RtFloat3 const &in, RtFloat3 const &period) = 0;
942  virtual RtFloat PNoise(RtFloat3 const &in, RtFloat inF,
943  RtFloat3 const &period, RtFloat periodF) = 0;
944 
945  virtual RtFloat3 PNoise3(RtFloat in, RtFloat period) = 0;
946  virtual RtFloat3 PNoise3(RtFloat2 const &in, RtFloat2 const &period) = 0;
947  virtual RtFloat3 PNoise3(RtFloat3 const &in, RtFloat3 const &period) = 0;
948  virtual RtFloat3 PNoise3(RtFloat3 const &in, RtFloat inF,
949  RtFloat3 const &period, RtFloat periodF) = 0;
950 
952  virtual RtFloat CellNoise(RtFloat in) = 0;
953  virtual RtFloat CellNoise(RtFloat2 const &in) = 0;
954  virtual RtFloat CellNoise(RtFloat3 const &in) = 0;
955  virtual RtFloat CellNoise(RtFloat3 const &in, RtFloat inF) = 0;
956 
957  virtual RtFloat3 CellNoise3(RtFloat in) = 0;
958  virtual RtFloat3 CellNoise3(RtFloat2 const &in) = 0;
959  virtual RtFloat3 CellNoise3(RtFloat3 const &in) = 0;
960  virtual RtFloat3 CellNoise3(RtFloat3 const &in, RtFloat inF) = 0;
961 
963  enum SplineType {
964  Bezier = 0,
965  BSpline,
966  Hermite,
967  Linear,
968  Catmullrom
969  };
970 
971  virtual RtFloat SolveSpline (SplineType type,
972  RtFloat const knot[],
973  RtInt nKnots,
974  RtFloat a) = 0;
975  virtual RtFloat EvalSpline (SplineType type,
976  RtFloat const knot[],
977  RtInt nKnots,
978  RtFloat a) = 0;
979  virtual RtFloat3 EvalSpline3(SplineType type,
980  RtFloat3 const knot[],
981  RtInt nknot,
982  RtFloat a) = 0;
983 
984 protected:
987 };
988 
992 {
993 public:
998  virtual RtInt TransformPoints(RtConstString fromspace,
999  RtConstString tospace,
1000  RtInt n, RtPoint p[], RtFloat time) = 0;
1001 
1003  virtual void TransformPoints(RtMatrix m, RtInt n, RtPoint p[]) = 0;
1004 
1009  virtual RtInt TransformMatrix(RtConstString fromspace,
1010  RtConstString tospace,
1011  RtFloat time, RtMatrix m) = 0;
1012 
1013 protected:
1016 };
1017 
1026 
1028 {
1029 public:
1030 
1032 virtual int AreaShadowFrV(RtInt nMaps, const RtString mapNames[],
1033  RtFloat* filterRegions,
1034  RtInt nLightSamples,
1035  RtPoint* lightPoints,
1036  RtColor* result,
1037  RtColor* perRayResult,
1038  RtVector* perRayL,
1039  RtFloat* perRayLMag,
1040  RtInt n, RtToken tokens[],
1041  RtPointer parms[]) = 0;
1042 
1044 virtual int AreaShadowPV(RtInt nMaps, const RtString mapNames[],
1045  RtFloat* points,
1046  RtInt nLightSamples,
1047  RtPoint* lightPoints,
1048  RtColor* result,
1049  RtColor* perRayResult,
1050  RtVector* perRayL,
1051  RtFloat* perRayLMag,
1052  RtInt n, RtToken tokens[],
1053  RtPointer parms[]) = 0;
1054 
1055 protected:
1058 };
1059 
1075 {
1076 public:
1077  enum BlockLifetime
1078  {
1079  k_EvaluationLifetime,
1080  // The duration of a single evaluation of the invoking plugin
1081  // function, method or execution block. Usually RixAlloca
1082  // should be preferred over EvaluationLifetime unless the
1083  // memory required exceeds the amounts reasonable for the
1084  // stack.
1085  k_ShadeContextLifetime,
1086  // the duration of a full shader evaluation
1087  };
1088 
1089  // Allocate will return 0 either the requested lifetime is not supported
1090  // in the current context or if the pool is exhausted. The latter
1091  // condition is generally not recoverable.
1092  virtual void *Allocate(size_t numbytes, BlockLifetime) = 0;
1093 
1094 protected:
1095  RixMemoryPool() : RixInterface(1) { }
1096 };
1097 
1100 {
1101 public:
1103  {
1104  const char *renderer;
1105  const char *version;
1106  float _UNUSED;
1107  RtInt versionCode[4];
1108  char _reserved[32];
1109  };
1111  virtual int GetRendererInfo(RendererInfo *) = 0;
1112 
1113  struct FrameInfo
1114  {
1115  FrameInfo() : _vers(2) {}
1116  enum t_integrationMode
1117  {
1118  k_distribution,
1119  k_pathtrace,
1120  };
1121 
1122  enum t_displayStyle
1123  {
1124  k_partialPixels,
1125  k_finalPixels
1126  };
1127 
1128  int frame;
1129  int pixelSamples[2];
1130  int nthreads;
1131  float shutter[2]; // when shutter values are equal, no motion-blur
1132  t_integrationMode integrationMode;
1133  bool rerendering;
1134  struct
1135  {
1136  int nDisplays; // indexes for GetDspyInfo
1137  int resolution[2];
1138  t_displayStyle displayStyle;
1139  } displayState;
1140 
1141  int _vers;
1142 
1143  // added in version 2
1144  // integrator settings are only non-null in RIS mode
1145  char const *integratorName;
1146  char const *integratorPath;
1147  class RixIntegratorEnvironment const *integratorEnv;
1148 
1149  char _reserved[32];
1150  };
1151 
1154  virtual int GetFrameInfo(FrameInfo *) = 0;
1155 
1156  struct DspyInfo
1157  {
1158  char const *name;
1159  char const *type;
1160  char const *mode;
1161  char _reserved[32];
1162  };
1165  virtual int GetDspyInfo(int dspyId, DspyInfo *) = 0;
1166 
1167  enum RayType
1168  {
1169  k_rtInvalid=0,
1170  k_rtCamera, /* primary visibility ray from a camera */
1171  k_rtLight, /* photon ray directly from a light source */
1172  k_rtSpecular, /* specularly reflected ray/photon */
1173  k_rtDiffuse, /* diffusely reflected ray/photon */
1174  k_rtTransmission, /* shadow ray */
1175  k_rtDirectlight, /* directlighting ray */
1176  k_rtNumRayTypes
1177  };
1178 
1179  enum ShadingIntent
1180  {
1181  k_siInvalid=0,
1182  k_siShadeGrid,
1183  k_siShadeRay,
1184  k_siCache,
1185  k_siNumShadingIntents
1186  };
1187 
1188  struct RayCtxInfo
1189  {
1190  bool rayhit; /* Camera rays can either be reyes or raytraced */
1191  RayType raytype;
1192  char const *raylabel;
1193  int depth, diffusedepth, speculardepth, shadowdepth, subsurfacedepth;
1194  int integratorIteration; // always 0 when in distribution integration
1195  int currentDecimation, maxDecimation; // only nonzero during rerendering
1196  ShadingIntent shadingIntent;
1197  char _reserved[32];
1198  };
1199 
1203  virtual int GetRayCtxInfo(RayCtxInfo *) = 0;
1204 
1218  enum Type
1219  {
1220  k_Float,
1221  k_Integer,
1222  k_StringV,
1223  k_Color,
1224  k_Normal,
1225  k_Vector,
1226  k_Point,
1227  k_HPoint,
1228  k_MPoint,
1229  k_Matrix
1230  };
1231  virtual int GetOption(const char *name, void *result, int resultlen,
1232  Type *resulttype, int *resultcount) = 0;
1233 
1234  virtual int GetAttribute(const char *name, void *result, int resultlen,
1235  Type *resulttype, int *resultcount) = 0;
1236 
1249  virtual int GetAttrIdNameStack(char const *idstack[], unsigned maxlen) = 0;
1250 
1251 
1252 
1253 protected:
1254  RixRenderState() : RixInterface(2) { }
1255 };
1256 
1258 {
1259 public:
1264  virtual RtToken ResolveToken(char const *nm) = 0;
1265 
1266  enum SymbolGroup
1267  {
1268  k_PixelFilter = 0,
1269  k_Basis = 1,
1270  k_Procedural = 2,
1271  k_ErrorHandler = 3,
1272  k_RiEntryPoint = 4
1273  };
1274  //
1287  virtual RtPointer ResolveSymbol(const char *nm, SymbolGroup group) = 0;
1288 
1289 protected:
1291 };
1292 
1294 {
1295 public:
1296  enum ResourceType
1297  {
1298  k_Shader=0,
1299  k_Texture,
1300  k_Archive,
1301  k_Display,
1302  k_Procedural,
1303  k_RifFilter,
1304  k_RixPlugin
1305  };
1306 
1309  virtual char const *GetResourcePaths(ResourceType) = 0;
1310 
1322  virtual int ResolveResource(ResourceType, char const *nm,
1323  char result[], int maxlen) = 0;
1324 
1325 protected:
1327 };
1328 
1330 {
1331 public:
1332  virtual void EmitVector(RtVector3 v, RtColorRGB c)=0;
1333  virtual void EmitPoint(RtPoint3 p, RtColorRGB c)=0;
1334  virtual void EmitPointNormal(RtPoint3 p, RtNormal3 n, RtColorRGB c)=0;
1335  virtual void EmitLine(RtPoint3 p1, RtPoint3 p2, RtColorRGB c)=0;
1336  virtual void EmitBound(RtPoint3 pmin, RtPoint3 pmax, RtColorRGB c)=0;
1337  virtual void Clear()=0;
1338  virtual void Flush()=0;
1339 
1340 protected:
1341  RixGeoDebugger() : RixInterface(1) {}
1342 };
1343 
1345 extern "C" {
1346  PRMANAPI class RixContext *RixGetContext();
1347  PRMANAPI class RixContext *RixGetContextViaRMANTREE(const char*rmantree=0L,
1348  bool printerror=true);
1349 }
1350 
1351 typedef RtInt RixLPEToken;
1352 
1355 class RixLPEInfo : public RixInterface
1356 {
1357  public:
1362  virtual int GetLpeIdByName(bool discrete, bool specular,
1363  bool reflect, bool user,
1364  unsigned char lobeId, char const *name) = 0;
1365 
1369  virtual int GetNumPotentialDiffuseLobes() = 0;
1370  virtual int GetNumPotentialSpecularLobes() = 0;
1371  virtual int GetNumPotentialUserLobes() = 0;
1372  virtual RixLPEToken StringToToken(char const *str) = 0;
1373 
1374 protected:
1375  RixLPEInfo() : RixInterface(1) {}
1376 };
1377 
1378 class RixLPEState;
1379 class RixShadingContext;
1380 
1381 // This is a callback routine for use with the
1382 // RixCustomLPE::RegisterScatterCallback() and
1383 // RixCustomLPE::InvokeScatterCallbacks(), described in more detail below.
1384 typedef void (*RixLPECallback)(void *userData,
1385  RixLPEState *lpeState,
1386  RixShadingContext const *sCtx,
1387  int sCtxIndex,
1388  RtColorRGB const &thruput,
1389  RtColorRGB const *lgtTrans,
1390  bool firstContribution);
1391 
1394 {
1395  public:
1396 
1397  // Use this method to return an integer identifier that corresponds to
1398  // a given Light Path Expression (LPE).
1399  virtual int LookupLPE(char const *lpeExpr) = 0;
1400 
1401  // This method returns true if the 'customLpe' integer identifier
1402  // (which should be obtained by calling LookupLPE()) matches the current
1403  // ray hit, returning true or false along with the cumulative path
1404  // throughput corresponding to the custom LPE. This method should typically
1405  // be called from within a registered "transition" callback routine
1406  // (see RegisterScatterCallback() below).
1407  virtual bool MatchesLPE(int customLpe,
1408  RixLPEState *lpeState,
1409  RtColorRGB &thruput) = 0;
1410 
1411  // Use this method to register a "scatter" callback. Each scattering
1412  // event along the ray path counts as a "scatter" event (that is, each
1413  // ray-geometry intersection hit point that results in light being
1414  // scattered throughout the scene). Ater registering a scatter callback,
1415  // the callback routine will be invoked at each scattering event. Within
1416  // a scatter callback routine one might make a call to the MatchesLPE()
1417  // method in order to determine whether a particular custom LPE matches
1418  // the current ray path history.
1419  virtual void RegisterScatterCallback(RixLPECallback callbackFunc,
1420  void *userData = NULL) = 0;
1421 
1422  // Calling this method will invoke all registered scatter callback routines.
1423  // Typically this method is only called internally by the core rendering
1424  // code (and typically end-user code would not need to call this method
1425  // directly). Instead this routine is called indirectly via the RixLPE
1426  // interface whenever there is a scattering event.
1427  virtual void InvokeScatterCallbacks(RixLPEState *lpeState,
1428  RixShadingContext const *sCtx,
1429  int sCtxIndex,
1430  RtColorRGB const &thruput,
1431  RtColorRGB const *lgtTrans,
1432  bool firstContribution) = 0;
1433 
1434 protected:
1435  RixCustomLPE() : RixInterface(1) {}
1436 };
1437 
1438 #endif // RIX_INTERFACE_H