RenderMan API  23.0
RtxPlugin.h
Go to the documentation of this file.
1 /*
2 # ------------------------------------------------------------------------------
3 #
4 # Copyright (c) 1986-2019 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 
38 #ifndef RTXPLUGIN_H
39 #define RTXPLUGIN_H
40 
41 #include "prmanapi.h" // for PRMANEXPORT
42 #include "ri.h" // for RtPointer
43 
44 class RixContext; // IWYU pragma: keep
45 
46 // An RtxPlugin class
47 class RtxPlugin
48 {
49 public:
50  RtxPlugin() {}
51  virtual ~RtxPlugin() {}
52 
54  struct Int2D
55  {
56  int X;
57  int Y;
58  };
59 
61  struct Tile2D
62  {
65  };
66 
77  struct TextureCtx
78  {
81 
83  unsigned int numLayers;
84 
90  struct layerSpec
91  {
92  const char* name;
93  unsigned numChannels;
94  } * *layers;
95 
97  Int2D minRes, maxRes;
98 
100  enum WrapMode
101  {
102  k_Black = 0,
104  k_Periodic
105  } sWrap,
106  tWrap;
107 
109  enum DataType
110  {
111  k_Byte = 0,
112  k_Float
113  } dataType;
114 
117  {
118  k_Single = 0,
120  k_RIP
121  } pyramidType;
122 
124  bool isLocked;
125 
128  unsigned int argc;
129  const char** argv;
130 
133  void* userData;
134 
135  // Version 2 API starts here
136 
137  // A plugin can request retry on error
138  // a fill may be aborted mid fill request
139  // during rerendering (resulting in incorrect fill data)
140  // Authors may request such errors during fill are retried
141  // during subsequent attempts to fill.
143  };
144 
147  virtual int Open(TextureCtx& tCtx) = 0;
148 
153  struct FillRequest
154  {
155  // This is the resolution of the image at a given MIP level
157 
158  // This is the tile index and tile size
160 
161  // This is a channel selection string. This string can be
162  // NULL if channel selection is not made by string.
163  const char* channelRefExpr;
164 
165  // This is the offset from zero for a given channel selection
166  // It is always zero if channelRefExpr is not NULL.
168 
169  // This is the number of channels we want to fill
171 
172  // The data (interleaved) with GetStride() channels
173  // that the plugin should write the tile results into
175  };
176 
177  // The plugin should use the fillReq inputs to write to the
178  // tileData in the FillRequest. Return nonzero on errors.
179  virtual int Fill(TextureCtx& tCtx, FillRequest& fillReq) = 0;
180 
181  // The plugin should release all assets at Close()
182  virtual int Close(TextureCtx& tCtx) = 0;
183 };
184 
185 // A RixContext is provided to an RtxPlugin at
186 // creation time, so that the plugin may use
187 // services provided by the renderer.
188 #define RTXPLUGINCREATE \
189  extern "C" const PRMANEXPORT int RtxPluginVersion = 2; \
190  extern "C" PRMANEXPORT RtxPlugin* RtxPluginNew( \
191  RixContext* rixCtx, const char* pluginName)
192 #endif
void * RtPointer
Definition: ri.h:69
virtual int Open(TextureCtx &tCtx)=0
WrapMode
The wrap mode applied at the edges of max resolution.
Definition: RtxPlugin.h:100
virtual int Close(TextureCtx &tCtx)=0
PyramidType
What type of pyramid should be used?
Definition: RtxPlugin.h:116
bool isLocked
Should the tile be locked while filling? (not thread safe?)
Definition: RtxPlugin.h:124
A struct to define an X,Y coordinate.
Definition: RtxPlugin.h:54
A struct to define a 2D region.
Definition: RtxPlugin.h:61
int numChannels
This is the total number of channels present.
Definition: RtxPlugin.h:80
const char ** argv
Definition: RtxPlugin.h:129
DataType
The type of the data provided by the texture.
Definition: RtxPlugin.h:109
const char * channelRefExpr
Definition: RtxPlugin.h:163
virtual int Fill(TextureCtx &tCtx, FillRequest &fillReq)=0
RtxPlugin()
Definition: RtxPlugin.h:50
unsigned int numLayers
The maximum # of layers this texture can access.
Definition: RtxPlugin.h:83
unsigned int argc
Definition: RtxPlugin.h:128
Int2D minRes
The min,max resolution requested for this texture.
Definition: RtxPlugin.h:97
virtual ~RtxPlugin()
Definition: RtxPlugin.h:51