gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

DS development > how to speed scanline in VRAM ?

#101436 - anael - Tue Sep 05, 2006 3:13 pm

Hello !

I'am working on a polygon drawing function to draw directly in VRAM,
for the scanline i use :

swiCopy(&color, back + 256*line + min, COPY_MODE_HWORD | COPY_MODE_FILL | (max - min));

back is VRAM
line the current line where i'm drawing
min the x start
max the x end

Is it possible to speed copy ? in ASM ?

thank you for reading !

#101527 - !cube - Wed Sep 06, 2006 8:13 am

Filling a polygon with a single color by copying data from one place to another is definitely not the way to go about it because you're accessing memory in vain when reading the color from a memory address.

- Use assembler and the registers as fully as you can to reduce memory accesses
- Do not make an assembler function for filling a scanline, make one for the whole triangle filling critical loop, setup code can be C/C++
- Never EVER plot pixel by pixel with STRB/STRH if you're just filling with one color unless on polygon boundaries
- Unroll the loop so you can fill more pixels with just one memory access by using aligned 32-bit stores and possibly even more with consecutive writes
- ARM9: Use swizzled textures when doing texture mapping to minimize cache misses
- ARM9: Use pre-emptive memory access when doing texture mapping, reading data well before the need to actually use the data anywhere to minimize the effect of cache misses and interlock cycles in LDR/LDRB/LDRH
- Use intelligent bit hacks when doing blending

..just some basic ideas how to improve your filler code.

#101535 - anael - Wed Sep 06, 2006 9:14 am

Thank you for help.

Yes i just whant to fill it with a single color with no blending, but i don't know how ASM works.

swiCopy works fine but it's slow...