Linear data copy to VRAM

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

Moderators: cheriff, TyRaNiD

Post Reply
Loothor
Posts: 6
Joined: Wed Sep 07, 2005 3:12 am

Linear data copy to VRAM

Post by Loothor »

I have some data I'd like to store in VRAM, and of course I'd like to transfer it as quickly as possible. As far as I know, this entails using sceGuCopyImage(). However, sceGuCopyImage seems tailored to placing images in VRAM with a rectangular layout, and I'd really like to just copy various sizes of data to specified VRAM addresses in a linear fashion. My code currently works fine using:

memcpy(pVRAMAddr, pData, size);

but this is not as quick as the DMA copy triggered by sceGuCopyImage from what I understand... Can somebody give me some info on how to do a DMA copy of data to VRAM in a linear fashion? I tried using various manglings of sceGuCopyImage, but most of them just seem to crash the PSP or write data non-linearly.
matkeupon
Posts: 26
Joined: Sat Jul 02, 2005 10:58 pm

Post by matkeupon »

I also had a performance problem with memcpy and the VRAM (it seems, copying the content of the whole screen with it is longer than 1/60s...).

There is an alignment requirement in the use of sceGuCopyImage() if I remember correctly. But using the Dmac functions would be better in your case.

http://forums.ps2dev.org/viewtopic.php?t=3890

This post talks about alignment requirement of the Dmac functions. I don't know if there is a way to know if the transfer is finished, must be a stub no one has found yet.
User avatar
Jim
Posts: 476
Joined: Sat Jul 02, 2005 10:06 pm
Location: Sydney
Contact:

Post by Jim »

Is it possible just to set width = gfx_x * gfx_y and height = 1 in the transfer? ie, pretend you're transferring one very long thin bitmap.

Jim
jsgf
Posts: 254
Joined: Tue Jul 12, 2005 11:02 am
Contact:

Post by jsgf »

You could, though I'm not sure what the limit is; if you can factor your copy area into two approximately equal products, then you can still do it in a 2D way.

Also, there doesn't seem to be much cost in issuing lots of separate copies. In PSPGL, I flip images by copying each scanline as a separate copy operation, with no obvious performance hit compared to doing a single bulk copy.
Loothor
Posts: 6
Joined: Wed Sep 07, 2005 3:12 am

Post by Loothor »

The sceDmacMemcpy() stub worked perfectly. Thanks so much for pointing out that thread. I didn't have any problems with alignment as discussed in that thread, but all of the data I am transferring is aligned on 16-byte boundaries.
Post Reply