From: Toni Wilen Date: Sun, 13 Aug 2017 13:04:19 +0000 (+0300) Subject: Completely skip PC resolutions that don't fit in VRAM, even in 256 color mode. X-Git-Tag: 3600~124 X-Git-Url: https://git.unchartedbackwaters.co.uk/w/?a=commitdiff_plain;h=402f83ec89831d20739cfd09678ca49b6ffb60e5;p=francis%2Fwinuae.git Completely skip PC resolutions that don't fit in VRAM, even in 256 color mode. --- diff --git a/od-win32/picasso96_win.cpp b/od-win32/picasso96_win.cpp index a8607bb8..3b11ef7c 100644 --- a/od-win32/picasso96_win.cpp +++ b/od-win32/picasso96_win.cpp @@ -42,6 +42,7 @@ #define USE_HARDWARESPRITE 1 #define P96TRACING_ENABLED 0 +#define P96TRACING_LEVEL 0 #define P96TRACING_SETUP_ENABLED 0 #define P96SPRTRACING_ENABLED 0 @@ -654,6 +655,7 @@ static void setupcursor (void) return; gfx_lock (); setupcursor_needed = 1; + LPDIRECT3DTEXTURE9 cursorsurfaced3d = D3D_getcursorsurface(); if (cursorsurfaced3d) { if (SUCCEEDED (hr = cursorsurfaced3d->LockRect (0, &locked, NULL, 0))) { dptr = (uae_u8*)locked.pBits; @@ -2270,6 +2272,11 @@ static void picasso96_alloc2 (TrapContext *ctx) i++; continue; } + // Not even 256 color mode fits in VRAM? Ignore it completely. + if (DisplayModes[i].res.width * DisplayModes[i].res.height > gfxmem_bank.allocated_size - 256) { + i++; + continue; + } j = i; size += PSSO_LibResolution_sizeof; while (missmodes[misscnt * 2] == 0) @@ -2443,9 +2450,10 @@ static void inituaegfx(TrapContext *ctx, uaecptr ABI) inituaegfxfuncs(ctx, uaegfx_rom, ABI); } -static void addmode(TrapContext *ctx, uaecptr AmigaBoardInfo, uaecptr *amem, struct LibResolution *res, int w, int h, const TCHAR *name, int display, int *unkcnt) +static bool addmode(TrapContext *ctx, uaecptr AmigaBoardInfo, uaecptr *amem, struct LibResolution *res, int w, int h, const TCHAR *name, int display, int *unkcnt) { int depth; + bool added = false; if (display > 0) { res->DisplayID = 0x51000000 + display * 0x100000; @@ -2468,11 +2476,13 @@ static void addmode(TrapContext *ctx, uaecptr AmigaBoardInfo, uaecptr *amem, str for (depth = 8; depth <= 32; depth++) { if (!p96depth (depth)) continue; - if(gfxmem_bank.allocated_size >= w * h * (depth + 7) / 8) { + if(gfxmem_bank.allocated_size >= w * h * ((depth + 7) / 8)) { FillBoardInfo(ctx, *amem, res, w, h, depth); *amem += PSSO_ModeInfo_sizeof; + added = true; } } + return added; } /**************************************** @@ -2484,7 +2494,7 @@ static void addmode(TrapContext *ctx, uaecptr AmigaBoardInfo, uaecptr *amem, str static uae_u32 REGPARAM2 picasso_InitCard (TrapContext *ctx) { int LibResolutionStructureCount = 0; - int i, j, unkcnt, cnt; + int i, unkcnt, cnt; uaecptr amem; uaecptr AmigaBoardInfo = trap_get_areg(ctx, 0); @@ -2500,24 +2510,28 @@ static uae_u32 REGPARAM2 picasso_InitCard (TrapContext *ctx) unkcnt = cnt = 0; while (newmodes[i].depth >= 0) { struct LibResolution res = { 0 }; - TCHAR *s; - j = i; - addmode(ctx, AmigaBoardInfo, &amem, &res, newmodes[i].res.width, newmodes[i].res.height, NULL, 0, &unkcnt); - s = au (res.Name); - write_log (_T("%2d: %08X %4dx%4d %s\n"), ++cnt, res.DisplayID, res.Width, res.Height, s); - xfree (s); - while (newmodes[i].depth >= 0 - && newmodes[i].res.width == newmodes[j].res.width - && newmodes[i].res.height == newmodes[j].res.height) - i++; + int j = i; + if (addmode(ctx, AmigaBoardInfo, &amem, &res, newmodes[i].res.width, newmodes[i].res.height, NULL, 0, &unkcnt)) { + TCHAR *s; + s = au (res.Name); + write_log (_T("%2d: %08X %4dx%4d %s\n"), ++cnt, res.DisplayID, res.Width, res.Height, s); + xfree (s); + while (newmodes[i].depth >= 0 + && newmodes[i].res.width == newmodes[j].res.width + && newmodes[i].res.height == newmodes[j].res.height) + i++; - LibResolutionStructureCount++; - CopyLibResolutionStructureU2A(ctx, &res, amem); + LibResolutionStructureCount++; + CopyLibResolutionStructureU2A(ctx, &res, amem); #if P96TRACING_ENABLED && P96TRACING_LEVEL > 1 - DumpLibResolutionStructurectx, (amem); + DumpLibResolutionStructure(ctx, amem); #endif - AmigaListAddTail(ctx, AmigaBoardInfo + PSSO_BoardInfo_ResolutionsList, amem); - amem += PSSO_LibResolution_sizeof; + AmigaListAddTail(ctx, AmigaBoardInfo + PSSO_BoardInfo_ResolutionsList, amem); + amem += PSSO_LibResolution_sizeof; + } else { + write_log (_T("--: %08X %4dx%4d Not enough VRAM\n"), res.DisplayID, res.Width, res.Height); + i++; + } } #if MULTIDISPLAY for (i = 0; Displays[i].name; i++) { @@ -2704,7 +2718,7 @@ static void init_picasso_screen (void) * This function is called whenever another ModeInfo has to be set. This * function simply sets up the CRTC and TS registers to generate the * timing used for that screen mode. You should not set the DAC, clocks -* or linear start adress. They will be set when appropriate by their +* or linear start address. They will be set when appropriate by their * own functions. */ static uae_u32 REGPARAM2 picasso_SetGC (TrapContext *ctx) diff --git a/od-win32/picasso96_win.h b/od-win32/picasso96_win.h index 9b4f9591..3385d831 100644 --- a/od-win32/picasso96_win.h +++ b/od-win32/picasso96_win.h @@ -141,7 +141,7 @@ struct BitMap struct Settings { uae_u32 BoardType; - /* a value discribing assignment to nth board local to boardtype + /* a value describing assignment to nth board local to boardtype * to be used for reassignment when boards are added or removed. */ uae_u16 LocalOrdering; uae_s16 LastSelected; @@ -536,7 +536,7 @@ struct picasso96_state_struct uae_u8 *HostAddress; /* Active screen address (PC-side) */ // host address is need because Windows // support NO direct access all the time to gfx Card - // everytime windows can remove your surface from card so the mainrender place + // every time windows can remove your surface from card so the mainrender place // must be in memory long XYOffset; };