RenderMan  26.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
RixInterfaces.h
Go to the documentation of this file.
1 /*
2 # ------------------------------------------------------------------------------
3 #
4 # Copyright (c) 2022 Pixar. All rights reserved.
5 #
6 # The information in this file (the "Software") is provided for the exclusive
7 # use of the software licensees of Pixar ("Licensees"). Licensees have the
8 # right to incorporate the Software into other products for use by other
9 # authorized software licensees of Pixar, without fee. Except as expressly
10 # permitted herein, the Software may not be disclosed to third parties, copied
11 # or duplicated in any form, in whole or in part, without the prior written
12 # permission of Pixar.
13 #
14 # The copyright notices in the Software and this entire statement, including the
15 # above license grant, this restriction and the following disclaimer, must be
16 # included in all copies of the Software, in whole or in part, and all permitted
17 # derivative works of the Software, unless such copies or derivative works are
18 # solely in the form of machine-executable object code generated by a source
19 # language processor.
20 #
21 # PIXAR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
22 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL PIXAR BE
23 # LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
24 # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
25 # OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
26 # CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. IN NO CASE WILL
27 # PIXAR'S TOTAL LIABILITY FOR ALL DAMAGES ARISING OUT OF OR IN CONNECTION WITH
28 # THE USE OR PERFORMANCE OF THIS SOFTWARE EXCEED $50.
29 #
30 # Pixar
31 # 1200 Park Ave
32 # Emeryville CA 94608
33 #
34 # ------------------------------------------------------------------------------
35 */
36 
37 #ifndef RixInterfaces_h
38 #define RixInterfaces_h
39 
40 #include <cstddef> // for NULL, size_t
41 #include <utility> // for std::move
42 #include "RiTypesHelper.h" // for RtFloat3, RtUString, etc
43 
44 #include "stats/Roz.h"
45 
46 class RixLPEState;
47 class RixShadingContext;
48 class RiPredefinedStrings;
49 
93 enum RixInterfaceId
95 {
96  // clang-format off
111  k_RixRiCtl = 20,
127  // clang-format on
128 };
129 
135 {
136 public:
137  // type of the results returned by
138  // - RixRenderState::GetAttribute
139  // - RixRenderState::GetOption
140  // - RixTexture::GetProperty
141  enum Type
142  {
153  };
156  virtual int GetVersion() const { return m_version; }
157 
158 protected:
161 
163  RixInterface(int version) : m_version(version) {}
164 
166  virtual ~RixInterface() {}
167 };
168 
174 {
175 public:
178  virtual RixInterface* GetRixInterface(RixInterfaceId id) const = 0;
179 
181  virtual ~RixContext() {}
182 };
183 
191 class RixXcpt : public RixInterface
192 {
193 public:
197  {
198  public:
199  virtual void HandleXcpt(int code, int severity, const char* msg) = 0;
200  virtual void HandleExitRequest(int code) = 0;
201 
202  protected:
203  virtual ~XcptHandler() {}
204  };
205 
209  virtual void Register(XcptHandler*) = 0;
210 
212  virtual void Unregister(XcptHandler*) = 0;
213 
216  virtual void SetBuiltinHandler(RtUString name) = 0;
217 
218 protected:
220 };
221 
222 
228 {
229 public:
231  virtual uint32_t XXHash32(void const* input, size_t size, unsigned seed)=0;
232 
234  virtual uint64_t XXHash64(void const* input, size_t size, unsigned seed)=0;
235 
236 protected:
239 };
240 
243 class RixMessages : public RixInterface
244 {
245 public:
250 
252  virtual void Error(const char* format, ...) = 0;
253 
255  virtual void ErrorAlways(const char* format, ...) = 0;
256 
258  virtual void Warning(const char* format, ...) = 0;
259 
261  virtual void WarningAlways(const char* format, ...) = 0;
262 
264  virtual void Info(const char* format, ...) = 0;
265 
267  virtual void InfoAlways(const char* format, ...) = 0;
268 
269 protected:
272 };
273 
290 class RixTexture : public RixInterface
291 {
292 public:
293  enum ErrType
294  {
295  Ok = 0,
303  };
304 
306  {
307  public:
310  {
311  texture = 0,
319  };
320 
323  : version(3),
324  fileHandle(NULL),
325  nchannels(0),
326  channelTypes(NULL),
327  nparts(0),
328  width(0),
329  height(0),
330  pixelAspectRatio(0.0f),
331  type(texture),
332  statsId(stats::DataLocId::InvalidId())
333  {
334  }
335 
336  int version; // Version of this struct
337  void* fileHandle; // If NULL, the file could not be acquired
338  int nchannels; // The # of channels in the texture
339  unsigned char* channelTypes; // The types of the channels
340  // 0 - unknown
341  // 1 - 8 bit
342  // 2 - 16 bit
343  // 3 - 32 bit
344  // 4 - float
345  // 5 - half
346  int nparts; // The number of parts present
347  int width, height; // Width and height of texture
348  float pixelAspectRatio; // Pixel aspect ratio of texture
349  TextureType type; // What type of texture?
350  stats::DataLocId statsId; // ID of this texture for stats tracking.
351  };
352 
354  {
359  };
360 
361  struct TxParams
362  {
363  public:
366  {
367  Nearest = 0, // *WARNING* disables MIPMAP! No filtering
368  Box, // Fast "box" like filter
369  Bilinear, // Slower, supports derivatives
370  Bspline, // Slower bicubic filter, supports derivatives
371  Mitchell, // Negative lobed, fast, bicubic filter - PTEX ONLY
372  Catmullrom, // Negative lobed, fast, bicubic filter - PTEX ONLY
373  Gaussian, // Gaussian fast filter
374  Lagrangian, // Fastest (SSE based) filter
375  BsplineAniso // Same as Bspline, but supports anisotropic filtering
376  };
377 
380  : version(1),
381  nchannels(1),
382  firstchannel(0),
383  lerp(true),
384  invertT(false),
385  filter(Box),
386  sblur(NULL),
387  tblur(NULL),
388  sblurVarying(true),
389  tblurVarying(true),
390  swidth(1.0f),
391  twidth(1.0f),
392  fill(0.f),
393  faceIndex(NULL)
394  {
395  }
396 
397  int version; // Version of this struct
398  int nchannels; // The number of channels to lookup
399  int firstchannel; // The channel to start the lookup
400  bool lerp; // Should MIP levels be interpolated
401  bool invertT; // Should the texture space origin be bottom left
402  // (false) or top left (true)
403  FilterType filter; // Which filter should be used
404  const float* sblur; // Amount of blur to apply to lookup
405  const float* tblur;
406  bool sblurVarying; // Is the blur uniform?
408  float swidth; // Multiplier for filter radius
409  float twidth;
410  float fill; // Value to fill missing channels
411  float* faceIndex; // A faceIndex to access ptexture
412  };
413 
427  virtual int AcquireTexture(
428  RtUString const fileName,
429  TxAtlasStyle const atlasStyle,
430  TxProperties& txProperties) = 0;
431 
435  virtual int AcquireTexturePart(
436  int partIndex,
437  TxProperties const& txProperties,
438  TxProperties& partProperties) = 0;
439 
442  virtual int ReleaseTexture(TxProperties const& txProperties) = 0;
443 
458  virtual int Texture(
459  TxProperties const& txProperties,
460  TxParams const& txParams,
461  int nPoints,
462  RtFloat2 const* st,
463  float const* stRadius,
464  float* result,
465  int* runFlags = NULL) = 0;
466  virtual int Texture(
467  TxProperties const& txProperties,
468  TxParams const& txParams,
469  int nPoints,
470  RtFloat3 const* st,
471  float const* stRadius,
472  float* result,
473  int* runFlags = NULL) = 0;
474 
494  virtual int TextureDerivatives(
495  TxProperties const& txProperties,
496  TxParams const& txParams,
497  int nPoints,
498  RtFloat2 const* st,
499  float const* dsdu,
500  float const* dtdu,
501  float const* dsdv,
502  float const* dtdv,
503  float const* dufp,
504  float const* dvfp,
505  float* result,
506  float* dresultds,
507  float* dresultdt,
508  int* runFlags = NULL) = 0;
509  virtual int TextureDerivatives(
510  TxProperties const& txProperties,
511  TxParams const& txParams,
512  int nPoints,
513  RtFloat3 const* st,
514  float const* dsdu,
515  float const* dtdu,
516  float const* dsdv,
517  float const* dtdv,
518  float const* dufp,
519  float const* dvfp,
520  float* result,
521  float* dresultds,
522  float* dresultdt,
523  int* runFlags = NULL) = 0;
524 
541  virtual int Ptexture(
542  TxProperties const& txProperties,
543  TxParams const& txParams,
544  int nPoints,
545  RtFloat2 const* uv,
546  float const* uWidth,
547  float const* vWidth,
548  float* result,
549  int* runFlags = NULL) = 0;
550 
573  virtual int PtextureDerivatives(
574  TxProperties const& txProperties,
575  TxParams const& txParams,
576  int nPoints,
577  RtFloat2 const* st,
578  float const* dsdu,
579  float const* dtdu,
580  float const* dsdv,
581  float const* dtdv,
582  float* result,
583  float* dresultds,
584  float* dresultdt,
585  int* runFlags = NULL) = 0;
586 
590  // NOTE: No filtering is applied to the data being read.
591  virtual int TextureData(
592  TxProperties const& txProperties,
593  TxParams const& txParams,
594  int mipLevel,
595  int cubeFace,
596  void* result) = 0;
597 
598  virtual int GetProperty(
599  TxProperties const& txProperties,
600  RtUString const propertyName,
601  void* result,
602  int resultLen,
603  Type* resultType,
604  int* resultCount
605  ) = 0;
606 
627  virtual const ErrType* GetLastError() = 0;
628 
629 protected:
632 };
633 
637 {
638 public:
639  virtual int RxTexture3dV(
640  char const* filename,
641  RtPoint3 point,
642  RtNormal3 normal,
643  float filterradius,
644  int n,
645  RtUString tokens[],
646  void* parms[]) = 0;
647 
648  // The RxTexture3d interface takes name/value pairs through the ellipses.
649  // It is important to note that names should be passed through as c-strings.
650  // These are converted to unique strings internally so something to
651  // note is that the vectorized API, RxTexture3dV, is likely to be more
652  // efficient and scalable for names and values that can be constructed up
653  // front.
654  virtual int RxTexture3d(
655  char const* filename,
656  RtPoint3 point,
657  RtNormal3 normal,
658  float filterradius,
659  ...) = 0;
660 
661 protected:
664 };
665 
670 {
671 public:
673  virtual float Noise(float in) = 0;
674  virtual float Noise(RtFloat2 const& in) = 0;
675  virtual float Noise(RtFloat3 const& in) = 0;
676  virtual float Noise(RtFloat3 const& in, float inF) = 0;
677 
678  virtual RtFloat3 Noise3(float in) = 0;
679  virtual RtFloat3 Noise3(RtFloat2 const& in) = 0;
680  virtual RtFloat3 Noise3(RtFloat3 const& in) = 0;
681  virtual RtFloat3 Noise3(RtFloat3 const& in, float inF) = 0;
682 
684  virtual float PNoise(float in, float period) = 0;
685  virtual float PNoise(RtFloat2 const& in, RtFloat2 const& period) = 0;
686  virtual float PNoise(RtFloat3 const& in, RtFloat3 const& period) = 0;
687  virtual float PNoise(
688  RtFloat3 const& in,
689  float inF,
690  RtFloat3 const& period,
691  float periodF) = 0;
692 
693  virtual RtFloat3 PNoise3(float in, float period) = 0;
694  virtual RtFloat3 PNoise3(RtFloat2 const& in, RtFloat2 const& period) = 0;
695  virtual RtFloat3 PNoise3(RtFloat3 const& in, RtFloat3 const& period) = 0;
696  virtual RtFloat3 PNoise3(
697  RtFloat3 const& in,
698  float inF,
699  RtFloat3 const& period,
700  float periodF) = 0;
701 
703  virtual float CellNoise(float in) = 0;
704  virtual float CellNoise(RtFloat2 const& in) = 0;
705  virtual float CellNoise(RtFloat3 const& in) = 0;
706  virtual float CellNoise(RtFloat3 const& in, float inF) = 0;
707 
708  virtual RtFloat3 CellNoise3(float in) = 0;
709  virtual RtFloat3 CellNoise3(RtFloat2 const& in) = 0;
710  virtual RtFloat3 CellNoise3(RtFloat3 const& in) = 0;
711  virtual RtFloat3 CellNoise3(RtFloat3 const& in, float inF) = 0;
712 
715  {
716  Bezier = 0,
722  };
723 
724  virtual float SolveSpline(
725  SplineType type,
726  float const knot[],
727  int nKnots,
728  float a) = 0;
729  virtual float EvalSpline(
730  SplineType type,
731  float const knot[],
732  int nKnots,
733  float a) = 0;
734  virtual RtFloat3 EvalSpline3(
735  SplineType type,
736  RtFloat3 const knot[],
737  int nknot,
738  float a) = 0;
739 
740 protected:
743 };
744 
748 {
749 public:
754  virtual int TransformPoints(
755  RtUString const fromspace,
756  RtUString const tospace,
757  int n,
758  RtPoint3 p[],
759  float time) = 0;
760 
762  virtual void TransformPoints(RtMatrix4x4 const& m, int n, RtPoint3 p[]) = 0;
763 
768  virtual int TransformMatrix(
769  RtUString const fromspace,
770  RtUString const tospace,
771  float time,
772  RtMatrix4x4& m) = 0;
773 
774 protected:
777 };
778 
781 {
782 public:
784  {
785  const char* renderer;
786  const char* version;
787  int versionCode[4];
788  char _reserved[32];
789  };
791  virtual int GetRendererInfo(RendererInfo*) = 0;
792 
793  struct FrameInfo
794  {
795  FrameInfo() : _vers(2) {}
796 
798  {
801  };
802 
803  int frame;
804  int nthreads;
805  float shutter[2]; // when shutter values are equal, no motion-blur
807  struct
808  {
809  int nDisplays; // indexes for GetDspyInfo
810  int resolution[2];
812  } displayState;
813 
814  int _vers;
815 
816  // added in version 2
817  // integrator settings are only non-null in RIS mode
818  RtUString integratorName;
819  RtUString integratorPath;
821 
822  char _reserved[32];
823  };
824 
827  virtual int GetFrameInfo(FrameInfo*) = 0;
828 
829  struct DspyInfo
830  {
831  RtUString name;
832  RtUString type;
833  RtUString mode;
834  char _reserved[32];
835  };
838  virtual int GetDspyInfo(int dspyId, DspyInfo*) = 0;
839 
841  {
847  };
848 
849  struct RayCtxInfo
850  {
851  int integratorIteration; // always 0 when in distribution integration
852  char _reserved[32];
853  };
854 
858  virtual int GetRayCtxInfo(RayCtxInfo*) = 0;
859 
875  virtual int GetOption(
876  RtUString const name,
877  void* result,
878  int resultLength,
879  Type* resultType,
880  int* resultCount) = 0;
881 
882  virtual int GetAttribute(
883  RtUString const name,
884  void* result,
885  int resultLength,
886  Type* resultType,
887  int* resultCount) = 0;
888 
900  virtual int GetRIBFileContext(int* linenumber, char** filename) = 0;
901 
902 
917  virtual int GetRIBArchive(RtUString const filename, const char** archive) = 0;
918 
919 protected:
921 };
922 
923 class [[deprecated]] RixSymbolResolver : public RixInterface
924 {
925 public:
935  virtual void ResolvePredefinedStrings(RiPredefinedStrings &ps) const = 0;
936 
938  {
939  k_PixelFilter = 0,
940  k_Basis = 1,
942  k_ErrorHandler = 3,
943  k_RiEntryPoint = 4
944  };
945  //
958  virtual void* ResolveSymbol(const char* nm, SymbolGroup group) = 0;
959 
960 protected:
962 };
963 
964 
966 {
967 public:
968  virtual void EmitVector(RtVector3 v, RtColorRGB c) = 0;
969  virtual void EmitPoint(RtPoint3 p, RtColorRGB c) = 0;
970  virtual void EmitPointNormal(RtPoint3 p, RtNormal3 n, RtColorRGB c) = 0;
971  virtual void EmitLine(RtPoint3 p1, RtPoint3 p2, RtColorRGB c) = 0;
972  virtual void EmitBound(RtPoint3 pmin, RtPoint3 pmax, RtColorRGB c) = 0;
973  virtual void Clear() = 0;
974  virtual void Flush() = 0;
975 
976 protected:
978 };
979 
980 typedef int RixLPEToken;
981 
984 class RixLPEInfo : public RixInterface
985 {
986 public:
991  virtual int GetLpeIdByName(
992  bool discrete,
993  bool specular,
994  bool reflect,
995  bool user,
996  unsigned char lobeId,
997  char const* name) const = 0;
998 
1002  virtual int GetNumPotentialDiffuseLobes() const = 0;
1003  virtual int GetNumPotentialSpecularLobes() const = 0;
1004  virtual int GetNumPotentialUserLobes() const = 0;
1005 
1006 protected:
1008 };
1009 
1010 // This is a callback routine for use with the
1011 // RixCustomLPE::RegisterScatterCallback() and
1012 // RixCustomLPE::InvokeScatterCallbacks(), described in more detail below.
1013 typedef void (*RixLPECallback)(
1014  void* userData,
1015  RixLPEState* lpeState,
1016  RixShadingContext const* sCtx,
1017  int sCtxIndex,
1018  RtColorRGB const& thruput,
1019  RtColorRGB const* lightTrans,
1020  bool firstContribution);
1021 
1024 {
1025 public:
1026  // Use this method to return an integer identifier that corresponds to
1027  // a given Light Path Expression (LPE).
1028  virtual int LookupLPE(char const* lpeExpr) = 0;
1029 
1030  // Use this method to return an integer identifier that corresponds to
1031  // a given Light Path Expression (LPE) name.
1032  virtual int LookupLPEByName(char const* lpeName) = 0;
1033 
1034  // This method returns true if the 'customLpe' integer identifier
1035  // (which should be obtained by calling LookupLPE()) matches the current
1036  // ray hit, returning true or false along with the cumulative path
1037  // thruput corresponding to the custom LPE. This method should typically
1038  // be called from within a registered "transition" callback routine
1039  // (see RegisterScatterCallback() below).
1040  virtual bool MatchesLPE(
1041  int customLpe,
1042  RixLPEState* lpeState,
1043  RtColorRGB& thruput) = 0;
1044 
1045  // Use this method to register a "scatter" callback. Each scattering
1046  // event along the ray path counts as a "scatter" event (that is, each
1047  // ray-geometry intersection hit point that results in light being
1048  // scattered throughout the scene). Ater registering a scatter callback,
1049  // the callback routine will be invoked at each scattering event. Within
1050  // a scatter callback routine one might make a call to the MatchesLPE()
1051  // method in order to determine whether a particular custom LPE matches
1052  // the current ray path history.
1053  virtual void RegisterScatterCallback(
1054  RixLPECallback callbackFunc,
1055  void* userData = NULL) = 0;
1056 
1057  // Calling this method will invoke all registered scatter callback routines.
1058  // Typically this method is only called internally by the core rendering
1059  // code (and typically end-user code would not need to call this method
1060  // directly). Instead this routine is called indirectly via the RixLPE
1061  // interface whenever there is a scattering event.
1062  virtual void InvokeScatterCallbacks(
1063  RixLPEState* lpeState,
1064  RixShadingContext const* sCtx,
1065  int sCtxIndex,
1066  RtColorRGB const& thruput,
1067  RtColorRGB const* lightTrans,
1068  bool firstContribution) = 0;
1069 
1070 protected:
1072 };
1073 
1083 {
1084 public:
1090  virtual void WriteXml(const char* format, ...) = 0;
1091 
1094  virtual void WriteText(const char* format, ...) = 0;
1095 
1097  virtual ~RixXmlFile() {}
1098 
1099  // Helper functions for writings stats.
1100  void WriteStat(char const* name, char const* desc, int value)
1101  {
1102  WriteXml("<int name=\"%s\"", name);
1103  if (desc)
1104  WriteXml(" description=\"%s\"", desc);
1105  WriteXml("> %i </int>\n", value);
1106  }
1107 
1108  void WriteStat(char const* name, char const* desc, uint64_t value)
1109  {
1110  WriteXml("<int name=\"%s\"", name);
1111  if (desc)
1112  WriteXml(" description=\"%s\"", desc);
1113  WriteXml("> %llu </int>\n", value);
1114  }
1115 
1116  void WriteStat(char const* name, char const* desc, float value)
1117  {
1118  WriteXml("<float name=\"%s\"", name);
1119  if (desc)
1120  WriteXml(" description=\"%s\"", desc);
1121  WriteXml("> %f </float>\n", value);
1122  }
1123 
1124  void WriteStat(char const* name, char const* desc, char const* value)
1125  {
1126  WriteXml("<string name=\"%s\"", name);
1127  if (desc)
1128  WriteXml(" description=\"%s\"", desc);
1129  WriteXml("> %s </string>\n", value);
1130  }
1131 
1132  void WriteTime(char const* name, char const* desc, float time)
1133  {
1134  WriteXml("<timer name=\"%s\"", name);
1135  if (desc)
1136  WriteXml(" description=\"%s\"", desc);
1137  WriteXml("><elapsed>%f</elapsed></timer>\n", time);
1138  }
1139 };
1140 
1157 class RixTimer : public RixInterface
1158 {
1159 public:
1161  virtual uint64_t SampleTime() = 0;
1163  virtual float ConvertIntervalToSeconds(uint64_t interval) = 0;
1164 
1165 protected:
1167 };
1168 
1187 class RixStats : public RixInterface
1188 {
1189 public:
1196  virtual void AddTimerStat(
1197  float* seconds,
1198  const char* name,
1199  const char* description) = 0;
1200 
1209  {
1210  public:
1211  enum Fmt
1212  {
1218  };
1219  virtual ~SimpleStat() {}
1220  virtual void Reset() = 0;
1221  virtual const char* GetName() = 0;
1222  virtual const char* GetDescription() = 0;
1223  virtual void GetResults(uint64_t* result, Fmt* fmt) = 0;
1224  };
1225  virtual int AddSimpleStat(SimpleStat*) = 0;
1226 
1233  virtual void AddMemoryStat(
1234  size_t* bytes,
1235  const char* name,
1236  const char* description) = 0;
1237 
1240  typedef void (*Reporter)(class RixXmlFile* file);
1241  typedef void (*ReporterCtx)(void* ctx, class RixXmlFile*);
1242 
1260  virtual void AddReporter(Reporter func) = 0;
1261  virtual void AddReporterCtx(ReporterCtx func, void* ctx) = 0;
1262 
1268  virtual void AddFileLogStat(const char* fileName, const char* path) = 0;
1269 
1270 protected:
1273 };
1274 
1275 
1276 class [[deprecated]] RixResourceResolver : public RixInterface
1277 {
1278 public:
1280  {
1281  k_Shader = 0,
1287  k_RixPlugin
1288  };
1289 
1292  virtual char const* GetResourcePaths(ResourceType) = 0;
1293 
1305  virtual int ResolveResource(
1306  ResourceType,
1307  char const* nm,
1308  char result[],
1309  int maxlen) = 0;
1310 
1311 protected:
1313 };
1314 
1316 [[deprecated]] typedef void (*RixCleanupFunc)(RixContext* context, void* data);
1317 
1383 class [[deprecated]] RixStorage : public RixInterface
1384 {
1385 public:
1387  virtual void* Get(const RtUString key) = 0;
1388 
1392  virtual void Set(
1393  const RtUString key,
1394  void* data,
1395  RixCleanupFunc cleanup = NULL) = 0;
1396 
1399  virtual void Clear(const RtUString key) = 0;
1400 
1402  virtual void Lock() = 0;
1403 
1405  virtual void Unlock() = 0;
1406 
1407 protected:
1410 };
1411 
1412 
1423 template<typename _Signature>
1425 
1427 template <typename _Res, typename... _ArgTypes>
1428 class [[deprecated]] RixFunction<_Res(_ArgTypes...)>
1429 {
1430  // Internal type erasure prototype
1431  struct FunctionPrototype
1432  {
1433  virtual ~FunctionPrototype() {}
1434  virtual _Res operator()(_ArgTypes... __args) const = 0;
1435  };
1436 
1437  // Internal type erasure template implementation
1438  template< typename Closure >
1439  struct Function : FunctionPrototype
1440  {
1441  Function(Closure&& t ) : fn(t) {}
1442  virtual ~Function() {}
1443  virtual _Res operator()(_ArgTypes... __args) const
1444  { return fn(__args...); }
1445  Closure fn;
1446  };
1447 
1448  FunctionPrototype* object;
1449 
1450 public:
1451  // Template constructor for Lambda capture.
1452  template< typename Closure >
1453  RixFunction(Closure&& obj )
1454  : object( new Function<Closure>( std::move(obj) ) )
1455  {}
1456 
1457  ~RixFunction()
1458  { delete object; }
1459 
1460  _Res operator()(_ArgTypes... __args) const
1461  {
1462  return (*object)(__args...);
1463  }
1464 };
1466 
1481 class [[deprecated]] RixMutex
1482 {
1483 public:
1485  virtual ~RixMutex() {}
1486 
1488  virtual void Lock() = 0;
1489 
1491  virtual void Unlock() = 0;
1492 };
1493 
1503 class [[deprecated]] RixThreadUtils : public RixInterface
1504 {
1505 public:
1507  virtual RixMutex* NewMutex() const = 0;
1508 
1510  virtual void DeleteMutex(RixMutex *mutex) const = 0;
1511 
1535  virtual void ParallelFor(size_t start, size_t end,
1536  const RixFunction<void(size_t)>& fn) const = 0;
1537  virtual void ParallelFor(size_t start, size_t end, size_t step,
1538  const RixFunction<void(size_t)>& fn) const = 0;
1539 
1540 protected:
1543 };
1544 
1550 {
1551 public:
1553  virtual bool ColorManagementEnabled() = 0;
1554  // Return 0 for ITU BT.709, 1 for CAEScg and -1 if the config wasn't initialized
1555  virtual int BaseColorSpace() = 0;
1556  // Convert a balckbody color to the current colorspace
1557  virtual RtColorRGB BlackbodyToColorSpace(RtColorRGB &in) = 0;
1558  // Make the color's luminance 1.0
1559  virtual void NormalizeColor(RtColorRGB &inout) = 0;
1561  virtual RtColorRGB LumaCoefs() = 0;
1562  // Return a processor id for an OCIO processor converting from inputRole to "rendering"
1563  virtual int GetProcessor(std::string inputRole) = 0;
1564  // Convert a color using the OCIO processor corresponding to the processor id
1565  virtual void ProcessColor(int processorId, RtColorRGB &inout) = 0;
1566 
1567 protected:
1570 };
1571 
1572 
1573 #endif // RIX_INTERFACE_H