]> git.unchartedbackwaters.co.uk Git - francis/winuae.git/commitdiff
Check texture size also in render backends, if already same, don't reallocate.
authorToni Wilen <twilen@winuae.net>
Tue, 23 Jan 2024 18:50:25 +0000 (20:50 +0200)
committerToni Wilen <twilen@winuae.net>
Tue, 23 Jan 2024 18:50:25 +0000 (20:50 +0200)
od-win32/direct3d.cpp
od-win32/direct3d11.cpp
od-win32/gdirender.cpp
od-win32/win32gfx.cpp

index a7f2f98c0cd90f12004ace86d44e26322fda5afe..13d9db9b050950f4764d59d785d3c0368f84d100 100644 (file)
@@ -202,6 +202,7 @@ struct d3dstruct
        int ledwidth, ledheight;
        int max_texture_w, max_texture_h;
        int tin_w, tin_h, tout_w, tout_h, window_h, window_w;
+       int tino_w, tino_h;
        int t_depth, dmult, dmultxh, dmultxv, dmode;
        int required_sl_texture_w, required_sl_texture_h;
        int vsync2, guimode, maxscanline, variablerefresh;
@@ -3097,9 +3098,14 @@ static bool xD3D_alloctexture (int monid, int w, int h)
        struct d3dstruct *d3d = &d3ddata[monid];
 
        if (w < 0 || h < 0) {
-               return d3d->texture1 != NULL;
+               if (d3d->tino_w == -w && d3d->tino_h == -h && d3d->texture1) {
+                       return true;
+               }
+               return false;
        }
 
+       d3d->tino_w = w;
+       d3d->tino_h = h;
        d3d->tin_w = w * d3d->dmult;
        d3d->tin_h = h * d3d->dmult;
 
index add203d1ceb3de4b23338347186a71dd4edab90b..1c61559a6b8cbb8a098942d2f9b0b1f040a4ce6f 100644 (file)
@@ -3424,19 +3424,13 @@ static bool xD3D11_initvals(HWND ahwnd, int monid, int w_w, int w_h, int t_w, in
        if (d3d->m_screenWidth != w_w || d3d->m_screenHeight != w_h) {
                changed = true;
        }
-       if (doalloc && !changed && (d3d->m_bitmapWidth != t_w || d3d->m_bitmapHeight != t_h || d3d->dmultxh != mmulth || d3d->dmultxv != mmultv)) {
-               d3d->m_bitmapWidth = t_w;
-               d3d->m_bitmapHeight = t_h;
-               d3d->dmultxh = mmulth;
-               d3d->dmultxv = mmultv;
-               D3D_alloctexture(monid, t_w, t_h);
-       }
-       d3d->m_bitmapWidth = t_w;
-       d3d->m_bitmapHeight = t_h;
        d3d->m_screenWidth = w_w;
        d3d->m_screenHeight = w_h;
        d3d->dmultxh = mmulth;
        d3d->dmultxv = mmultv;
+       if (d3d->m_device) {
+               target_graphics_buffer_update(monid);
+       }
 
        return changed;
 }
@@ -5037,8 +5031,14 @@ static bool xD3D11_alloctexture(int monid, int w, int h)
        struct d3d11struct *d3d = &d3d11data[monid];
        bool v;
 
+       if (w == 0 || h == 0) {
+               return false;
+       }
        if (w < 0 || h < 0) {
-               return d3d->texture2d != NULL;
+               if (d3d->m_bitmapWidth == -w && d3d->m_bitmapHeight == -h && d3d->texture2d) {
+                       return true;
+               }
+               return false;
        }
 
        recheck(d3d, monid);
@@ -5336,12 +5336,14 @@ static void updatecursorsurface(int monid)
        int cy = (int)d3d->cursor_y;
        int width = sp->width;
        int height = sp->height;
+       int bw = d3d->m_bitmapWidth;
+       int bh = d3d->m_bitmapHeight;
 
        if (sp->texture == NULL) {
                return;
        }
 
-       if (sp->updated && cx >= 0 && cy >= 0 && cx + width <= d3d->m_bitmapWidth && cy + height <= d3d->m_bitmapHeight) {
+       if (sp->updated && cx >= 0 && cy >= 0 && cx + width <= bw && cy + height <= bh) {
                return;
        }
 
@@ -5356,14 +5358,14 @@ static void updatecursorsurface(int monid)
                for (int h = 0; h < sp->height; h++) {
                        int w = width;
                        int x = 0;
-                       if (cx + w > d3d->m_bitmapWidth) {
-                               w -= (cx + w) - d3d->m_bitmapWidth;
+                       if (cx + w > bw) {
+                               w -= (cx + w) - bw;
                        }
                        if (cx < 0) {
                                x = -cx;
                                w -= -cx;
                        }
-                       if (w <= 0 || cy + h > d3d->m_bitmapHeight) {
+                       if (w <= 0 || cy + h > bh) {
                                memset(b, 0, width * 4);
                        } else {
                                if (x > 0) {
@@ -5379,7 +5381,7 @@ static void updatecursorsurface(int monid)
                }
                d3d->m_deviceContext->Unmap(d3d->hwsprite.texture, 0);
 
-               if (cx >= 0 && cy >= 0 && cx + width <= d3d->m_bitmapWidth && cy + height <= d3d->m_bitmapHeight) {
+               if (cx >= 0 && cy >= 0 && cx + width <= bw && cy + height <= bh) {
                        sp->updated = true;
                }
        }
index 31167cfb8ccb858cbe9632c964943b76887c98e4..c4452d950045e829fa5ef9b16a3cb37e17d432be 100644 (file)
@@ -234,7 +234,10 @@ static bool gdi_alloctexture(int monid, int w, int h)
        struct gdistruct *gdi = &gdidata[monid];
 
        if (w < 0 || h < 0) { 
-               return gdi->hdc != NULL;
+               if (gdi->bm.width == -w && gdi->bm.height == -h && gdi->hdc) {
+                       return true;
+               }
+               return false;
        }
 
        freetexture(monid);
index 3d3f0bad7c5fc0e7add58eb7dc7975d6764e6eb0..6eaa6aeb5d04dcb5bdbf73d1435b5b5d27eea6c6 100644 (file)
@@ -4161,7 +4161,7 @@ bool target_graphics_buffer_update(int monid)
                h = vb->outheight;
        }
        
-       if (oldtex_w[monid] == w && oldtex_h[monid] == h && oldtex_rtg[monid] == mon->screen_is_picasso && D3D_alloctexture(mon->monitor_id, -1, -1)) {
+       if (oldtex_w[monid] == w && oldtex_h[monid] == h && oldtex_rtg[monid] == mon->screen_is_picasso && D3D_alloctexture(mon->monitor_id, -w, -h)) {
                osk_setup(monid, -2);
                return false;
        }