From: Toni Wilen Date: Mon, 24 Mar 2025 17:01:41 +0000 (+0200) Subject: Draw buffer handling update. X-Git-Url: https://git.unchartedbackwaters.co.uk/w/?a=commitdiff_plain;h=7beca51ff7baeabc792a22d12c6e86d3ba4335a2;p=francis%2Fwinuae.git Draw buffer handling update. --- diff --git a/custom.cpp b/custom.cpp index cba5790e..490f650b 100644 --- a/custom.cpp +++ b/custom.cpp @@ -1256,7 +1256,7 @@ static void update_mirrors(void) hsyncdebug = currprefs.gfx_overscanmode - OVERSCANMODE_ULTRA + 1; } struct vidbuf_description *vidinfo = &adisplays[0].gfxvidinfo; - lineoptimizations_allowed = vidinfo->inbuffer == vidinfo->outbuffer && !lightpen_active; + lineoptimizations_allowed = vidinfo->inbuffer == vidinfo->outbuffer && drawing_can_lineoptimizations(); color_table_changed = true; } @@ -1569,7 +1569,6 @@ static void resetfulllinestate(void) void compute_framesync(void) { struct vidbuf_description *vidinfo = &adisplays[0].gfxvidinfo; - struct vidbuffer *vb = vidinfo->inbuffer; struct amigadisplay *ad = &adisplays[0]; int islace = interlace_seen ? 1 : 0; int isntsc = (beamcon0 & BEAMCON0_PAL) ? 0 : 1; @@ -1583,6 +1582,9 @@ void compute_framesync(void) vblank_hz = vblank_hz_shf; } + set_drawbuffer(); + struct vidbuffer *vb = vidinfo->inbuffer; + vblank_hz = target_adjust_vblank_hz(0, vblank_hz); struct chipset_refresh *cr = get_chipset_refresh(&currprefs); diff --git a/drawing.cpp b/drawing.cpp index 7f442186..a349c53c 100644 --- a/drawing.cpp +++ b/drawing.cpp @@ -204,7 +204,6 @@ static bool denise_lock(void) struct amigadisplay *ad = &adisplays[monid]; struct vidbuf_description *vidinfo = &ad->gfxvidinfo; struct vidbuffer *vb = &vidinfo->drawbuffer; - struct vidbuffer *vbin = &vidinfo->tempbuffer; if (!vb->locked) { if (!lockscr(vb, false, display_reset > 0)) { @@ -361,9 +360,6 @@ static int rga_denise_fast_read, rga_denise_fast_write; #define DENISE_RGA_SLOT_FAST_TOTAL 1024 static struct denise_rga rga_denise_fast[DENISE_RGA_SLOT_FAST_TOTAL]; - - - typedef void (*LINETOSRC_FUNC)(void); static LINETOSRC_FUNC lts; static bool lts_changed, lts_request; @@ -1170,6 +1166,7 @@ void init_row_map(void) struct vidbuf_description *vidinfo = &adisplays[0].gfxvidinfo; struct vidbuffer *vb = vidinfo->inbuffer; static uae_u8 *oldbufmem; + static struct vidbuffer *oldvb; static int oldheight, oldpitch; static bool oldgenlock, oldburst; int i, j; @@ -1184,11 +1181,13 @@ void init_row_map(void) } if (oldbufmem && oldbufmem == vb->bufmem && + oldvb == vb && oldheight == vb->height_allocated && oldpitch == vb->rowbytes && oldgenlock == init_genlock_data && - oldburst == (row_map_color_burst_buffer ? 1 : 0)) - return; + oldburst == (row_map_color_burst_buffer ? 1 : 0)) { + return; + } xfree(row_map_genlock_buffer); row_map_genlock_buffer = NULL; if (init_genlock_data) { @@ -1216,6 +1215,7 @@ void init_row_map(void) row_map_genlock[i] = row_tmp16; i++; } + oldvb = vb; oldbufmem = vb->bufmem; oldheight = vb->height_allocated; oldpitch = vb->rowbytes; @@ -1745,6 +1745,18 @@ static void refresh_indicator_update(struct vidbuffer *vb) } } +bool drawing_can_lineoptimizations(void) +{ + if (currprefs.monitoremu || currprefs.cs_cd32fmv || ((currprefs.genlock || currprefs.genlock_effects) && currprefs.genlock_image) || + currprefs.cs_color_burst || currprefs.gfx_grayscale || currprefs.monitoremu) { + return false; + } + if (lightpen_active || debug_dma >= 2 || debug_heatmap >= 2 || refresh_indicator_buffer) { + return false; + } + return true; +} + static void draw_frame_extras(struct vidbuffer *vb, int y_start, int y_end) { if (debug_dma > 1 || debug_heatmap > 1) { @@ -1806,6 +1818,7 @@ static void vbcopy(struct vidbuffer *vbout, struct vidbuffer *vbin) static void finish_drawing_frame(bool drawlines) { int monid = 0; + bool vbcopied = false; struct amigadisplay *ad = &adisplays[monid]; struct vidbuf_description *vidinfo = &ad->gfxvidinfo; struct vidbuffer *vbout = vidinfo->outbuffer; @@ -1857,12 +1870,14 @@ static void finish_drawing_frame(bool drawlines) compute_framesync(); } vbcopy(vbout, vbin); + vbcopied = true; } if (multimon && locked) { unlockscr(m_out, -1, -1); render_screen(m_out->monitor_id, 1, true); show_screen(m_out->monitor_id, 0); } + vbcopied = true; } // genlock @@ -1880,6 +1895,7 @@ static void finish_drawing_frame(bool drawlines) if (!vbout->hardwiredpositioning) { setnativeposition(vbout); } + vbcopied = true; } #ifdef CD32 @@ -1894,6 +1910,7 @@ static void finish_drawing_frame(bool drawlines) } else { vbcopy(vbout, vbin); } + vbcopied = true; } #endif @@ -1905,11 +1922,16 @@ static void finish_drawing_frame(bool drawlines) } setspecialmonitorpos(vbout); emulate_grayscale(vbin, vbout); - if (!vbout->hardwiredpositioning) + if (!vbout->hardwiredpositioning) { setnativeposition(vbout); + } + vbcopied = true; } if (denise_locked) { + if (!vbcopied) { + vbcopy(vbout, vbin); + } unlockscr(vbout, display_reset ? -2 : -1, -1); denise_locked = false; } @@ -4865,6 +4887,17 @@ bool has_draw_denise(void) return thread_debug_lock; } +void set_drawbuffer(void) +{ + struct vidbuf_description *vidinfo = &adisplays[0].gfxvidinfo; + + if (vidinfo->tempbuffer.bufmem && !drawing_can_lineoptimizations()) { + vidinfo->inbuffer = &vidinfo->tempbuffer; + } else { + vidinfo->inbuffer = &vidinfo->drawbuffer; + } +} + bool start_draw_denise(void) { struct vidbuf_description *vidinfo = &adisplays[0].gfxvidinfo; @@ -4882,16 +4915,10 @@ bool start_draw_denise(void) thread_debug_lock = true; - if (vidinfo->tempbuffer.bufmem) { - vidinfo->inbuffer = &vidinfo->tempbuffer; - } else { - vidinfo->inbuffer = &vidinfo->drawbuffer; - } - + set_drawbuffer(); if (vidinfo->outbuffer != vidinfo->inbuffer) { vidinfo->inbuffer->locked = vidinfo->outbuffer->locked; } - init_row_map(); denise_y_start = 0; diff --git a/include/drawing.h b/include/drawing.h index 148f4c94..88ff31ba 100644 --- a/include/drawing.h +++ b/include/drawing.h @@ -196,5 +196,7 @@ bool denise_is_vb(void); void draw_denise_line_queue_flush(void); void quick_denise_rga_queue(int linecnt, int startpos, int endpos); void denise_handle_quick_strobe_queue(uae_u16 strobe, int strobe_pos, int endpos); +bool drawing_can_lineoptimizations(void); +void set_drawbuffer(void); #endif /* UAE_DRAWING_H */ diff --git a/od-win32/win32gfx.cpp b/od-win32/win32gfx.cpp index 723748ad..0a642c67 100644 --- a/od-win32/win32gfx.cpp +++ b/od-win32/win32gfx.cpp @@ -3777,8 +3777,6 @@ retry: regqueryint(NULL, wasfsname[1], &wasfs[1]); gfxmode_reset(mon->monitor_id); - //freevidbuffer(mon->monitor_id, &avidinfo->drawbuffer); - //freevidbuffer(mon->monitor_id, &avidinfo->tempbuffer); for (;;) { updatemodes(mon); @@ -3800,37 +3798,8 @@ retry: if (currprefs.gfx_vresolution > avidinfo->gfx_vresolution_reserved) avidinfo->gfx_vresolution_reserved = currprefs.gfx_vresolution; - -#if defined (GFXFILTER) - if (mon->currentmode.flags & DM_D3D) { - if (!currprefs.gfx_autoresolution) { - mon->currentmode.amiga_width = AMIGA_WIDTH_MAX << currprefs.gfx_resolution; - mon->currentmode.amiga_height = AMIGA_HEIGHT_MAX << currprefs.gfx_vresolution; - } else { - mon->currentmode.amiga_width = AMIGA_WIDTH_MAX << avidinfo->gfx_resolution_reserved; - mon->currentmode.amiga_height = AMIGA_HEIGHT_MAX << avidinfo->gfx_vresolution_reserved; - } - if (avidinfo->gfx_resolution_reserved == RES_SUPERHIRES) - mon->currentmode.amiga_height *= 2; - if (mon->currentmode.amiga_height > 1280) - mon->currentmode.amiga_height = 1280; - - avidinfo->drawbuffer.inwidth = avidinfo->drawbuffer.outwidth = mon->currentmode.amiga_width; - avidinfo->drawbuffer.inheight = avidinfo->drawbuffer.outheight = mon->currentmode.amiga_height; - - mon->currentmode.current_depth = mon->currentmode.native_depth; - mon->currentmode.pitch = mon->currentmode.amiga_width * mon->currentmode.current_depth >> 3; - } - else -#endif - { - mon->currentmode.amiga_width = mon->currentmode.current_width; - mon->currentmode.amiga_height = mon->currentmode.current_height; - } - avidinfo->drawbuffer.pixbytes = mon->currentmode.current_depth >> 3; - avidinfo->drawbuffer.bufmem = NULL; - avidinfo->drawbuffer.linemem = NULL; - avidinfo->drawbuffer.rowbytes = mon->currentmode.pitch; + mon->currentmode.amiga_width = mon->currentmode.current_width; + mon->currentmode.amiga_height = mon->currentmode.current_height; break; #ifdef PICASSO96 } @@ -3839,36 +3808,20 @@ retry: updatepicasso96(mon); - if (!scrlinebuf) - scrlinebuf = xmalloc (uae_u8, max_uae_width * 4); - - avidinfo->drawbuffer.emergmem = scrlinebuf; // memcpy from system-memory to video-memory - - avidinfo->drawbuffer.realbufmem = NULL; - avidinfo->drawbuffer.bufmem = NULL; - avidinfo->drawbuffer.bufmem_allocated = NULL; - - avidinfo->outbuffer = &avidinfo->drawbuffer; - if (!mon->screen_is_picasso) { allocsoftbuffer(mon->monitor_id, _T("draw"), &avidinfo->drawbuffer, mon->currentmode.flags, - 1920, 1280, mon->currentmode.current_depth); - avidinfo->inbuffer = &avidinfo->drawbuffer; - if (currprefs.monitoremu || currprefs.cs_cd32fmv || ((currprefs.genlock || currprefs.genlock_effects) && currprefs.genlock_image) || - currprefs.cs_color_burst || currprefs.gfx_grayscale || currprefs.monitoremu) { - allocsoftbuffer(mon->monitor_id, _T("monemu"), &avidinfo->tempbuffer, mon->currentmode.flags, - mon->currentmode.amiga_width > 1024 ? mon->currentmode.amiga_width : 1024, - mon->currentmode.amiga_height > 1024 ? mon->currentmode.amiga_height : 1024, - mon->currentmode.current_depth); - avidinfo->inbuffer = &avidinfo->tempbuffer; - } + 1920, 1280); + + allocsoftbuffer(mon->monitor_id, _T("monemu"), &avidinfo->tempbuffer, mon->currentmode.flags, + mon->currentmode.amiga_width > 2048 ? mon->currentmode.amiga_width : 2048, + mon->currentmode.amiga_height > 2048 ? mon->currentmode.amiga_height : 2048); } -#if 0 - S2X_free(mon->monitor_id); -#endif + avidinfo->outbuffer = &avidinfo->drawbuffer; + avidinfo->inbuffer = &avidinfo->tempbuffer; + if (!D3D_isenabled(mon->monitor_id)) { for (int i = 0; i < MAX_AMIGAMONITORS; i++) { oldtex_w[i] = oldtex_h[i] = -1;