Vertex formats...

Post Reply
Samson
Posts: 35
Joined: Mon May 19, 2008 8:05 am

Vertex formats...

Post by Samson » Sun Nov 09, 2008 8:58 pm

I'm a bit confused by vertex formats and vertex descriptions in libogc, for example:

Code: Select all

	GX_ClearVtxDesc();
	GX_SetVtxDesc(GX_VA_POS, GX_DIRECT);
	GX_SetVtxDesc(GX_VA_NBT, GX_DIRECT);
	GX_SetVtxDesc(GX_VA_TEX0, GX_DIRECT);
	
	GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_POS_XYZ, GX_F32, 0);
	GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_NBT, GX_NRM_NBT, GX_F32, 0);
	GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_TEX0, GX_TEX_ST, GX_F32, 0);
So GX_SetVtxAttrFmt takes a GX_VTXFMT0 format argument, but GX_SetVtxDesc doesn't. I looked through the code in libogc, and it always writes the vertex description into CP registers 0x50/0x60.
If you look into YAGCD, there should be one vertex description for each vertex format. Or is that Wii-only hardware? Otherwise I don't see the point in being able to declare several formats, if the actual declaration has to consist of the same elements each time. Or are you expected to send a new declaration whenever you render primitives with a different format?

shagkur
Posts: 53
Joined: Thu Sep 08, 2005 8:40 pm

Re: Vertex formats...

Post by shagkur » Mon Nov 17, 2008 1:19 pm

Hi,

you determine the VtxAttrFmt to be used on call to GX_Begin. That's why you don't have to set this with a call to VtxDesc explicitely.
This way you can setup all your used VtxAttrFmt(s) at render init and just select them by using the appropriate fmt slot on call to GX_Begin.
SetVtxDesc is more or less only used to specify what vertex data will be in the stream following GX_Begin.

regards
shagkur

Samson
Posts: 35
Joined: Mon May 19, 2008 8:05 am

Re: Vertex formats...

Post by Samson » Tue Nov 18, 2008 11:50 pm

The reason I was asking is, the VtxDesc contains which elements of a vertex are present, and if they're direct, or if they use an 8 or 16 bit index. So if you've got different shaders it would be something you're changing very frequently. On the other hand I can see myself settling for only a handful of VtxAttrFmt. But I guess if that's how the hardware is designed I'll have to work with that.

shagkur
Posts: 53
Joined: Thu Sep 08, 2005 8:40 pm

Re: Vertex formats...

Post by shagkur » Wed Nov 19, 2008 3:10 pm

Hi,

reading up the patent again says clearly there's only one vertex descriptor called "current vertex descriptor". So in my opinion there's a mistake in YAGCD at this point.

Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests