Page 1 of 2

texturemapping using intel GPP raster

PostPosted: May 6, 2003 @ 8:23am
by vic
hello, ive just started to implemente texturemapping in a renderer im building for pocketpc using intel's GPP library..
my problem is i havent been able to get UV coordinates to work correctly.
for testing purposes i was working on a simple sprite/image drawing routine, which would use intel's lib to draw a background on a 240x320 display (pocketpc normal).
i have been getting weird results.. also help from intel hasnt been that good..
anyone here tried intel's library and worked out texturing ? let me know if you did
thanks in advance

PostPosted: May 6, 2003 @ 9:54am
by blackrob_
Would you be able to post a bit of your code so we can take a look ? :)

PostPosted: May 6, 2003 @ 10:27am
by vic
// Set raster struct
raster.m_pFrameBuf = (U16 *)buffer;
raster.m_rgba = 0x00ff0000;
raster.m_pZBuffer = NULL;
raster.m_texture[0].m_pTexBuffer = (U16 *)bitmap.GetData();
raster.m_texture[0].m_Width = bitmap.GetWidth();
raster.m_texture[0].m_Height = bitmap.GetHeight();

// Create an array of scanlines with texture info
I32 res;
for( int j=0; j<320; j++ ) // y
{
int startX = j*240;
int endX = j*240+240;

// get fixed-point v coord in [0..1] range
I32 tm = gppFloat_To_Fixed_16( (float)j );
I32 tn = gppFloat_To_Fixed_16( 320.0f );

// Set starting point array
startpoint[j].x = gppInt_To_Fixed_16( startX );
startpoint[j].w = 0;
startpoint[j].r = (0);
startpoint[j].g = (0);
startpoint[j].b = (0);
startpoint[j].a = (0);

// Get UV coords for startpoint
startpoint[j].tu = gppFloat_To_Fixed_16( 0.0 );
gppDiv_16_32s( tm, tn, &res );
startpoint[j].tv = (res);

// Set endpoints array
endpoint[j].x = gppInt_To_Fixed_16( endX );
endpoint[j].w = 0;
endpoint[j].r = (0);
endpoint[j].g = (0);
endpoint[j].b = (0);
endpoint[j].a = (0);

// Get UV coords for endpoint
endpoint[j].tu = gppFloat_To_Fixed_16( 1.0 );
gppDiv_16_32s( tm, tn, &res );
endpoint[j].tv = (res);
}



Then in the mainloop, rasterize:

// Gouraud texture scanlines (no depthbuffer used)
for( i=0; i<m_Height; i++ )
status = gppScanLine_G_Zal_Taw_16_32s( &startpoint[i], &endpoint[i], &raster );


I cant post any pictures right now, i dont have the pocketpc with me atm, but ill try to get a shot of how it should it and how it *is*.
I think something wrong with the texture coords, maybe the fixed-point conversion, or how it accepts the coords. I think it should accept coords within the texture size limits, not in a 0..1 range.. but using this, happens to be the best results i got so far!
it should be something dumb, but i havent traced it yet. maybe you can !
thanks in advance

PostPosted: May 6, 2003 @ 12:35pm
by Digby
I haven't used the Intel library but from looking at your code and their docs here's a few things you might try.

1) You need to change the raster.m_pFrameBuf to point at the start of each scan line you're going to rasterize. In the code you posted, you set it once to what I can only assume is the start of your render target.

2) Even though you're rasterizing without using a depth buffer, you might want to set the w component of the endpoints to the fixed point equivalent of 1.0.

3) Since you're setting the color of both endpoints of the scan line to black, use flat shading instead of Gouraud shading to increase performance.

I think Dan has actually evaluated the Intel library and can probably give you more info.

PostPosted: May 6, 2003 @ 5:56pm
by vic
hi!

thanks for the tips ! i tried what you said, i was using different colors on scanline points thats why the gouraud code was still on. about the memory addressing for each scanline. i just tried it.. still gives me the same image results! nothing changed.. any other ideas ?
it has been quite painful :)
thanks in advance
vic

PostPosted: May 6, 2003 @ 6:53pm
by Digby
Beats me. You might try using the simpler "decal" texturing mode (ippgScanLine_Zal_Tdw_16_32s).

I guess the first thing I would do is try to simplify things as much as possible in an attempt to narrow down the problem. I'd try to rasterize a single scan line instead of the whole screen. I'd use a malloc'ed buffer for my texture and fill it with a known value (start with white) and then see if I got the expected results.

Maybe you can post a screen dump of what is happening with a simpler version of your code?

PostPosted: May 6, 2003 @ 11:18pm
by Dan East

PostPosted: May 7, 2003 @ 6:14am
by vic
i have tried a simpler version. i got flat shading and gouraud working. i tried every raster method, but it really doesnt matter, coz if texture doesnt work with one of the rasters, it wont work with any other. i ran into these problems just with texturemapping, nothing else.

as for a test heres what i did.. i just draw one big background image with a simple blit function, and then i try to render that same image using IGPP, scanline by scanline (using a timer)

about the clipping.. i just feed my start/end scanline points with the screen borders.. should be enough.

scanline1 sx=0, ex=239;
scanline2 sx=240, ex=479;
scanline2 sx=480, ex=719;
etc

the formula is as follows:
(sets start x point to first pixel of each screen scanline and end x point to the startpoint+(width-1)

for j=0; j<height; j++
{
int startX = j*width;
int endX = startX+(width-1);

startpoint[j].x = gppInt_To_Fixed_16( startX );
endpoint[j].x = gppInt_To_Fixed_16( endX );
}

then just go thru the scanlines array and render them all.

if you want to give it a try, i assembled a simple example (with source code and binaries). you can download it and also see some shots at:

www.pixelnerve.com/gpp

(original.jpg is the original image blitted to the screen. gpp_render.jpg is how it looks when rendered by my function using the intel GPP.
notice i just render half the screen height. theres a line to seperate it.. the top half is rendered by GPP. it screwed up the image as you can see)


hope to hear from you soon!
peace !

PostPosted: May 7, 2003 @ 8:15am
by Sergey Chaban

PostPosted: May 7, 2003 @ 8:17am
by Digby

PostPosted: May 7, 2003 @ 8:26am
by vic

PostPosted: May 7, 2003 @ 8:30am
by vic

PostPosted: May 7, 2003 @ 4:17pm
by DooMer_MP3
Hey question. I was going to start experimenting with the GPP library myself, but I have an ARM PocketPC (Audiovox Maestro). Is it true that the only functions that don't work on ARM processors are Inv and Div instructions? If so, how are people getting around this? Did you write your own Div routines in C? Or did you do it in ARM assembly?

Also, does usage of the GPP library still allow you to test code under the emulator in EVC++? Or do you have to start compiling it to the PocketPC for each time you want to run it?

Thanks.

Chris

PostPosted: May 7, 2003 @ 5:01pm
by Dan East

PostPosted: May 7, 2003 @ 5:16pm
by vic