need help allocating and copying sprite tiles efficiently

Foxi4
Posts: 14
Joined: Wed Feb 22, 2012 10:49 pm

Re: need help allocating and copying sprite tiles efficientl

Post by Foxi4 » Wed Nov 28, 2012 9:49 am

I was lead to believe that you can use all four channels at one time since the DMA controller is separate from the CPU entirely. Even if you can perform only one copy operation though, it's still independent from the CPU and more time-efficient. ;)

elhobbs
Posts: 354
Joined: Thu Jul 02, 2009 1:19 pm

Re: need help allocating and copying sprite tiles efficientl

Post by elhobbs » Wed Nov 28, 2012 3:32 pm

not sure if this has already been mentioned, but DMA copies are best for main ram to vram copies. main ram to main ram copies do not perform as well with DMA copies.

Foxi4
Posts: 14
Joined: Wed Feb 22, 2012 10:49 pm

Re: need help allocating and copying sprite tiles efficientl

Post by Foxi4 » Sat Dec 01, 2012 6:26 pm

I see... so, to conclude:

When copying between RAM <---> VRAM, use DMA Copying
When copying within RAM, use SWI Copying
When all else fails, use the Standard memcpy Copying

...sounds about right? Of course one also has to take into account the size of chunks and all that junk... But sounds alright for a general rule.

elhobbs
Posts: 354
Joined: Thu Jul 02, 2009 1:19 pm

Re: need help allocating and copying sprite tiles efficientl

Post by elhobbs » Sun Dec 02, 2012 12:56 am

Don't forget to flush data cache before dma. You should be able to find an optimized asm memcpy if you search this forum. It seam to remember that it may be best at main to main copies. It may require aligned buffers but so does dma.

jinoh67
Posts: 4
Joined: Sat May 04, 2013 4:18 am

Re: need help allocating and copying sprite tiles efficientl

Post by jinoh67 » Sat May 04, 2013 4:21 am

On http://libnds.devkitpro.org/a00112.html ... 22fe84245d,

static void dmaCopy ( const void * source,
void * dest,
uint32 size
) [inline]
copies from source to destination using channel 3 of DMA available channels in half words

Parameters:
source the source to copy from
dest the destination to copy to
size the size in bytes of the data to copy. Will be truncated to the nearest half word (2 bytes)

On http://libnds.devkitpro.org/a00102.html ... f9f334ec27,


void swiCopy ( const void * source,
void * dest,
int flags
)
copies or fills some memory.

Parameters:
source pointer to transfer source or pointer to value to fill the memory with.
dest pointer to transfer destination.
flags bits(0-20): size of data to copy/fill in words, or'd with the copy mode size (word or halfword) and type (copy or fill).

Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests