Navigation überspringen
** Sega Genesis 3D Engine Day 3 **
0:00 / 0:23

** Sega Genesis 3D Engine Day 3 **

Shannon Birt

@birt_shannon2636 Follower

Auf X besuchen

21.354 Aufrufe

** Sega Genesis 3D Engine Day 3 ** Blast Processing kicks In !! Converted the Line Drawing and Triangle drawing to 68k Assembly and gained 25% in the line drawing and 33% speedups in the triangle drawing vs C ( so far ) . The scheduler calculating the vertexs is still in C , just the drawing routines are now are in assembly . Possibly 5-10 % gains will come from the scheduler being in ASM also. The Line and Triangle drawing C code took some beating , it was surprising - particularly the line drawing to get a speed up over the C code in ASM. I guess its not too surprising as the C code was basically handling pointers and integers so I had to get exotic to find the speedups. Initially my ASM Line draw was 100% slower than the C code - the first pass conversion from C to ASM is always rough as its more about getting it working then refine later , but yeah 100% slower on first pass was brutal, after 4 hrs tweaking it was 25% faster than the C code so thats a good start - might get more yet. So added more squares and more triangles for load testing at the same frame rate. Its still not anything cohesive but right now focussing on performance in rendering to see how much can be pushed. As rendering will be the biggest cpu soak the faster that goes the better. The smaller triangles take about 1/3 the CPU time of the larger triangles at present so theres definately a fill rate limit vs the setup time to consider. The same would go for the squares been line framed - smaller ones would allow al lot more . #SGDK #SegaGenesis #SegaMegadrive

53 Kommentare

Kommentare aus dem Originalbeitrag auf X (Twitter)

  • Profilbild von Stephane

    @MegadriveDev

    @suddendesu Did you try to compare versus the SGDK bitmap functions ? I remember spending a bit of time on them a long time ago but I never refined them since then.

    14 Likes

  • Profilbild von Shannon Birt

    @birt_shannon

    Hi Stephane, I didn't compare it , it would be interesting to know . Unless they are written in assembly I think they would be slower as I'm doing lots of 68k tricks to get more speed that I doubt C would optimise for. The larger triangles when wrapt in a kdebug start - stop are taking ~ 49k cycles, smaller ones 13-14 k cycles. The box outlines 4 sides are ~ 20k cycles (so maybe 5k per line ) . The Kdebug itself is likely taking a chunk of that , and thats also asm been called from C so its not full asm yet. I'm hoping to get a bit more yet. I guess theres going to be an upper end of performance that can be reached with this sort of thing .

    13 Likes

  • Profilbild von Stephane

    @MegadriveDev

    @suddendesu I didn't really measured in cycles but yeah all the drawing methods are mostly in assembly. I believe the polygon drawing code itself is fast but the bitmap buffer handling itself is not that fast (still in C) and so a big portion of time is spent in the VRAM transfer

    5 Likes

  • Profilbild von Shannon Birt

    @birt_shannon

    Some palette masking would make the buffer sending much more efficient - like Anaels demos , albiet with a hefty color reduction . Right now just using a full 15 color buffer , double buffered 256x128 sending about ~ 4k per frame which is allowing some time in the vblank for other tasks. The dma is optimised so its one DMA per frame, and it will use the maximum amount of scanlines it can whilst leaving some scanlines for other tasks. I've thought about a reduced screen vertically - that might make sense to increase the frame rate by allowing more DMA per frame, but i think a lower frame rate with this sort of thing is acceptable to push more detail.

    7 Likes

  • Profilbild von Stephane

    @MegadriveDev

    @suddendesu Oh yeah so your implementation is already much more optimized than the SGDK bitmap engine which uses a linear 256x160 4bpp buffer (can be double buffered) and which is transferred by the CPU for the linear --> tile conversion 🥲

    6 Likes

  • Profilbild von Shannon Birt

    @birt_shannon

    Ah thats very interesting . Currently using a by column format and all the translation to tile format is done directly in the drawing routines so the dma is fast and efficient and no translation needed but the drawing routines have to deal with the column stride. Linear format sounds nice to work with however where speed is not the top priority as the cpu transfer would be atleast twice as slow as dma .

    5 Likes

  • Profilbild von Stephane

    @MegadriveDev

    @suddendesu Exactly, I really wanted to have that linear buffer so any user can use it to do software rendering easily. Also that allows the drawing methods (pixel, line and filled polygon/triangle..) to be faster but yeah the software buffer copy itself is terribly slow 😅

    4 Likes

  • Profilbild von Stephane

    @MegadriveDev

    @suddendesu Just the software transfer limits the maximum frame rate to 20 FPS in NTSC / 25 FPS in PAL

    5 Likes

  • Profilbild von Prof Celso Fontes

    @profcelsofontes

    Hi @birt_shannon ! I think you can be interested in my new project too (no c, all assembly):

    9 Likes

  • Profilbild von Shannon Birt

    @birt_shannon

    Oh looks nice - rotating cube !! , will have a look . You'll know the pain first hand then haha. Ah you drawing quads or triangles ? How did you setup the frame buffer - Column by column ? I'll lookout for the next update !

    1 Like

  • Profilbild von Prof Celso Fontes

    @profcelsofontes

    📐! Each cube face = 2 tris, 12 total. Scanline fill with 16.8 fixed-point edge interpolation. FB is row-major (not column😅): 160x112, 2px/byte (4-bit nibbles). Formula: offset = y*80 + x/2. No DMA — CPU packs into 8x8 tiles & uploads to VRAM on a 7.67MHz 68k.Every cycle hurts🔥

    3 Likes

  • Profilbild von Shannon Birt

    @birt_shannon

    Ah right , as im using H32 mode here so I can use 8.8 fixed point for edges . Buffers are 256x128 (double buffered) and using DMA to send each buffer then flipping so no fancy tile packing but it has speed so thats what I'm after at present. Yes every cycle must be meaninfull haha.

    4 Likes

  • Profilbild von Prof Celso Fontes

    @profcelsofontes

    thanks for your hints ! I updated and now is much much more smoother

    2 Likes

  • Profilbild von Shannon Birt

    @birt_shannon

    Great work 👏

    1 Like

  • Profilbild von Prof Celso Fontes

    @profcelsofontes

    thanks, now i need to fix some incorrect positions to 100% perfect the cube and go to others primitives enough to create a hello world 3d game as example for the sdk itself

    2 Likes

  • Profilbild von Shannon Birt

    @birt_shannon

    Yeah i think there is some benefit to drawing quads to reduce divisions and might be faster filling also . All fun !!

    1 Like

  • Profilbild von PABLO PEÑA

    @PABLOPEGA1980

    Shannon playing with poligons...🤔 I see It clear, next optimization is Shenmue running on the Genesis!! Well done Shannon! 💪

    7 Likes

  • Profilbild von Shannon Birt

    @birt_shannon

    Thanks Pablo 😀 .. Shenmue next week !

    5 Likes

  • Profilbild von PABLO PEÑA

    @PABLOPEGA1980

    😂😂😂

    3 Likes

  • Profilbild von Raphael Morane

    @moranetigger

    What about the sega cd chip that make 3d stuff? Some one could give me a example os use? Great project bro...imagine a world circuit MD

    2 Likes