** Sega Genesis 3D Engine Day 3 **
@birt_shannon2636 Follower
21.354 Aufrufe
53 Kommentare
Kommentare aus dem Originalbeitrag auf X (Twitter)

@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

@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

@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

@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

@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

@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

@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

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

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

@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

@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

@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

@profcelsofontes
thanks for your hints ! I updated and now is much much more smoother
2 Likes

@birt_shannon
Great work 👏
1 Like

@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

@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

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

@birt_shannon
Thanks Pablo 😀 .. Shenmue next week !
5 Likes

@PABLOPEGA1980
😂😂😂
3 Likes

@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











