mental ray uses the notion of a stream for all realtime image display methods. For each method, there is a begin function that creates the stream, and the is a single end function that destroys a stream. Streams are identified by an identifier of type miStream. While a stream is open, it propagates frame begin/end and tile begin/end information, in a format that depends on the stream method.
Note that mental ray runs the DISP module in a separate thread. This means that display callbacks are not called in the thread that set up the callback stream. Also, there may be a small delay before a terminated stream stops sending rectangles; this needs careful attention if streams are created and terminated in the middle of rendering.
miStream mi_disp_stream_pipe_begin(
int fd)
Create a pipe stream that sends messages of type 5 when a frame begins, 4 when a frame ends, and 2 for every finished rectangle, as described in this table. Messages are written to the file descriptor fd. The returned miStream code identifies the stream and must be used for terminating the stream using mi_disp_stream_end. The stream will remain open until it is explicitly terminated.
miStream mi_disp_stream_socket_begin(
int fd)
Create a socket stream that sends messages of type 6 when a frame begins, 4 when a frame ends, and 2 for every finished rectangle, as described in this table. Except for the type of the frame begin message, the stream is similar to a pipe stream.
typedef void (*miDisp_cb)(
void *arg,
miRc_mapfb *fbmap,
int xl,
int yl,
int xh,
int yh);
miStream mi_disp_stream_cb_begin(
void *arg,
miDisp_cb rcb)
Create a callback stream. The callback will be called in four situations:
The distinction between rectangle begin and end is available only for callback streams (although later versions may make it available for sockets and pipes as well). It allows previewers to announce that a rectangle has started rendering using little cross-hair markers or similar, to give the user better feedback. For all calls, the arg argument is an opaque pointer that always has the value given to mi_disp_stream_cb_begin; it can be used to pass a this pointer to a C++ method.
The fbmap is an opaque miRc_mapfb pointer. It is either zero (see above) or points to a structure in memory. A frame buffer image can be accessed using the mi_disp_fbmap and mi_disp_fbunmap functions (address by index, like one of the miRC_IMAGE_* indices for standard frame buffers). 3.6New integrations may use the mi_disp_fbmap_name and mi_disp_fbunmap_name functions with named frame buffers.
typedef void (*miDisp_jpeg_cb)(
void *arg,
void *data,
int size);
miStream mi_disp_stream_jpeg_cb_begin(
void *arg,
miDisp_jpeg_cb jcb,
int q)
Create a JPEG callback stream. The callback will be called in two situations: when the frame ends (data and size are 0), and when enough rectangles have been rendered and compressed to send more JPEG data ( data points to a buffer containing size bytes). Due to the nature of JPEG compression, there is no direct association between pixel rectangles and buffers. If all data passed by the callback is written to a file in sequence, a complete JFIF image results. The arg pointer is again an opaque user-defined pointer.
As a side effect, mi_disp_stream_jpeg_cb_begin sets the tile order to top-down to optimize streaming. It can be restored to another order with mi_rc_set_taskorder.
miStream mi_disp_stream_end(
miStream vstr)
Terminate a stream. vstr is the stream identifier returned by the function that created the stream. No more data will be sent down this stream. However, since the DISP module runs in a separate thread, there may be calls still scheduled or in progress.
Copyright © 1986, 2015 NVIDIA ARC GmbH. All rights reserved.