RslContext_v1 Class Reference

RslContext_v1 Class Referenceabstract

#include <RslPlugin.h>

Inheritance diagram for RslContext_v1:
RslContext_v2 RslContext

Public Member Functions

virtual ~RslContext_v1 ()
 Virtual destructor.
 
virtual const RslRunFlagGetRunFlags (unsigned int *length) const =0
 
virtual RixInterface * GetRixInterface (RixInterfaceId id) const =0
 
RixStorage * GetGlobalStorage () const
 
RixStorage * GetThreadStorage () const
 
RixStorage * GetLocalStorage () const
 
void SetThreadData (void *data, RixCleanupFunc cleanup=0L)
 
void * GetThreadData () const
 Get per-thread user data.
 
void SetLocalData (void *data, RixCleanupFunc cleanup=0L)
 
void * GetLocalData () const
 Get local user data.
 
virtual const char * GetPluginName () const =0
 Get the name of this plugin.
 

Friends

template<typename T >
class RslIter
 
template<typename T >
class RslArrayIter
 

Detailed Description

The RslContext provides access to various capabilities required by shader plugins. The context provides thread-safe global storage (via GetGlobalStorage()), per-thread storage (via GetThreadStorage()), and local "per-grid" storage (via GetLocalStorage()). It also provides a general-purpose way to obtain RenderMan interface extensions (RixInterface), which provide additional utilities, including error/warning messages with duplicate suppression (RixMessages), statistics (RixStats), and threading utilitis (RixThreadUtils).

Member Function Documentation

RixStorage* RslContext_v1::GetGlobalStorage ( ) const
inline

Get thread-safe global variable storage (RixStorage), which is used as follows:

RixStorage* storage = rslContext->GetGlobalStorage();
storage->Lock();
void* myglobal = storage->Get("myglobal");
if (myglobal == NULL) {
myglobal = MakeData();
storage->Set("myglobal", myglobal, CleanupData);
}
storage->Unlock();

This code operates as follows:

  • Get the globals from the RslContext.
  • Lock the globals for thread safety.
  • Look up the key to see if the data already exists.
  • If not, allocate the data and store it in the globals. (The optional cleanup function is called at end of frame.)
  • Unlock the globals.
RixStorage* RslContext_v1::GetLocalStorage ( ) const
inline

Get local data storage (RixStorage), which is cleared when the current shader set finishes running on the current set of points.

virtual RixInterface* RslContext_v1::GetRixInterface ( RixInterfaceId  id) const
pure virtual

Shader plugins have access to RixInterfaces that provide various kinds of storage management (per-frame, per-thread, and per-grid), statistics reporting, error messages, etc.

virtual const RslRunFlag* RslContext_v1::GetRunFlags ( unsigned int *  length) const
pure virtual

Returns an array of runflags. A value of 1 indicates the grid point is active, a value of 0 means the grid point is not active.

RixStorage* RslContext_v1::GetThreadStorage ( ) const
inline

Get per-thread storage (RixStorage), which is used as follows:

RixStorage* storage = rslContext->GetThreadStorage();
void* mydata = storage->Get("mydata");
if (mydata == NULL) {
mydata = MakeData();
storage->Set("mydata", mydata, CleanupData);
}

This code operates as follows:

  • Get the per-thread storage from the RslContext.
  • Look up the key to see if the data already exists.
  • If not, allocate the data and store it in the globals. (The optional cleanup function is called at end of frame.)
void RslContext_v1::SetLocalData ( void *  data,
RixCleanupFunc  cleanup = 0L 
)
inline

Set local user data and optional cleanup function. The cleanup function is called on the user data when the current shader set finishes running on the current set of points. For greater flexibility, use GetLocalStorage().

void RslContext_v1::SetThreadData ( void *  data,
RixCleanupFunc  cleanup = 0L 
)
inline

Set per-thread user data and optional cleanup function. The cleanup function is called on the user data when the thread is terminated. For greater flexibility, use GetThreadStorage().


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