]> git.unchartedbackwaters.co.uk Git - francis/winuae.git/commitdiff
Multithread RTG change, only do color conversion/copy in separate thread, present...
authorToni Wilen <twilen@winuae.net>
Sat, 5 May 2018 15:48:16 +0000 (18:48 +0300)
committerToni Wilen <twilen@winuae.net>
Sat, 5 May 2018 15:48:16 +0000 (18:48 +0300)
od-win32/picasso96_win.cpp

index 817f7754c04652c646f7dc599938ff4b6f9d454e..dd2ed758bdbb867bdcd21bbcb6d522d053cfcb21 100644 (file)
@@ -89,7 +89,7 @@ static int picasso96_PCT = PCT_Unknown;
 int mman_GetWriteWatch (PVOID lpBaseAddress, SIZE_T dwRegionSize, PVOID *lpAddresses, PULONG_PTR lpdwCount, PULONG lpdwGranularity);
 void mman_ResetWatch (PVOID lpBaseAddress, SIZE_T dwRegionSize);
 
-bool picasso_flushpixels(int index, uae_u8 *src, int offset);
+void picasso_flushpixels(int index, uae_u8 *src, int offset, bool render);
 
 int p96refresh_active;
 bool have_done_picasso = 1; /* For the JIT compiler */
@@ -809,15 +809,15 @@ static bool is_uaegfx_active(void)
        return true;
 }
 
-static bool rtg_render(void)
+static void rtg_render(void)
 {
        int monid = currprefs.rtgboards[0].monitor_id;
-       bool flushed = false;
        bool uaegfx_active = is_uaegfx_active();
        int uaegfx_index = 0;
        struct AmigaMonitor *mon = &AMonitors[monid];
        struct picasso96_state_struct *state = &picasso96_state[monid];
        struct picasso_vidbuf_description *vidinfo = &picasso_vidinfo[monid];
+       struct amigadisplay *ad = &adisplays[monid];
 
        if (doskip () && p96skipmode == 0) {
                ;
@@ -825,7 +825,7 @@ static bool rtg_render(void)
                bool full = vidinfo->full_refresh > 0;
                if (uaegfx_active) {
                        if (!currprefs.rtg_multithread) {
-                               flushed = picasso_flushpixels(0, gfxmem_banks[uaegfx_index]->start + natmem_offset, state->XYOffset - gfxmem_banks[uaegfx_index]->start);
+                               picasso_flushpixels(0, gfxmem_banks[uaegfx_index]->start + natmem_offset, state->XYOffset - gfxmem_banks[uaegfx_index]->start, true);
                        }
                } else {
                        if (vidinfo->full_refresh < 0)
@@ -833,18 +833,15 @@ static bool rtg_render(void)
                        if (vidinfo->full_refresh > 0)
                                vidinfo->full_refresh--;
                }
-               bool flushed2 = gfxboard_vsync_handler(full, true);
+               gfxboard_vsync_handler(full, true);
                if (currprefs.rtg_multithread && uaegfx_active) {
-                       write_comm_pipe_int(render_pipe, uaegfx_index | (flushed2 ? 0x80000000 : 0), 0);
-                       flushed = true;
+                       if (ad->pending_render) {
+                               ad->pending_render = false;
+                               gfx_unlock_picasso(mon->monitor_id, true);
+                       }
+                       write_comm_pipe_int(render_pipe, uaegfx_index, 0);
                }
-               flushed |= flushed2;
        }
-       return flushed;
-}
-static void rtg_show(int monid)
-{
-       gfx_unlock_picasso(monid, true);
 }
 static void rtg_clear(int monid)
 {
@@ -1158,7 +1155,7 @@ static void picasso_handle_vsync2(struct AmigaMonitor *mon)
                mouseupdate(mon);
 
        if (thisisvsync) {
-               rendered = rtg_render();
+               rtg_render();
                frame_drawn(mon->monitor_id);
        }
 
@@ -1175,8 +1172,6 @@ static void picasso_handle_vsync2(struct AmigaMonitor *mon)
        }
 #endif
 
-       if (thisisvsync && !rendered)
-               rtg_show(mon->monitor_id);
 }
 
 static int p96hsync;
@@ -1218,6 +1213,11 @@ void picasso_handle_hsync(void)
        if (currprefs.rtgboards[0].rtgmem_size == 0)
                return;
 
+       if (ad->pending_render) {
+               ad->pending_render = false;
+               gfx_unlock_picasso(mon->monitor_id, true);
+       }
+
        int vsync = isvsync_rtg();
        if (vsync < 0) {
                p96hsync++;
@@ -4498,13 +4498,12 @@ void picasso_invalidate(int monid, int x, int y, int w, int h)
        DX_Invalidate(&AMonitors[monid], x, y, w, h);
 }
 
-static bool picasso_flushpixels(int index, uae_u8 *src, int off)
+static void picasso_flushpixels(int index, uae_u8 *src, int off, bool render)
 {
        int monid = currprefs.rtgboards[index].monitor_id;
        struct picasso96_state_struct *state = &picasso96_state[monid];
        uae_u8 *src_start;
        uae_u8 *src_end;
-       int lock = 0;
        uae_u8 *dst = NULL;
        ULONG_PTR gwwcnt;
        int pwidth = state->Width > state->VirtualWidth ? state->VirtualWidth : state->Width;
@@ -4523,7 +4522,7 @@ static bool picasso_flushpixels(int index, uae_u8 *src, int off)
                pwidth, pheight);
 #endif
        if (!vidinfo->extra_mem || !gwwbuf[index] || src_start >= src_end) {
-               return false;
+               return;
        }
 
        if (flashscreen) {
@@ -4565,7 +4564,6 @@ static bool picasso_flushpixels(int index, uae_u8 *src, int off)
                        vidinfo->rtg_clear_flag--;
                if (dst == NULL)
                        break;
-               lock = 1;
                dst += vidinfo->offset;
 
                if (doskip () && p96skipmode == 2) {
@@ -4644,8 +4642,6 @@ static bool picasso_flushpixels(int index, uae_u8 *src, int off)
        if (currprefs.leds_on_screen & STATUSLINE_RTG) {
                if (dst == NULL) {
                        dst = gfx_lock_picasso(monid, false, false);
-                       if (dst)
-                               lock = 1;
                }
                if (dst) {
                        if (!(currprefs.leds_on_screen & STATUSLINE_TARGET)) {
@@ -4664,12 +4660,11 @@ static bool picasso_flushpixels(int index, uae_u8 *src, int off)
                }
        }
 
-       if (lock)
-               gfx_unlock_picasso(monid, true);
+       if (dst)
+               gfx_unlock_picasso(monid, render);
        if (dst && gwwcnt) {
                vidinfo->full_refresh = 0;
        }
-       return lock != 0; 
 }
 
 static void *render_thread(void *v)
@@ -4677,7 +4672,6 @@ static void *render_thread(void *v)
        render_thread_state = 1;
        for (;;) {
                int idx = read_comm_pipe_int_blocking(render_pipe);
-               bool flush = (idx & 0x80000000) != 0;
                if (idx == -1)
                        break;
                idx &= 0xff;
@@ -4686,10 +4680,8 @@ static void *render_thread(void *v)
                if (ad->picasso_on && ad->picasso_requested_on) {
                        lockrtg();
                        struct picasso96_state_struct *state = &picasso96_state[monid];
-                       if (!picasso_flushpixels(idx, gfxmem_banks[idx]->start + natmem_offset, state->XYOffset - gfxmem_banks[idx]->start)) {
-                               if (flush)
-                                       gfx_unlock_picasso(monid, true);
-                       }
+                       picasso_flushpixels(idx, gfxmem_banks[idx]->start + natmem_offset, state->XYOffset - gfxmem_banks[idx]->start, false);
+                       ad->pending_render = true;
                        unlockrtg();
                }
        }
@@ -5280,7 +5272,7 @@ uae_u32 picasso_demux (uae_u32 arg, TrapContext *ctx)
 
 void picasso_free(void)
 {
-       if (currprefs.rtg_multithread && render_thread_state > 0) {
+       if (render_thread_state > 0) {
                write_comm_pipe_int(render_pipe, -1, 0);
                while (render_thread_state >= 0) {
                        Sleep(10);