Todd R Pravata (tpravata++at++m2.rts.dseg.ti.com)
Tue, 2 Jul 96 01:52:07 CDT
I'm need to read a large portion of the framebuffer at 30 Hz to feed
data from a Performer rendered scene to a tracker running in real-time.
The basic question:
What is the fastest way to read from the framebuffer given the
requirements of my application:
12 bits per pixel,
single component pixel (intensity only),
a large image (630K pixels),
and must be IRIS GL?
Can someone please explain the "findings" below?
Can someone please explain "PM_LUMINANCE" mode?
Findings:
I have modified perfly (see code snippets below) so that I can toggle
through the combinations of pixmode INPUT and OUTPUT FORMAT and TYPE
(in order to find the combination that works) and so that I am drawing
12 bit pixels. Here is what I have found:
OUTPUT_FORMAT OUTPUT_TYPE INPUT_FORMAT INPUT_TYPE RATE
--------------------------------------------------------------------------------
BGR UNSIGNED_BYTE DC DC 30
BGR UNSIGNED_SHORT DC DC 15
BGR UNSIGNED_SHORT_12 DC DC 20
RGB UNSIGNED_BYTE DC DC 12
RGB UNSIGNED_SHORT DC DC 12
RGB UNSIGNED_SHORT_12 DC DC 20
LUMINANCE DC LUMINANCE DC 30
LUMINANCE DC BGR DC 15
LUMINANCE DC RGB DC 15
Note: I am not interested in any of the formats with alpha components.
Note: This test was conducted on an RE2.
Note: DC = don't care
The good news is that I can read 12 bit pixels using PM_LUMINANCE at
30 Hz. However, I don't really understand what PM_LUMINANCE does in
GL. I read the OpenGL man page for the corresponding mode
(glreadpixels GL_LUMINANCE) and and it says that the value will be the
sum of the RED, GREEN and BLUE components. Is this what PM_LUMINANCE
does? Or, does it take the value specified by readcomponent (the
readcomponent man page does not mention PM_LUMINANCE)?
>From the pixmode man page:
PM_INPUT_FORMAT, PM_OUTPUT_FORMAT, default values: PM_ABGR. If in
RGBmode, specifies the pixel color component format; if in cmode,
has no effect. The format specifies the number and order of color
components. May be one of: PM_ABGR, PM_BGR, PM_RGBA, PM_RGB,
PM_LUMINANCE, PM_LUMINANCEA, PM_ALPHA. If PM_LUMINANCE or
PM_LUMINANCEA is selected as the PM_OUTPUT_FORMAT, all of the
other features of pixmode will be ignored except for
PM_INPUT_TYPE, PM_OUTPUT_TYPE, PM_OFFSET, and PM_STRIDE.
The observations conflict with the statement in the man page. It seems
that the INPUT_FORMAT is not being ignored when the OUTPUT_FORMAT is
PM_LUMINANCE since setting it does have an effect on the speed of the
lrectread.
Note: I modified InitPipe to set my pixel size to 12 bits:
static int FBAttrs[] = {
PFFB_DOUBLEBUFFER,
PFFB_DEPTH_SIZE, 24,
PFFB_RED_SIZE, 12,
PFFB_SAMPLES, 8,
PFFB_STENCIL_SIZE, 1,
None,
};
pfPWinFBConfigAttrs(pw, FBAttrs);
pfConfigPWin(pw);
Here is the function that reads from the framebuffer:
readScreen()
{
int xorg, yorg, xsize, ysize;
unsigned long *scrbuf = NULL;
xorg = 0;
yorg = 0;
xsize = XSIZE;
ysize = YSIZE;
/* read from FRONT-buffer to get channel stats info */
readsource(SRC_AUTO);
scrbuf = ViewState->scrbuf1;
pixmode(PM_TTOB, ViewState->pm_ttob);
pixmode(PM_RTOL, ViewState->pm_rtol);
/*
PM_INPUT_FORMAT, PM_OUTPUT_FORMAT, default values: PM_ABGR. If in
RGBmode, specifies the pixel color component format; if in cmode,
has no effect. The format specifies the number and order of color
components. May be one of: PM_ABGR, PM_BGR, PM_RGBA, PM_RGB,
PM_LUMINANCE, PM_LUMINANCEA, PM_ALPHA. If PM_LUMINANCE or
PM_LUMINANCEA is selected as the PM_OUTPUT_FORMAT, all of the
other features of pixmode will be ignored except for
PM_INPUT_TYPE, PM_OUTPUT_TYPE, PM_OFFSET, and PM_STRIDE.
*/
pixmode(PM_INPUT_FORMAT, ViewState->pm_input_format);
pixmode(PM_OUTPUT_FORMAT, ViewState->pm_output_format);
/*
PM_INPUT_TYPE, default values: PM_UNSIGNED_BYTE. Specifies the
type of pixel color components. May be one of: PM_BITMAP,
PM_BYTE, PM_UNSIGNED_BYTE, PM_SHORT_12, PM_UNSIGNED_SHORT_12,
PM_SHORT, PM_UNSIGNED_SHORT, PM_INT, PM_UNSIGNED_INT, PM_FLOAT.
*/
pixmode(PM_INPUT_TYPE, ViewState->pm_input_type);
/*
PM_OUTPUT_TYPE, default values: PM_UNSIGNED_BYTE. Specifies the
type of pixel color components. May be one of: PM_BITMAP,
PM_UNSIGNED_BYTE, PM_UNSIGNED_SHORT_12, PM_UNSIGNED_SHORT,
PM_UNSIGNED_INT, PM_FLOAT.
*/
pixmode(PM_OUTPUT_TYPE, ViewState->pm_output_type);
/*
PM_SIZE, default value: 32. Number of bits per pixel. Used for
packing during reads and writes. Valid values: 1, 4, 8, 12, 16,
24, 32, 64 (see NOTES below)
*/
pixmode(PM_SIZE, ViewState->pm_size);
/*
RC_ABGR Indicates that all 4 frame buffer components, ABGR should
be transferred. This is the default.
RC_ALPHA selects the alpha channel of the current framebuffer
selected by readsource.
RC_BLUE selects the blue channel of the current framebuffer
selected by readsource.
RC_GREEN selects the green channel of the current framebuffer
selected by readsource.
RC_RED selects the red channel of the current framebuffer selected
by readsource.
*/
readcomponent(ViewState->read_component);
/* read the display */
lrectread((short)xorg, (short)yorg, (short)(xorg+xsize-1), (short)(yorg+ysize-1), scrbuf);
}
Here are my initial values (note that I only change input_format, output_format,
input_type and output_type):
ViewState->pm_rtol = 0;
ViewState->pm_ttob = 0;
ViewState->pm_size = 32;
ViewState->read_component = RC_ABGR;
ViewState->pm_output_format = PM_BGR;
ViewState->pm_input_format = PM_BGR;
ViewState->pm_output_type = PM_UNSIGNED_BYTE;
ViewState->pm_input_type = PM_UNSIGNED_BYTE;
-- Todd Pravata todd.pravata++at++ti.com 214-575-6126 Visual Simulation Lab, Texas Instruments"The significant problems that we face cannot be solved at the same level of thinking we were at when we created them." -- Albert Einstein
** Views expressed are not necessarily those of Texas Instruments ** ======================================================================= List Archives, FAQ, FTP: http://www.sgi.com/Technology/Performer/ <--new! Submissions: info-performer++at++sgi.com Admin. requests: info-performer-request++at++sgi.com
This archive was generated by hypermail 2.0b2 on Mon Aug 10 1998 - 17:53:07 PDT