]> git.unchartedbackwaters.co.uk Git - francis/winuae.git/commitdiff
Fix surface limit check.
authorToni Wilen <twilen@winuae.net>
Sat, 1 Apr 2023 08:01:47 +0000 (11:01 +0300)
committerToni Wilen <twilen@winuae.net>
Sat, 1 Apr 2023 08:01:47 +0000 (11:01 +0300)
gfxboard.cpp
od-win32/direct3d.cpp
od-win32/direct3d.h
od-win32/direct3d11.cpp
od-win32/gdirender.cpp
od-win32/picasso96_win.cpp
od-win32/picasso96_win.h
od-win32/win32_scaler.cpp
od-win32/win32gfx.cpp

index 0388505f55eeebf3fc19228f905b7ed159cae9f3..a3e284111a6cc48bedaff3ea0ab61e7660104994 100644 (file)
@@ -712,14 +712,14 @@ void video_blit_memtoscreen(int x, int y, int y1, int y2, int w, int h)
                                if (gb->gfxboard_surface) {
                                        struct picasso_vidbuf_description *vidinfo = &picasso_vidinfo[gb->monitor_id];
                                        if (w != gb->width_redraw || h != gb->height_redraw) {
-                                               for (int y = 0; y < vidinfo->height; y++) {
+                                               for (int y = 0; y < vidinfo->maxheight; y++) {
                                                        uae_u8 *d = gb->gfxboard_surface + y * vidinfo->rowbytes;
                                                        if (y < h) {
-                                                               if (vidinfo->width > w) {
-                                                                       memset(d + w * vidinfo->pixbytes, 0, (vidinfo->width - w) * vidinfo->pixbytes);
+                                                               if (vidinfo->maxwidth > w) {
+                                                                       memset(d + w * vidinfo->pixbytes, 0, (vidinfo->maxwidth - w) * vidinfo->pixbytes);
                                                                }
                                                        } else {
-                                                               memset(d, 0, vidinfo->width * vidinfo->pixbytes);
+                                                               memset(d, 0, vidinfo->maxwidth * vidinfo->pixbytes);
                                                        }
                                                }
                                                gb->width_redraw = w;
@@ -727,10 +727,10 @@ void video_blit_memtoscreen(int x, int y, int y1, int y2, int w, int h)
                                                y1 = 0;
                                                y2 = h;
                                        }
-                                       for (int yy = y1; yy < y2 && yy < vidinfo->height; yy++) {
+                                       for (int yy = y1; yy < y2 && yy < vidinfo->maxheight; yy++) {
                                                uae_u8 *d = gb->gfxboard_surface + yy * vidinfo->rowbytes;
                                                uae_u8 *s = getpcembuffer32(x, y, yy);
-                                               int ww = w > vidinfo->width ? vidinfo->width : w;
+                                               int ww = w > vidinfo->maxwidth ? vidinfo->maxwidth : w;
                                                memcpy(d, s, ww * vidinfo->pixbytes);
                                        }
                                }
index 1101d1b4cae6fc11e41a0325d72c08006c5950da..a105e0c8b2908be6609671964cae08efe7e21c09 100644 (file)
@@ -3760,7 +3760,7 @@ static void xD3D_unlocktexture(int monid, int y_start, int y_end)
        d3d->fulllocked = 0;
 }
 
-static uae_u8 *xD3D_locktexture (int monid, int *pitch, int *height, int fullupdate)
+static uae_u8 *xD3D_locktexture (int monid, int *pitch, int *width, int *height, int fullupdate)
 {
        struct d3dstruct *d3d = &d3ddata[monid];
        D3DLOCKED_RECT lock;
@@ -3823,6 +3823,8 @@ static uae_u8 *xD3D_locktexture (int monid, int *pitch, int *height, int fullupd
        *pitch = lock.Pitch;
        if (height)
                *height = d3d->tin_h;
+       if (width)
+               *width = d3d->tin_w;
        return (uae_u8*)lock.pBits;
 }
 
index 63e5905e0f4e56dcf354e7977d4df0cea649d3b9..559e860ba2cf5589e61b197102757198384f70a8 100644 (file)
@@ -14,7 +14,7 @@ extern void(*D3D_refresh)(int);
 extern bool(*D3D_renderframe)(int, int,bool);
 extern void(*D3D_showframe)(int);
 extern void(*D3D_showframe_special)(int, int);
-extern uae_u8* (*D3D_locktexture)(int, int*, int*, int);
+extern uae_u8 *(*D3D_locktexture)(int, int*, int*, int*, int);
 extern void(*D3D_unlocktexture)(int, int, int);
 extern void(*D3D_flushtexture)(int, int miny, int maxy);
 extern void(*D3D_guimode)(int, int);
@@ -24,7 +24,7 @@ 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, float mx, float my, bool visible, bool noscale);
-extern uae_u8(*D3D_setcursorsurface)(int, int *pitch);
+extern uae_u8 *(*D3D_setcursorsurface)(int, int *pitch);
 extern float(*D3D_getrefreshrate)(int);
 extern void(*D3D_restore)(int, bool);
 extern void(*D3D_resize)(int, int);
index 4ede01025270d5dc2af1eb6cfee36a46971c4afa..e449772265bc7ef12a708aece8698310f22b3322 100644 (file)
@@ -52,7 +52,7 @@ void(*D3D_refresh)(int);
 bool(*D3D_renderframe)(int, int,bool);
 void(*D3D_showframe)(int);
 void(*D3D_showframe_special)(int, int);
-uae_u8* (*D3D_locktexture)(int, int*, int*, int);
+uae_u8 *(*D3D_locktexture)(int, int*, int*, int*, int);
 void (*D3D_unlocktexture)(int, int, int);
 void (*D3D_flushtexture)(int, int miny, int maxy);
 void (*D3D_guimode)(int, int);
@@ -62,7 +62,7 @@ void (*D3D_clear)(int);
 int (*D3D_canshaders)(void);
 int (*D3D_goodenough)(void);
 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);
+uae_u8 *(*D3D_setcursorsurface)(int, int *pitch);
 float (*D3D_getrefreshrate)(int);
 void(*D3D_restore)(int, bool);
 void(*D3D_resize)(int, int);
@@ -4956,7 +4956,7 @@ static bool xD3D11_alloctexture(int monid, int w, int h)
        return true;
 }
 
-static uae_u8 *xD3D11_locktexture(int monid, int *pitch, int *height, int fullupdate)
+static uae_u8 *xD3D11_locktexture(int monid, int *pitch, int *width, int *height, int fullupdate)
 {
        struct d3d11struct *d3d = &d3d11data[monid];
 
@@ -4975,6 +4975,8 @@ static uae_u8 *xD3D11_locktexture(int monid, int *pitch, int *height, int fullup
        *pitch = map.RowPitch;
        if (height)
                *height = d3d->m_bitmapHeight;
+       if (width)
+               *width = d3d->m_bitmapWidth;
        d3d->texturelocked++;
        return (uae_u8*)map.pData;
 }
index 6bc8b116488f91f5bedf9039e288e760300101cd..fb2195562321fcdbe5947a4aa55823b432ee479c 100644 (file)
@@ -280,13 +280,15 @@ static void gdi_guimode(int monid, int guion)
 {
 }
 
-static uae_u8 *gdi_locktexture(int monid, int *pitch, int *height, int fullupdate)
+static uae_u8 *gdi_locktexture(int monid, int *pitch, int *width, int *height, int fullupdate)
 {
        struct gdistruct *gdi = &gdidata[monid];
        if (gdi->bm.bits) {
                *pitch = gdi->bm.pitch;
                if (height)
                        *height = gdi->bm.height;
+               if (width)
+                       *width = gdi->bm.width;
                return (uae_u8*)gdi->bm.bits;
        }
        return NULL;
index 8ba3430e0c5c0dee058cc9006508a567e962f294..b273efb5859ebcabf002b98e7d55d83a2405085c 100644 (file)
@@ -5597,11 +5597,11 @@ static void picasso_flushpixels(int index, uae_u8 *src, int off, bool render)
                        dst = dstp;
 
                        // safety check
-                       if (pwidth > vidinfo->rowbytes / vidinfo->pixbytes) {
-                               pwidth = vidinfo->rowbytes / vidinfo->pixbytes;
+                       if (pwidth > vidinfo->maxwidth) {
+                               pwidth = vidinfo->maxwidth;
                        }
-                       if (pheight > vidinfo->height) {
-                               pheight = vidinfo->height;
+                       if (pheight > vidinfo->maxheight) {
+                               pheight = vidinfo->maxheight;
                        }
 
                        if (!split && vidinfo->rtg_clear_flag) {
index d7fd3d192ee1826ea6392ba25ee49a795d7a95ca..16852068c5b64687c7507ed460ba81e9f3477186 100644 (file)
@@ -667,6 +667,7 @@ extern void picasso_invalidate(int monid, int x, int y, int w, int h);
 struct picasso_vidbuf_description {
        int width, height, depth;
        int rowbytes, pixbytes, offset;
+    int maxwidth, maxheight; // allocated surface/texture size
        int extra_mem; /* nonzero if there's a second buffer that must be updated */
        uae_u32 rgbformat;
        uae_u32 selected_rgbformat;
index f034f139311ddcb1fb06f9bae93652e3ffd0a3ac..13b5e3060d40a5522b1eb446ac3d9266975f78bc 100644 (file)
@@ -1002,7 +1002,7 @@ void S2X_render(int monid, int y_start, int y_end)
        int aw, ah, aws, ahs;
        uae_u8 *dptr, *enddptr, *sptr, *endsptr;
        int ok = 0;
-       int pitch, surf_height;
+       int pitch, surf_height, surf_width;
        uae_u8 *surfstart;
 
        aw = amiga_width;
@@ -1023,7 +1023,7 @@ void S2X_render(int monid, int y_start, int y_end)
 
        if (D3D_restore)
                D3D_restore(monid, true);
-       surfstart = D3D_locktexture(monid, &pitch, &surf_height, y_start < -1 ? -1 : (y_start < 0 ? 1 : 0));
+       surfstart = D3D_locktexture(monid, &pitch, &surf_width, &surf_height, y_start < -1 ? -1 : (y_start < 0 ? 1 : 0));
        if (surfstart == NULL) {
                return;
        }
index 1f816df3c2f4dde2026e60e012de5d95bfa0e9a1..72f083dc65e8cc4b933d36a1c999d6f47efcdfd3 100644 (file)
@@ -1455,7 +1455,7 @@ bool lockscr3d(struct vidbuffer *vb)
        struct AmigaMonitor *mon = &AMonitors[vb->monitor_id];
        if (mon->currentmode.flags & DM_D3D) {
                if (!(mon->currentmode.flags & DM_SWSCALE)) {
-                       vb->bufmem = D3D_locktexture(vb->monitor_id, &vb->rowbytes, NULL, false);
+                       vb->bufmem = D3D_locktexture(vb->monitor_id, &vb->rowbytes, NULL, NULL, false);
                        if (vb->bufmem) 
                                return true;
                }
@@ -1492,7 +1492,7 @@ int lockscr(struct vidbuffer *vb, bool fullupdate, bool first, bool skip)
                        ret = 1;
                } else {
                        ret = 0;
-                       vb->bufmem = D3D_locktexture(vb->monitor_id, &vb->rowbytes, NULL, skip ? -1 : (fullupdate ? 1 : 0));
+                       vb->bufmem = D3D_locktexture(vb->monitor_id, &vb->rowbytes, NULL, NULL, skip ? -1 : (fullupdate ? 1 : 0));
                        if (vb->bufmem) {
                                if (first)
                                        init_row_map();
@@ -1661,9 +1661,7 @@ void getrtgfilterrect2(int monid, RECT *sr, RECT *dr, RECT *zr, int *mode, int d
 static uae_u8 *gfx_lock_picasso2(int monid, bool fullupdate)
 {
        struct picasso_vidbuf_description *vidinfo = &picasso_vidinfo[monid];
-       int pitch;
-       uae_u8 *p = D3D_locktexture(monid, &pitch, NULL, fullupdate);
-       vidinfo->rowbytes = pitch;
+       uae_u8 *p = D3D_locktexture(monid, &vidinfo->rowbytes, &vidinfo->maxwidth, &vidinfo->maxheight, fullupdate);
        return p;
 }
 uae_u8 *gfx_lock_picasso(int monid, bool fullupdate)