]> git.unchartedbackwaters.co.uk Git - francis/winuae.git/commitdiff
uaegfx RTG mode scaling multiplier support.
authorToni Wilen <twilen@winuae.net>
Sat, 18 Jun 2022 19:24:55 +0000 (22:24 +0300)
committerToni Wilen <twilen@winuae.net>
Sat, 18 Jun 2022 19:24:55 +0000 (22:24 +0300)
od-win32/direct3d.cpp
od-win32/direct3d.h
od-win32/direct3d11.cpp
od-win32/picasso96_win.cpp
od-win32/win32gfx.cpp
od-win32/win32gui.cpp

index b5a67b8a12d28edc6630531265818fac09b8a018..d7bf6fd2b46114ddc69a376c3b1ba6811b75b342 100644 (file)
@@ -202,7 +202,8 @@ struct d3dstruct
        int required_sl_texture_w, required_sl_texture_h;
        int vsync2, guimode, maxscanline, variablerefresh;
        int resetcount;
-       double cursor_x, cursor_y;
+       float cursor_x, cursor_y;
+       float cursor_mx, cursor_my;
        bool cursor_v, cursor_scale;
        int statusbar_vx, statusbar_hx;
 
@@ -3533,13 +3534,16 @@ static void D3D_render2(struct d3dstruct *d3d, int mode)
                d3d->sprite->Begin(D3DXSPRITE_ALPHABLEND);
                if (d3d->cursorsurfaced3d && d3d->cursor_v) {
                        D3DXMATRIXA16 t;
-
+                       int bl = d3d->filterd3d->gfx_filter_bilinear ? D3DTEXF_LINEAR : D3DTEXF_POINT;
+                       d3d->d3ddev->SetSamplerState(0, D3DSAMP_MAGFILTER, bl);
+                       d3d->d3ddev->SetSamplerState(0, D3DSAMP_MINFILTER, bl);
+                       d3d->d3ddev->SetSamplerState(0, D3DSAMP_MIPFILTER, bl);
                        if (d3d->cursor_scale)
-                               MatrixScaling(&t, ((float)(d3d->window_w) / (d3d->tout_w + 2 * d3d->cursor_offset2_x)), ((float)(d3d->window_h) / (d3d->tout_h + 2 * d3d->cursor_offset2_y)), 0);
+                               MatrixScaling(&t, ((float)(d3d->window_w) / (d3d->tout_w + 2 * d3d->cursor_offset2_x)) * d3d->cursor_mx, ((float)(d3d->window_h) / (d3d->tout_h + 2 * d3d->cursor_offset2_y)) * d3d->cursor_my, 0);
                        else
-                               MatrixScaling(&t, 1.0f, 1.0f, 0);
-                       v.x = (float)d3d->cursor_x + d3d->cursor_offset2_x;
-                       v.y = (float)d3d->cursor_y + d3d->cursor_offset2_y;
+                               MatrixScaling(&t, d3d->cursor_mx, d3d->cursor_my, 0);
+                       v.x = (float)d3d->cursor_x / d3d->cursor_mx + d3d->cursor_offset2_x;
+                       v.y = (float)d3d->cursor_y / d3d->cursor_my + d3d->cursor_offset2_y;
                        v.z = 0.0f;
                        d3d->sprite->SetTransform(&t);
                        d3d->sprite->Draw(d3d->cursorsurfaced3d, NULL, NULL, &v, 0xffffffff);
@@ -3672,7 +3676,7 @@ static void D3D_render2(struct d3dstruct *d3d, int mode)
                write_log (_T("%s: EndScene() %s\n"), D3DHEAD, D3D_ErrorString (hr));
 }
 
-static bool xD3D_setcursor(int monid, int x, int y, int width, int height, bool visible, bool noscale)
+static bool xD3D_setcursor(int monid, int x, int y, int width, int height, float mx, float my, bool visible, bool noscale)
 {
        struct d3dstruct *d3d = &d3ddata[monid];
 
@@ -3682,8 +3686,10 @@ static bool xD3D_setcursor(int monid, int x, int y, int width, int height, bool
        if (width && height) {
                d3d->cursor_offset2_x = d3d->cursor_offset_x * d3d->window_w / width;
                d3d->cursor_offset2_y = d3d->cursor_offset_y * d3d->window_h / height;
-               d3d->cursor_x = x * d3d->window_w / width;
-               d3d->cursor_y = y * d3d->window_h / height;
+               d3d->cursor_x = (float)x * d3d->window_w / width;
+               d3d->cursor_y = (float)y * d3d->window_h / height;
+               d3d->cursor_mx = mx;
+               d3d->cursor_my = my;
        } else {
                d3d->cursor_x = d3d->cursor_y = 0;
                d3d->cursor_offset2_x = d3d->cursor_offset2_y = 0;
index b54b20f3d2fa52a4b16fad8cb7750d0f92af6ea1..255ead5e33c8016396e6d14c68d982208680376c 100644 (file)
@@ -23,7 +23,7 @@ extern int(*D3D_isenabled)(int);
 extern void(*D3D_clear)(int);
 extern int(*D3D_canshaders)(void);
 extern int(*D3D_goodenough)(void);
-extern bool(*D3D_setcursor)(int, int x, int y, int width, int height, bool visible, bool noscale);
+extern bool(*D3D_setcursor)(int, int x, int y, int width, int height, float mx, float my, bool visible, bool noscale);
 extern uae_u8* (*D3D_setcursorsurface)(int, int *pitch);
 extern float(*D3D_getrefreshrate)(int);
 extern void(*D3D_restore)(int, bool);
index 0275a3e10e7ce632660a9ad20fe289349648d1ff..4e3431673185b5d09c1b5362672cd83945ea1dc7 100644 (file)
@@ -59,7 +59,7 @@ int (*D3D_isenabled)(int);
 void (*D3D_clear)(int);
 int (*D3D_canshaders)(void);
 int (*D3D_goodenough)(void);
-bool (*D3D_setcursor)(int, int x, int y, int width, int height, bool visible, bool noscale);
+bool (*D3D_setcursor)(int, int x, int y, int width, int height, float mx, float my, bool visible, bool noscale);
 uae_u8* (*D3D_setcursorsurface)(int, int *pitch);
 float (*D3D_getrefreshrate)(int);
 void(*D3D_restore)(int, bool);
@@ -5192,7 +5192,7 @@ bool D3D11_capture(int monid, void **data, int *w, int *h, int *pitch, bool rend
        return false;
 }
 
-static bool xD3D_setcursor(int monid, int x, int y, int width, int height, bool visible, bool noscale)
+static bool xD3D_setcursor(int monid, int x, int y, int width, int height, float mx, float my, bool visible, bool noscale)
 {
        struct d3d11struct *d3d = &d3d11data[monid];
 
@@ -5219,7 +5219,8 @@ static bool xD3D_setcursor(int monid, int x, int y, int width, int height, bool
                multx = ((float)(d3d->m_screenWidth) / ((d3d->m_bitmapWidth * d3d->dmult) + 2 * d3d->cursor_offset2_x));
                multy = ((float)(d3d->m_screenHeight) / ((d3d->m_bitmapHeight * d3d->dmult) + 2 * d3d->cursor_offset2_y));
        }
-       setspritescaling(&d3d->hwsprite, 1.0f / multx, 1.0f / multy);
+
+       setspritescaling(&d3d->hwsprite, mx / multx, my / multy);
 
        d3d->hwsprite.x = d3d->cursor_x * multx + d3d->cursor_offset2_x * multx;
        d3d->hwsprite.y = d3d->cursor_y * multy + d3d->cursor_offset2_y * multy;
@@ -5229,6 +5230,7 @@ static bool xD3D_setcursor(int monid, int x, int y, int width, int height, bool
        d3d->cursor_scale = !noscale;
        d3d->cursor_v = visible;
        d3d->hwsprite.enabled = visible;
+       d3d->hwsprite.bilinear = d3d->filterd3d->gfx_filter_bilinear;
        return true;
 }
 
index 09f164df7036ee72cb5a7064da8196f9d79eba22..d02c7c8570ff32cb0889e4c6bd6f5fb745a8b572 100644 (file)
@@ -804,7 +804,7 @@ static void disablemouse (void)
                return;
        if (!currprefs.gfx_api)
                return;
-       D3D_setcursor(0, 0, 0, 0, 0, false, true);
+       D3D_setcursor(0, 0, 0, 0, 0, 0, 0, false, true);
 }
 
 static void mouseupdate(struct AmigaMonitor *mon)
@@ -812,6 +812,8 @@ static void mouseupdate(struct AmigaMonitor *mon)
        struct picasso96_state_struct *state = &picasso96_state[mon->monitor_id];
        int x = newcursor_x;
        int y = newcursor_y;
+       float mx = currprefs.gf[1].gfx_filter_horiz_zoom_mult;
+       float my = currprefs.gf[1].gfx_filter_vert_zoom_mult;
        int forced = 0;
 
        if (!hwsprite)
@@ -827,9 +829,9 @@ static void mouseupdate(struct AmigaMonitor *mon)
        if (!currprefs.gfx_api)
                return;
        if (currprefs.gf[1].gfx_filter_autoscale == RTG_MODE_CENTER) {
-               D3D_setcursor(mon->monitor_id, x, y, WIN32GFX_GetWidth(mon), WIN32GFX_GetHeight(mon), cursorvisible, mon->scalepicasso == 2);
+               D3D_setcursor(mon->monitor_id, x, y, WIN32GFX_GetWidth(mon), WIN32GFX_GetHeight(mon), mx, my, cursorvisible, mon->scalepicasso == 2);
        } else {
-               D3D_setcursor(mon->monitor_id, x, y, state->Width, state->Height, cursorvisible, false);
+               D3D_setcursor(mon->monitor_id, x, y, state->Width, state->Height, mx, my, cursorvisible, false);
        }
 }
 
@@ -2628,7 +2630,7 @@ static void inituaegfx(TrapContext *ctx, uaecptr ABI)
        flags |= BIF_NOMEMORYMODEMIX;
        flags |= BIF_GRANTDIRECTACCESS;
        flags &= ~BIF_HARDWARESPRITE;
-       if (currprefs.gfx_api && D3D_goodenough () > 0 && D3D_setcursor(0, -1, -1, -1, -1, false, false) && USE_HARDWARESPRITE && currprefs.rtg_hardwaresprite) {
+       if (currprefs.gfx_api && D3D_goodenough () > 0 && D3D_setcursor && D3D_setcursor(0, -1, -1, -1, -1, 0, 0, false, false) && USE_HARDWARESPRITE && currprefs.rtg_hardwaresprite) {
                hwsprite = 1;
                flags |= BIF_HARDWARESPRITE;
                write_log (_T("P96: Hardware sprite support enabled\n"));
index e2b22b10576fc5a61a21905d553d50737721f4d9..5bac7d2504eb417904fc8f059b775edcbede62d8 100644 (file)
@@ -1542,58 +1542,6 @@ void flush_clear_screen (struct vidbuffer *vb)
        }
 }
 
-static void DX_Blit96(struct AmigaMonitor *mon, int x, int y, int w, int h)
-{
-       struct picasso96_state_struct *state = &picasso96_state[mon->monitor_id];
-       RECT dr, sr;
-
-       picasso_offset_x = 0;
-       picasso_offset_y = 0;
-       picasso_offset_mx = 1.0;
-       picasso_offset_my = 1.0;
-       if (mon->scalepicasso) {
-               int srcratio, dstratio;
-               int srcwidth, srcheight;
-
-               if (mon->scalepicasso < 0 || mon->scalepicasso > 1) {
-                       srcwidth = state->Width;
-                       srcheight = state->Height;
-               } else {
-                       srcwidth = mon->currentmode.native_width;
-                       srcheight = mon->currentmode.native_height;
-               }
-
-               SetRect (&sr, 0, 0, state->Width, state->Height);
-               if (currprefs.win32_rtgscaleaspectratio < 0) {
-                       // automatic
-                       srcratio = state->Width * ASPECTMULT / state->Height;
-                       dstratio = srcwidth * ASPECTMULT / srcheight;
-               } else if (currprefs.win32_rtgscaleaspectratio == 0) {
-                       // none
-                       srcratio = dstratio = 0;
-               } else {
-                       // manual
-                       srcratio = currprefs.win32_rtgscaleaspectratio;
-                       dstratio = srcwidth * ASPECTMULT / srcheight;
-               }
-               if (srcratio == dstratio) {
-                       SetRect (&dr, 0, 0, srcwidth, srcheight);
-               } else if (srcratio > dstratio) {
-                       int yy = srcheight - srcheight * dstratio / srcratio;
-                       SetRect (&dr, 0, yy / 2, srcwidth, srcheight - yy / 2);
-                       picasso_offset_y = yy / 2;
-               } else {
-                       int xx = srcwidth - srcwidth * srcratio / dstratio;
-                       SetRect (&dr, xx / 2, 0,srcwidth - xx / 2, srcheight);
-                       picasso_offset_x = xx / 2;
-               }
-               picasso_offset_mx = (float)state->Width / (dr.right - dr.left);
-               picasso_offset_my = (float)state->Height / (dr.bottom - dr.top);
-       } else {
-               SetRect (&sr, x, y, x + w, y + h);
-       }
-}
-
 void getrtgfilterrect2(int monid, RECT *sr, RECT *dr, RECT *zr, int dst_width, int dst_height)
 {
        struct AmigaMonitor *mon = &AMonitors[monid];
@@ -1611,6 +1559,14 @@ void getrtgfilterrect2(int monid, RECT *sr, RECT *dr, RECT *zr, int dst_width, i
 
        if (!ad->picasso_on)
                return;
+
+       if (currprefs.gf[1].gfx_filter_horiz_zoom_mult > 0) {
+               picasso_offset_mx *= currprefs.gf[1].gfx_filter_horiz_zoom_mult * currprefs.gf[1].gfx_filter_horiz_zoom / 1000.0f;
+       }
+       if (currprefs.gf[1].gfx_filter_vert_zoom_mult > 0) {
+               picasso_offset_my *= currprefs.gf[1].gfx_filter_vert_zoom_mult * currprefs.gf[1].gfx_filter_vert_zoom / 1000.0f;
+       }
+
        if (!mon->scalepicasso)
                return;
 
@@ -1864,8 +1820,18 @@ static void update_gfxparams(struct AmigaMonitor *mon)
 #ifdef PICASSO96
        mon->currentmode.vsync = 0;
        if (mon->screen_is_picasso) {
-               mon->currentmode.current_width = (int)(state->Width * currprefs.rtg_horiz_zoom_mult);
-               mon->currentmode.current_height = (int)(state->Height * currprefs.rtg_vert_zoom_mult);
+               float mx = 1.0;
+               float my = 1.0;
+               if (currprefs.gf[1].gfx_filter_horiz_zoom_mult > 0) {
+                       mx *= currprefs.gf[1].gfx_filter_horiz_zoom_mult;
+               }
+               if (currprefs.gf[1].gfx_filter_vert_zoom_mult > 0) {
+                       my *= currprefs.gf[1].gfx_filter_vert_zoom_mult;
+               }
+               mx = mx + mx * currprefs.gf[1].gfx_filter_horiz_zoom / 1000.0f;
+               my = my + my * currprefs.gf[1].gfx_filter_vert_zoom / 1000.0f;
+               mon->currentmode.current_width = (int)(state->Width * currprefs.rtg_horiz_zoom_mult * mx);
+               mon->currentmode.current_height = (int)(state->Height * currprefs.rtg_vert_zoom_mult * my);
                currprefs.gfx_apmode[1].gfx_interlaced = false;
                if (currprefs.win32_rtgvblankrate == 0) {
                        currprefs.gfx_apmode[1].gfx_refreshrate = currprefs.gfx_apmode[0].gfx_refreshrate;
@@ -2107,12 +2073,12 @@ void graphics_reset(bool forced)
        }
 }
 
-void WIN32GFX_DisplayChangeRequested (int mode)
+void WIN32GFX_DisplayChangeRequested(int mode)
 {
        display_change_requested = mode;
 }
 
-int check_prefs_changed_gfx (void)
+int check_prefs_changed_gfx(void)
 {
        int c = 0;
        bool monitors[MAX_AMIGAMONITORS];
@@ -2133,6 +2099,13 @@ int check_prefs_changed_gfx (void)
                        c |= c2;
                        monitors[i] = true;
                }
+               if (WIN32GFX_IsPicassoScreen(&AMonitors[i])) {
+                       struct gfx_filterdata *gfc = &changed_prefs.gf[1];
+                       if (gfc->changed) {
+                               gfc->changed = false;
+                               c |= 16;
+                       }
+               }
        }
        monitors[0] = true;
 
index d87f8b6e9aaabfe906fc2f746a76682a48def2fb..44aa3bf5d5c96cf25bac10fcd4dd9857db1466b9 100644 (file)
@@ -19583,7 +19583,7 @@ static void enable_for_hw3ddlg (HWND hDlg)
 {
        int v = workprefs.gf[filter_nativertg].gfx_filter ? TRUE : FALSE;
        int scalemode = workprefs.gf[filter_nativertg].gfx_filter_autoscale;
-       int vv = FALSE, vv2 = FALSE, vv3 = FALSE;
+       int vv = FALSE, vv2 = FALSE, vv3 = FALSE, vv4 = FALSE;
        int as = FALSE;
        struct uae_filter *uf;
        int i, isfilter;
@@ -19599,14 +19599,18 @@ static void enable_for_hw3ddlg (HWND hDlg)
                }
                i++;
        }
-       if (v && uf->intmul)
+       if (v && uf->intmul) {
                vv = TRUE;
-       if (v && uf->yuv)
+       }
+       if (v && uf->yuv) {
                vv2 = TRUE;
-       if (workprefs.gfx_api)
-               v = vv = vv2 = vv3 = TRUE;
-       if (filter_nativertg)
-               v = FALSE;
+       }
+       if (workprefs.gfx_api) {
+               v = vv = vv2 = vv3 = vv4 = TRUE;
+       }
+       if (filter_nativertg) {
+               vv4 = FALSE;
+       }
        if (scalemode == AUTOSCALE_STATIC_AUTO || scalemode == AUTOSCALE_STATIC_NOMINAL || scalemode == AUTOSCALE_STATIC_MAX)
                as = TRUE;
 
@@ -19614,8 +19618,8 @@ static void enable_for_hw3ddlg (HWND hDlg)
        ew(hDlg, IDC_FILTERVZMULT, v && !as);
        ew(hDlg, IDC_FILTERHZ, v);
        ew(hDlg, IDC_FILTERVZ, v);
-       ew(hDlg, IDC_FILTERHO, v);
-       ew(hDlg, IDC_FILTERVO, v);
+       ew(hDlg, IDC_FILTERHO, v && vv4);
+       ew(hDlg, IDC_FILTERVO, v && vv4);
        ew(hDlg, IDC_FILTERSLR, vv3);
        ew(hDlg, IDC_FILTERXL, vv2);
        ew(hDlg, IDC_FILTERXLV, vv2);
@@ -20540,10 +20544,12 @@ static INT_PTR CALLBACK hw3dDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM
                                        break;
                                case IDC_FILTERHZMULT:
                                        currprefs.gf[filter_nativertg].gfx_filter_horiz_zoom_mult = workprefs.gf[filter_nativertg].gfx_filter_horiz_zoom_mult = getfiltermult (hDlg, IDC_FILTERHZMULT);
+                                       workprefs.gf[filter_nativertg].changed = true;
                                        updatedisplayarea(-1);
                                        break;
                                case IDC_FILTERVZMULT:
                                        currprefs.gf[filter_nativertg].gfx_filter_vert_zoom_mult = workprefs.gf[filter_nativertg].gfx_filter_vert_zoom_mult = getfiltermult (hDlg, IDC_FILTERVZMULT);
+                                       workprefs.gf[filter_nativertg].changed = true;
                                        updatedisplayarea(-1);
                                        break;
                                case IDC_FILTERASPECT:
@@ -20613,20 +20619,30 @@ static INT_PTR CALLBACK hw3dDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM
                                }
                        } else {
                                if (h == hz) {
-                                       fd->gfx_filter_horiz_zoom = fdwp->gfx_filter_horiz_zoom = (float)SendMessage (hz, TBM_GETPOS, 0, 0);
+                                       fd->gfx_filter_horiz_zoom = (float)SendMessage (hz, TBM_GETPOS, 0, 0);
                                        if (fdwp->gfx_filter_keep_aspect) {
-                                               fd->gfx_filter_vert_zoom = fdwp->gfx_filter_vert_zoom = currprefs.gf[filter_nativertg].gfx_filter_horiz_zoom;
+                                               fd->gfx_filter_vert_zoom = currprefs.gf[filter_nativertg].gfx_filter_horiz_zoom;
                                                xSendDlgItemMessage (hDlg, IDC_FILTERVZ, TBM_SETPOS, TRUE, (int)fdwp->gfx_filter_vert_zoom);
                                        }
                                } else if (h == vz) {
-                                       fd->gfx_filter_vert_zoom = fdwp->gfx_filter_vert_zoom = (float)SendMessage (vz, TBM_GETPOS, 0, 0);
+                                       fd->gfx_filter_vert_zoom = (float)SendMessage (vz, TBM_GETPOS, 0, 0);
                                        if (fdwp->gfx_filter_keep_aspect) {
-                                               fd->gfx_filter_horiz_zoom = fdwp->gfx_filter_horiz_zoom = currprefs.gf[filter_nativertg].gfx_filter_vert_zoom;
+                                               fd->gfx_filter_horiz_zoom = currprefs.gf[filter_nativertg].gfx_filter_vert_zoom;
                                                xSendDlgItemMessage (hDlg, IDC_FILTERHZ, TBM_SETPOS, TRUE, (int)fdwp->gfx_filter_horiz_zoom);
                                        }
                                }
-                               fd->gfx_filter_horiz_offset = fdwp->gfx_filter_horiz_offset = (float)SendMessage (GetDlgItem (hDlg, IDC_FILTERHO), TBM_GETPOS, 0, 0);
-                               fd->gfx_filter_vert_offset = fdwp->gfx_filter_vert_offset = (float)SendMessage (GetDlgItem (hDlg, IDC_FILTERVO), TBM_GETPOS, 0, 0);
+                               if (fd->gfx_filter_horiz_zoom != fdwp->gfx_filter_horiz_zoom) {
+                                       fdwp->gfx_filter_horiz_zoom = fd->gfx_filter_horiz_zoom;
+                                       fdwp->changed = true;
+                               }
+                               if (fd->gfx_filter_vert_zoom != fdwp->gfx_filter_vert_zoom) {
+                                       fdwp->gfx_filter_vert_zoom = fd->gfx_filter_vert_zoom;
+                                       fdwp->changed = true;
+                               }
+                               fdwp->gfx_filter_horiz_offset = (float)SendMessage (GetDlgItem (hDlg, IDC_FILTERHO), TBM_GETPOS, 0, 0);
+                               fdwp->gfx_filter_vert_offset = (float)SendMessage(GetDlgItem(hDlg, IDC_FILTERVO), TBM_GETPOS, 0, 0);
+                               fd->gfx_filter_horiz_offset = fdwp->gfx_filter_horiz_offset;
+                               fd->gfx_filter_vert_offset = fdwp->gfx_filter_vert_offset;
                                SetDlgItemInt (hDlg, IDC_FILTERHOV, (int)workprefs.gf[filter_nativertg].gfx_filter_horiz_offset, TRUE);
                                SetDlgItemInt (hDlg, IDC_FILTERVOV, (int)workprefs.gf[filter_nativertg].gfx_filter_vert_offset, TRUE);
                                SetDlgItemInt (hDlg, IDC_FILTERHZV, (int)workprefs.gf[filter_nativertg].gfx_filter_horiz_zoom, TRUE);