RenderManAPI  24.0
RixPattern Class Referenceabstract

The RixPattern interface characterizes pattern generation for the purposes of RixBxdf parameterization. More...

#include <RixPattern.h>

Inherits RixShadingPlugin.

Classes

struct  Bake2dSpec
 Output specification for 2d baking. More...
 
struct  Bake3dSpec
 Output specification for 3d baking. More...
 
struct  OutputSpec
 

Public Types

enum  SynchronizeHints { k_None = 0x00000000, k_All = 0xFFFFFFFF }
 The renderer offers the ability to shading plugins to track custom data with every instance of the plugin reference. More...
 

Public Member Functions

int GetInterface () const override
 
virtual int ComputeOutputParams (RixShadingContext const *sCtx, int *numOutputs, OutputSpec **outputs, void *instanceData, RixSCParamInfo const *instanceTable)=0
 Patterns are expected to allocate space for OutputSpec array and buffers for all output values via RixShadingContext::Allocate. More...
 
virtual bool Bake2dOutput (RixBakeContext const *bCtx, Bake2dSpec &output, void *instanceData)=0
 This method is called when baking for every pattern parameter. More...
 
virtual bool Bake3dOutput (RixBakeContext const *bCtx, Bake3dSpec &output, void *instanceData)=0
 This method is called when baking for every pattern parameter. More...
 
virtual int GetVersion () const
 
virtual int Init (RixContext &ctx, RtUString const pluginPath)=0
 In order to initialize the plugin, the renderer will call Init() once. More...
 
virtual void Finalize (RixContext &ctx)=0
 Finalize() is the companion to Init(), called at the end of rendering with the expectation that any data allocated within the Init() implementation will be released. More...
 
virtual RixSCParamInfo const * GetParamTable ()=0
 All shading plugins are expected to return a description of their input and output parameters via the GetParamTable() method. More...
 
virtual void Synchronize (RixContext &ctx, RixSCSyncMsg syncMsg, RixParameterList const *syncParams)=0
 This method is used to deliver occasional status information from the renderer. More...
 
virtual void CreateInstanceData (RixContext &rixCtx, RtUString const handle, RixParameterList const *parameterList, InstanceData *instanceData)
 CreateInstanceData() is called once per plugin-instance. More...
 
virtual void SynchronizeInstanceData (RixContext &rixCtx, RtUString const handle, RixParameterList const *instanceParams, uint32_t const editHints, InstanceData *instanceData)
 SynchronizeInstanceData() will only be called if InstanceData::synchronizeHints was set to a non-zero value during the initial call to CreateInstanceData(). More...
 

Protected Member Functions

 RixPattern ()
 
virtual ~RixPattern ()
 

Protected Attributes

int m_version
 

Detailed Description

The RixPattern interface characterizes pattern generation for the purposes of RixBxdf parameterization.

Non-constant patterns can themselves be parameterized by some aspect of the RixShadingContext. Typically, RixPatterns operate atop a filter width associated with the shading context. Internally RixPatterns, in order to respond to the ComputeOuputParams request, must request the RixShadingContext to evaulate input parameters associated with the named outputs.

Member Enumeration Documentation

◆ SynchronizeHints

The renderer offers the ability to shading plugins to track custom data with every instance of the plugin reference.

This is useful primarily to plugin types like Bxdf and Pattern that expect to see multiple instances. Instance data is usually a function of the instance parameters, and plugins that operate in performance sensitive conditions may "bake" an understanding of their behavior/requirements into custom representation for tracking with the instance. The instance data can be recovered from the operating context associated with the plugin type, or via inspection of the parameter list (using RixParameterList::EvalParam). Note that in the latter case, the ability to inspect the parameter list is restricted: "network" connections (i.e. upstream pattern graph inputs) cannot be evaluated at the time CreateInstanceData is invoked.

Note that CreateInstanceData() is only called once, when the plugin instance is created. As a consequence, edits happening during an interactive session can't be captured by this method. The InstanceData::synchronizeHints member allows a plugin to subscribe to a synchronization call, following some edits. In order for SynchronizeInstanceData() to be called, this member needs to be set to a non-zero value by CreateInstanceData().

Note that some quantities are not accessible anymore through the RixContext object in CreateInstanceData(), for reasons related to interactive rendering. In particular:

  • LPE-related quantities
  • Display-related quantities (e.g. resolution)
  • editable options should only be queried in SynchronizeInstanceData().

Additionally, a plugin can create its parameter table dynamically based on the parameters provided to each instance of the plugin. This dynamically created table should be saved in the paramtable member of InstanceData, and should be freed by the InstanceData freefunc. Generally, concrete interfaces should be preferred over dynamic interfaces due to their extra memory expense. If the paramtable member remains null, all instances will share the parameter table returned by GetParamTable. In order to prevent the renderer from filtering out dynamic parameters as bad inputs, a plugin that is using a dynamically created table should have a k_RixSCAnyType entry in its plugin parameter table.

A trivial implementation of the following methods doesn't modify the InstanceData objects provided. Plugins should consider the number of potential instances that may be produced in a worst-case render to assess the memory impact of the instance data. The renderer will free data via freefunc when it understands that the plugin instance will no longer be needed. The handle parameter the value associated with the Ri instance but may not be guaranteed to be globally unique. The instanceid parameter is optionally delivered via the parameterlist (see RI_INSTANCEID docs) and is expected (though not guaranteed) to be unique. This call might be called in multiple threads and should be re-entrant and thread-safe.

Enumerator
k_None 
k_All 

Constructor & Destructor Documentation

◆ RixPattern()

RixPattern::RixPattern ( )
inlineprotected

◆ ~RixPattern()

virtual RixPattern::~RixPattern ( )
inlineprotectedvirtual

Member Function Documentation

◆ Bake2dOutput()

virtual bool RixPattern::Bake2dOutput ( RixBakeContext const *  bCtx,
Bake2dSpec output,
void *  instanceData 
)
pure virtual

This method is called when baking for every pattern parameter.

Valid outputs must specify Bake2dOutput::filename, Bake2dOutput::display and Bake2dOutput::primVar. Space for Bake2dOutput member strings can be allocated via RixBakeContext::Allocate. Initially, Bake2dOutput is called for the (0, 0) UV-tile. If Bake2dOutput::atlas is set to true, additional call to this method will be made for each uv-tile. Returns true for valid bake 2d outputs. A trivial implementation simply returns false, signifying no valid outputs. Note: this method is called before SynchronizeInstanceData(), meaning the plugins needs to initialize the appropriate parts of its instance data in CreateInstanceData().

◆ Bake3dOutput()

virtual bool RixPattern::Bake3dOutput ( RixBakeContext const *  bCtx,
Bake3dSpec output,
void *  instanceData 
)
pure virtual

This method is called when baking for every pattern parameter.

Valid outputs must specify Bake3dOutput::filename and Bake3dOutput::display. Space for Bake3dOutput member strings can be allocated via RixBakeContext::Allocate. Returns true for valid bake 3d outputs. A trivial implementation simply returns false, signifying no valid outputs. Note: this method is called before SynchronizeInstanceData(), meaning the plugins needs to initialize the appropriate parts of its instance data in CreateInstanceData().

◆ ComputeOutputParams()

virtual int RixPattern::ComputeOutputParams ( RixShadingContext const *  sCtx,
int *  numOutputs,
OutputSpec **  outputs,
void *  instanceData,
RixSCParamInfo const *  instanceTable 
)
pure virtual

Patterns are expected to allocate space for OutputSpec array and buffers for all output values via RixShadingContext::Allocate.

The optional instanceTable returned by plugin's CreateInstanceData is managed by the renderer and delivered with the associated instance. Plugins that don't support the optional override capability can ignore the instanceTable parameter. returns 0 for success, non-zero for error

◆ CreateInstanceData()

virtual void RixShadingPlugin::CreateInstanceData ( RixContext rixCtx,
RtUString const  handle,
RixParameterList const *  parameterList,
InstanceData instanceData 
)
inlinevirtualinherited

CreateInstanceData() is called once per plugin-instance.

It may be called before other renderer options and/or plugins have been set-up. As a consequence, some quantities may not be accessible in CreateInstanceData(). For example:

  • LPE-related quantities
  • Display-related quantities (e.g. resolution)
  • editable options SynchronizeInstanceData() should be used to retrieve the up-to-date related quantities.

Reimplemented in RixIntegratorFactory, and RixProjectionFactory.

References PIXAR_ARGUSED.

◆ Finalize()

virtual void RixShadingPlugin::Finalize ( RixContext ctx)
pure virtualinherited

Finalize() is the companion to Init(), called at the end of rendering with the expectation that any data allocated within the Init() implementation will be released.

◆ GetInterface()

int RixPattern::GetInterface ( ) const
inlineoverridevirtual

Reimplemented from RixShadingPlugin.

References k_RixPattern.

◆ GetParamTable()

virtual RixSCParamInfo const* RixShadingPlugin::GetParamTable ( )
pure virtualinherited

All shading plugins are expected to return a description of their input and output parameters via the GetParamTable() method.

This returns a pointer to an array of RixSCParamInfo, containing one entry for each input and output parameter, as well as an extra empty entry to mark the end of the table. This parameter table is used by the renderer to ensure proper type checking and validate the connections of upstream and downstream nodes. As such, each entry in the table should set a name, a type (RixSCType enumeration), detail (varying vs uniform, RixSCDetail enumeration), and access (input vs output, RixSCAccess enumeration). These declarations also need to be kept in sync with the associated .args file.

◆ GetVersion()

virtual int RixShadingPlugin::GetVersion ( ) const
inlinevirtualinherited

◆ Init()

virtual int RixShadingPlugin::Init ( RixContext ctx,
RtUString const  pluginPath 
)
pure virtualinherited

In order to initialize the plugin, the renderer will call Init() once.

Even if the plugin is evoked multiple times during the render with different arguments, Init() will still be called only once during the lifetime of the render. The RixContext parameter can be used by the plugin to request any RixInterfaces services provided by the renderer. Any expensive memory allocations or operations that can be reused during the lifetime of the plugin can be performed in this routine. Upon successful initialization, this routine should return a zero status.

◆ Synchronize()

virtual void RixShadingPlugin::Synchronize ( RixContext ctx,
RixSCSyncMsg  syncMsg,
RixParameterList const *  syncParams 
)
pure virtualinherited

This method is used to deliver occasional status information from the renderer.

Parameterlist contents depend upon the SyncMsg. A trivial implementation simply does nothing, ignoring all events.

◆ SynchronizeInstanceData()

virtual void RixShadingPlugin::SynchronizeInstanceData ( RixContext rixCtx,
RtUString const  handle,
RixParameterList const *  instanceParams,
uint32_t const  editHints,
InstanceData instanceData 
)
inlinevirtualinherited

SynchronizeInstanceData() will only be called if InstanceData::synchronizeHints was set to a non-zero value during the initial call to CreateInstanceData().

This method is allowed to modify:

  • data (including freeing the previous pointer and allocating new memory)
  • datalen
  • freefunc
  • synchronizeHints

However, it is not currently possible to modify:

  • paramtable

Note that special care should be taken when modifying synchronizeHints, so that the plugin instance doesn't lock itself out of synchronization notifications.

Reimplemented in RixIntegratorFactory, and RixProjectionFactory.

References PIXAR_ARGUSED.

Member Data Documentation

◆ m_version

int RixShadingPlugin::m_version
protectedinherited

The documentation for this class was generated from the following file: