pfComputeFunc(3pf) OpenGL Performer 3.2.2 libpf C++ Reference Pages
NAME
pfComputeFunc, pfGetComputeFunc, pfAllocComputeData, pfGetComputeData,
pfPassComputeData, pfCompute - Set callback for compute process, allocate
and pass compute data.
FUNCTION SPECIFICATION
#include <Performer/pf.h>
void pfComputeFunc(pfComputeFuncType func);
pfComputeFuncType pfGetComputeFunc(void);
void * pfAllocComputeData(int bytes);
void * pfGetComputeData(void);
void pfPassComputeData(void);
void pfCompute(void);
typedef void (*pfComputeFuncType)(void *userData);
DESCRIPTION
The func argument to pfComputeFunc specifies the compute callback
function. This function will be invoked by pfFrame and will be passed a
pointer to a data buffer allocated by pfAllocComputeData. If a separate
process is allocated for asynchronous computation by the
PFMP_FORK_COMPUTE mode to pfMultiprocess, then pfFrame will cause func to
be called in the separate (COMPUTE) process. pfGetComputeFunc returns
the compute callback or NULL if none is set.
The compute function's primary purpose is to provide a place for per-
frame asynchronous computation. The results of such computation may be
placed in pfFlux objects for use in the scene graph or by the
asynchronous rendering pipeline; see the man page for new pfFlux). The
compute process is automatically used by some OpenGL Performer objects,
such as pfASD, that require extensive computation that can be done
asynchronously and potentially extend beyond the time for a frame. see
new pfASD).
When the compute function is in a separate process, it will run
asynchronously with the rest of the rendering pipeline. Specifically, if
the compute function takes more than a frame time, the rendering pipeline
will not be affected.
Unlike the intersection and cull processes, there is no copy of the scene
graph in the compute process. Only pfFlux objects can be safely
inspected or edited by the compute process. It is not valid to look at
any pfNode in the compute process unless specific care for multibuffering
Page 1
pfComputeFunc(3pf) OpenGL Performer 3.2.2 libpf C++ Reference Pages
has been done: creating of a pfBuffer and calling pfBufferScope to move
the node to the compute process. See the man pages for pfDBaseFunc and
new pfBuffer for more information. Additionally, unlike the database
process, there is no automatic method for merging computed results back
into the application process. However, if the results are stored in a
pfFlux, this should not be necessary.
If a compute function has been specified by pfComputeFunc, it must call
pfCompute to carry out default OpenGL Performer compute processing.
pfCompute should only be called from within the COMPUTE callback in the
COMPUTE process just like pfCull and pfDraw should only be called in the
pfChannel CULL and DRAW callbacks (pfChannel::setTravFunc) respectively.
If a compute function has not been specified or is NULL, OpenGL Performer
automatically calls pfCompute from pfFrame.
pfAllocComputeData returns a pointer to a chunk of shared memory of bytes
bytes. This memory buffer may be used to communicate information between
the compute function and application. Compute data should only be
allocated once. pfGetComputeData returns the previously allocated
compute data.
When the compute function is forked, pfPassComputeData should be used to
copy the compute data into internal OpenGL Performer memory when the next
pfFrame is called. Once pfFrame is called, the application may modify
data in the compute data buffer without fear of colliding with the forked
compute function. However, modifications to the compute data chunk made
by the COMPUTE process will not be visible to the APP process, i.e, there
is no "upstream" propagation of passthrough data. For managing sending
upstream or asynchronous processes to receive the results of the compute
process, you can use pfFlux objects.
SEE ALSO
pfConfig, pfFrame, pfMultiprocess, new, pfFlux, new, pfFBuffer
Page 2