sceGumDrawArray and huge models

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
LuMo
Posts: 410
Joined: Sun Aug 21, 2005 2:45 am
Location: Austria
Contact:

sceGumDrawArray and huge models

Post by LuMo »

as sceGumDrawArray is defined:

Code: Select all

void sceGumDrawArray  	(   	int   	 prim,
		int  	vtype,
		int  	count,
		const void *  	indices,
		const void *  	vertices
	)
if i pass to count a value like unsigned shor it works fine
when i switch over to unsigned long the model gets fucked up (no other changes in code...)

as int can be 2 or 4 bytes i am curious whats going wrong there...
int
-32'768 ... 32'767 or
-2'147'483'648 .. 2'147'483'647

while unsigned long = 4 byte
0 ... 4'294'967'295

the range is the same (IF int is implemented as 4-byte)

any ideas?
greets
lumo
PS: i do not want to crop the models in parts...
"Good artists copy, great artists steal."
Pablo Picasso
go2lumo.com
sandberg
Posts: 90
Joined: Wed Oct 05, 2005 1:25 am
Location: Denmark

Post by sandberg »

This is caused by the fact, that when the sceGuDrawArray sends the last command to the GU, it packs the primitive type and the count parameter into the same 32 bit argument. Where the 16 upper bits is the primitive and the lower 16 bit is the number of vertices / indices. So you can only use 16 bit for the count.

I've marked the code below in red.
void sceGuDrawArray(int prim, int vtype, int count, const void* indices, const void* vertices)
{
if (vtype)
sendCommandi(18,vtype);

if (indices)
{
sendCommandi(16,(((unsigned int)indices) >> 8) & 0xf0000);
sendCommandi(2,((unsigned int)indices) & 0xffffff);
}

if (vertices)
{
sendCommandi(16,(((unsigned int)vertices) >> 8) & 0xf0000);
sendCommandi(1,((unsigned int)vertices) & 0xffffff);
}

sendCommandiStall(4,(prim << 16)|count);
}
Br, Sandberg
LuMo
Posts: 410
Joined: Sun Aug 21, 2005 2:45 am
Location: Austria
Contact:

Post by LuMo »

bugga
at least i know... its not my programming fault :)

thanks
lumo
"Good artists copy, great artists steal."
Pablo Picasso
go2lumo.com
Post Reply