• Rise from your gwave!

Reading from the framebuffer?

Discussion in 'Saturn Dev' started by XL2, Aug 23, 2018.

  1. XL2

    XL2 Member

    And it seems like it works!
    I haven't tried on real hardware, but it should work too.
    In these pictures, only the "sparkles" are using VDP2 transparency so it might be a bit hard to see.
    It's also very low definition at just 160x112 so I guess it will look better with flat polygons and gouraud shading.

    The only remaining issue is the scale as I just want to scale x by 0,455 and y 0.5 to have everything fit where it should go, but simply scaling my matrix will lead to issues (I just want screen space scaling).
    Maybe I'll just manualy fix the draw commands or manualy generate draw commands, but it would be better to avoid always "patching" SGL and redo everything it does.

    Edit : Added another picture with a basic box to better show how the transparency works on both VDP2 layers and VDP1. But the scale is still wrong, I will try to find a way to fix it this week.
     

    Attached Files:

    Last edited: Dec 3, 2018 at 10:42 PM
  2. mrkotfw

    mrkotfw Member

    Excellent work.

    This is a bit off topic, but I wonder if it's possible to use the SCU-DSP for software translucency (similar to PlayStation blending modes).

    Possibly perform it in 8x8 or 16x16 "tiles". You have two tiles in each bank, and DMA the results to VDP2.
     
    David Gámiz Jiménez likes this.
  3. XL2

    XL2 Member

    You mean using software rendering? I already wrote a simple software renderer using lines for transparency before trying the current technique.
    The line technique is looking quite good but it creates too many draw commands.
    The SCU could be useful to create the edges, but it has too limited memory for anything ambitious.
    You can of course use different transparency ratios on the NBG0 or NBG1 layer, but it will apply on the whole layer.
    I never tried per pixel color ratios, but that could be another solution using the BR technique for different blending values.
    The only negative points are the sorting and the low definition.
    For the speed, it seems to be quite fast with little impact on the framerate, but I need to use custom draw commands as it doesn't play nice with SGL.

    Edit : With custom draw commands and proper scaling. I could probably not scale up that much and accept some lost pixels on the side of the screen to avoid such large edges, but I don't know if I should.
     

    Attached Files:

    Last edited: Dec 5, 2018 at 11:07 PM
  4. XL2

    XL2 Member

    Tested on real hardware and it works fine!
    The framerate is mostly at 30 FPS, but it slows down more often to 20 than before (some optimizations would help improve that).

    On a side note, could anyone give me a hand transforming some SGL functions?
    It would be faster that using my own code since I could just use the whole SGL pipeline.
    I just need to scale at screen space (again, x * 0.454545 and y * 0.5) after the transformation.
    I know almost nothing about assembly atm, so could anyone point me where to look at?
    Thanks!

    Code:
    sglC08.o:     file format coff-sh
    
    
    Disassembly of section SLPROG:
    
    00000000 <_slPutPolygon>:
           0:    e0 01           mov    #1,r0
           2:    c0 73           mov.b    r0,@(115,gbr)
           4:    c5 55           mov.w    @(170,gbr),r0
           6:    70 01           add    #1,r0
           8:    c1 55           mov.w    r0,@(170,gbr)
           a:    c6 22           mov.l    @(136,gbr),r0
           c:    51 41           mov.l    @(4,r4),r1
           e:    63 03           mov    r0,r3
          10:    c6 1d           mov.l    @(116,gbr),r0
          12:    65 3d           extu.w    r3,r5
          14:    62 0d           extu.w    r0,r2
          16:    32 1c           add    r1,r2
          18:    32 56           cmp/hi    r5,r2
          1a:    8d 46           bt.s    aa <ptpl_09>
          1c:    65 29           swap.w    r2,r5
          1e:    52 43           mov.l    @(12,r4),r2
          20:    43 29           shlr16    r3
          22:    40 29           shlr16    r0
          24:    30 2c           add    r2,r0
          26:    30 36           cmp/hi    r3,r0
          28:    8d 3f           bt.s    aa <ptpl_09>
          2a:    25 0d           xtrct    r0,r5
          2c:    d6 7b           mov.l    21c <IMM_ComRdPtr>,r6    ! 260ffc44
          2e:    c6 12           mov.l    @(72,gbr),r0
          30:    63 62           mov.l    @r6,r3
          32:    67 03           mov    r0,r7
          34:    30 30           cmp/eq    r3,r0
          36:    8f 3a           bf.s    ae <ptpl_01>
          38:    c6 07           mov.l    @(28,gbr),r0
          3a:    17 11           mov.l    r1,@(4,r7)
          3c:    17 23           mov.l    r2,@(12,r7)
          3e:    66 03           mov    r0,r6
          40:    c6 09           mov.l    @(36,gbr),r0
          42:    41 08           shll2    r1
          44:    41 08           shll2    r1
          46:    30 1c           add    r1,r0
          48:    c2 09           mov.l    r0,@(36,gbr)
          4a:    e0 fc           mov    #-4,r0
          4c:    24 09           and    r0,r4
          4e:    51 40           mov.l    @(0,r4),r1
          50:    52 42           mov.l    @(8,r4),r2
          52:    53 44           mov.l    @(16,r4),r3
          54:    21 09           and    r0,r1
          56:    22 09           and    r0,r2
          58:    e0 fe           mov    #-2,r0
          5a:    23 09           and    r0,r3
          5c:    17 12           mov.l    r1,@(8,r7)
          5e:    17 24           mov.l    r2,@(16,r7)
          60:    17 35           mov.l    r3,@(20,r7)
          62:    e1 14           mov    #20,r1
          64:    17 10           mov.l    r1,@(0,r7)
          66:    60 53           mov    r5,r0
          68:    c2 1d           mov.l    r0,@(116,gbr)
          6a:    77 18           add    #24,r7
          6c:    50 60           mov.l    @(0,r6),r0
          6e:    51 61           mov.l    @(4,r6),r1
          70:    52 62           mov.l    @(8,r6),r2
          72:    53 63           mov.l    @(12,r6),r3
          74:    17 00           mov.l    r0,@(0,r7)
          76:    17 11           mov.l    r1,@(4,r7)
          78:    17 22           mov.l    r2,@(8,r7)
          7a:    17 33           mov.l    r3,@(12,r7)
          7c:    50 64           mov.l    @(16,r6),r0
          7e:    51 65           mov.l    @(20,r6),r1
          80:    52 66           mov.l    @(24,r6),r2
          82:    53 67           mov.l    @(28,r6),r3
          84:    17 04           mov.l    r0,@(16,r7)
          86:    17 15           mov.l    r1,@(20,r7)
          88:    17 26           mov.l    r2,@(24,r7)
          8a:    17 37           mov.l    r3,@(28,r7)
          8c:    50 68           mov.l    @(32,r6),r0
          8e:    51 69           mov.l    @(36,r6),r1
          90:    52 6a           mov.l    @(40,r6),r2
          92:    53 6b           mov.l    @(44,r6),r3
          94:    17 08           mov.l    r0,@(32,r7)
          96:    17 19           mov.l    r1,@(36,r7)
          98:    17 2a           mov.l    r2,@(40,r7)
          9a:    17 3b           mov.l    r3,@(44,r7)
          9c:    e0 30           mov    #48,r0
          9e:    30 7c           add    r7,r0
          a0:    d1 5f           mov.l    220 <IMM_FRT_INTR>,r1    ! 21000000
          a2:    c2 12           mov.l    r0,@(72,gbr)
          a4:    21 01           mov.w    r0,@r1
          a6:    00 0b           rts  
          a8:    e0 01           mov    #1,r0
    
    
    [...]
    And so on...
    
     

    Attached Files:

Share This Page