GU questions about cachewriteback and other things...

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

Moderators: cheriff, TyRaNiD

Post Reply
Sdw
Posts: 29
Joined: Tue Jul 17, 2007 9:50 am

GU questions about cachewriteback and other things...

Post by Sdw »

I'm doing my first little tests of the GU. I found some samples, and got things going. However I had some major problems when I started to do dynamic changes to my vertex buffer, some changes never seemed to make it through.

After much testing I found out that adding a sceKernelDcacheWritebackAll() before the sceGumDrawArray() call solved it. So is that the way it should be done - flushing the cache after every change, or am doing something stupid?

Another question, the "display list" or whatever you call it that you set up with
sceGuStart(GU_DIRECT,dList):
After adding some stuff my program started crashing and I soon realised that the dlist that was allocated was too small. So I increased it and it worked.
However, is this just guess work how big it should be? The example program I started out with used memalign( 16, 1024 ), and I increased it to 65536 and things worked again, but I have no real grasp on how much drawing operations corresponds to how much display list space.
How much do you allocate normally?
chp
Posts: 313
Joined: Wed Jun 23, 2004 7:16 am

Post by chp »

If you're just writing to the vertexbuffer every time you should do your memory accesses uncached, which should give you much better performance than flushing the cache. You do this by ORing the pointer with 0x40000000. That makes sure that writes are pushed to memory directly and won't linger in the cache, just make sure you don't need to read from the same memory (uncached reads have a huge penalty, and cached reads might not see what you have written uncached to the same location).

The displaylist should be enough to contain all drawing commands between one sceGuStart()/sceGuFinish() pair. You can check how much memory you are currently using by calling sceGuCheckList(), which returns number of bytes currently in use. If you overflow this list you are basically screwed, since it will have written into memory it does not own. A good size is 512kB for most needs.

Most sceGu*()-commands use around 4-16 bytes per call, but there are exceptions like sceGuSetMatrix() that can use up to 70 bytes per call since it needs to inline the matrix in the display list. Also, all calls to sceGuGetMemory() will allocate from the display list, so if you call that a lot you will see a lot more list usage.
GE Dominator
Sdw
Posts: 29
Joined: Tue Jul 17, 2007 9:50 am

Post by Sdw »

Thanks chp, excellent answers!
flatmush
Posts: 28
Joined: Tue Aug 07, 2007 9:15 am
Location: Here
Contact:

Post by flatmush »

One thing that I always wondered is, is it faster to use cached memory for a texture that you swizzle and leave and just do a writeback on it, or is it faster to use uncached memory.
Post Reply