[uae] Re: SDL speedup

  • From: Richard Drummond <evilrich@xxxxxxxxxxxxxx>
  • To: uae@xxxxxxxxxxxxx
  • Date: Fri, 12 Nov 2004 21:34:04 -0500

Hi Jesper

On Friday 12 November 2004 05:10 pm, blynel@xxxxxxxxxx wrote:
> I should probadly note that I was using double resolution and
> scanlines. When swiching to lowres (without scanlines) I get this
> debug info:
>
> Function: flush_screen
> Function: flush_block 16 116
> Function: flush_block 117 217
> Function: flush_block 218 239
> Function: flush_block 245 255
> Function: flush_screen

Doh! Of course. I didn't test with scanlines.

> Which look more like what should happen. And now the game runs fine of
> course :)

> This code should really go in 'drawing.c' but that one seems a bit
> more difficult to mess with. Anyway I agree that the 100 line blocks
> look a bit arbitrary. If something changes does it really flush a
> whole 100 line block? Merging the blocks and only flushing what has
> changed seem like a better scheme to me.

Only adjacent lines were merged as blocks - hence the problem with scanlines, 
since only every other line is updated.

Try the attached patch for drawing.c. This will cause two consecutive 
flush_lines with a 1-line space between to be treated as a block. This should 
cure the problem with scanlines.

Cheers,
Rich
Index: src/drawing.c
===================================================================
RCS file: /cvsroot/uaedev/uae/src/drawing.c,v
retrieving revision 1.6
diff -u -r1.6 drawing.c
--- src/drawing.c       30 Oct 2004 16:01:27 -0000      1.6
+++ src/drawing.c       13 Nov 2004 02:23:55 -0000
@@ -163,6 +163,8 @@
 static int first_drawn_line, last_drawn_line;
 static int first_block_line, last_block_line;
 
+#define NO_BLOCK -3
+
 /* These are generated by the drawing code from the line_decisions array for
    each line that needs to be drawn.  These are basically extracted out of
    bit fields in the hardware registers.  */
@@ -1208,15 +1210,15 @@
     if (gfxvidinfo.maxblocklines == 0)
        flush_line (lineno);
     else {
-       if ((last_block_line+1) != lineno) {
-           if (first_block_line != -2)
+       if ((last_block_line + 2) < lineno) {
+           if (first_block_line != NO_BLOCK)
                flush_block (first_block_line, last_block_line);
            first_block_line = lineno;
        }
        last_block_line = lineno;
        if (last_block_line - first_block_line >= gfxvidinfo.maxblocklines) {
            flush_block (first_block_line, last_block_line);
-           first_block_line = last_block_line = -2;
+           first_block_line = last_block_line = NO_BLOCK;
        }
     }
 }
@@ -1238,7 +1240,7 @@
        Should be corrected.
        (sjo 26.9.99) */
 
-    if (gfxvidinfo.maxblocklines != 0 && first_block_line != -2) {
+    if (gfxvidinfo.maxblocklines != 0 && first_block_line != NO_BLOCK) {
        flush_block (first_block_line, last_block_line);
     }
     unlockscr ();
@@ -1644,7 +1646,7 @@
     last_drawn_line = 0;
     first_drawn_line = 32767;
 
-    first_block_line = last_block_line = -2;
+    first_block_line = last_block_line = NO_BLOCK;
     if (currprefs.test_drawing_speed)
        frame_redraw_necessary = 1;
     else if (frame_redraw_necessary)

Other related posts: