diff options
| author | Jaroslav Hensl <[email protected]> | 2026-07-05 15:49:39 +0200 |
|---|---|---|
| committer | Jaroslav Hensl <[email protected]> | 2026-07-05 15:49:39 +0200 |
| commit | 718b3d51a1532fe1ba2e133cf76186f1a609d35e (patch) | |
| tree | 72cc067a44c590725f0a00bd76ccddb4e234848d | |
| parent | 0755608c75c2c0f70978c46ef757746583d6348d (diff) | |
| -rw-r--r-- | 3d_accel.h | 8 | ||||
| -rw-r--r-- | 3d_accel_svgadb.h | 66 | ||||
| -rw-r--r-- | async.h | 2 | ||||
| -rw-r--r-- | dddrv.c | 11 | ||||
| -rw-r--r-- | docs/svga-notes.txt | 22 | ||||
| -rw-r--r-- | makefile | 2 | ||||
| -rw-r--r-- | vmdisp9x.inf | 6 | ||||
| -rw-r--r-- | vxd_async.c | 35 | ||||
| -rw-r--r-- | vxd_halloc.c | 4 | ||||
| -rw-r--r-- | vxd_lib.c | 30 | ||||
| -rw-r--r-- | vxd_lib.h | 2 | ||||
| -rw-r--r-- | vxd_main.c | 3 | ||||
| -rw-r--r-- | vxd_strings.h | 2 | ||||
| -rw-r--r-- | vxd_svga.c | 807 | ||||
| -rw-r--r-- | vxd_svga.h | 7 | ||||
| -rw-r--r-- | vxd_svga_cb.c | 4 | ||||
| -rw-r--r-- | vxd_svga_mem.c | 126 | ||||
| -rw-r--r-- | vxd_vesa.c | 14 |
18 files changed, 539 insertions, 612 deletions
@@ -298,6 +298,10 @@ BOOL FBHDA_mode_query(DWORD index, FBHDA_mode_t *mode); */
#ifdef SVGA
+#define SVGA_REGION_ALLOC 0
+#define SVGA_REGION_USE_USERMEM 1
+#define SVGA_REGION_USE_FIXEDMEM 2
+
typedef struct SVGA_region_info
{
DWORD region_id;
@@ -310,6 +314,7 @@ typedef struct SVGA_region_info DWORD mob_pt_depth;
DWORD is_mob;
DWORD mobonly;
+ DWORD alloctype;
} SVGA_region_info_t;
typedef struct SVGA_CMB_status
@@ -330,8 +335,6 @@ typedef struct SVGA_DB_region {
DWORD pid;
SVGA_region_info_t info;
- DWORD pad1;
- DWORD pad2;
} SVGA_DB_region_t;
typedef struct SVGA_DB_context
@@ -413,6 +416,7 @@ void SVGA_fence_query(DWORD FBPTR ptr_fence_passed, DWORD FBPTR ptr_fence_last); void SVGA_fence_wait(DWORD fence_id);
BOOL SVGA_region_create(SVGA_region_info_t FBPTR rinfo);
void SVGA_region_free(SVGA_region_info_t FBPTR rinfo);
+int SVGA_region_focus(void FBPTR mem, DWORD w, DWORD h, DWORD bpp);
#define SVGA_QUERY_REGS 1
#define SVGA_QUERY_FIFO 2
diff --git a/3d_accel_svgadb.h b/3d_accel_svgadb.h new file mode 100644 index 0000000..2efd01b --- /dev/null +++ b/3d_accel_svgadb.h @@ -0,0 +1,66 @@ +/*****************************************************************************
+
+Copyright (c) 2026 Jaroslav Hensl <[email protected]>
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+
+*****************************************************************************/
+#ifndef __3D_ACCEL_SVGADB_H__INCLUDED__
+#define __3D_ACCEL_SVGADB_H__INCLUDED__
+
+#define BSTEP (sizeof(DWORD)*8)
+
+static inline DWORD map_lookup_and_set(DWORD *bitmap, DWORD start, DWORD max)
+{
+ DWORD i = start / BSTEP;
+ DWORD ii = start % BSTEP;
+
+ bitmap += i;
+
+ for(; i < max; i += BSTEP)
+ {
+ DWORD tmp = *bitmap;
+ if(tmp != 0) /* skip all-occupied double words */
+ {
+ for(; ii < BSTEP; ii++)
+ {
+ if(((tmp >> ii) & 0x1) != 0)
+ {
+ *bitmap &= ~((DWORD)1 << ii); /* set the bit in bitmap (to zero) */
+ return i+ii;
+ }
+ }
+ ii = 0;
+ }
+ bitmap++;
+ }
+
+ return max;
+}
+
+static inline void map_reset(DWORD *bitmap, DWORD id)
+{
+ DWORD i = id / BSTEP;
+ DWORD ii = id % BSTEP;
+
+ bitmap += i;
+ *bitmap |= ((DWORD)1 << ii);
+}
+
+#endif /* __3D_ACCEL_SVGADB_H__INCLUDED__ */
@@ -29,8 +29,10 @@ typedef void (*draw_callback_h)(blit_t *blit); BOOL async_blit_init(blit_t *blitptr, draw_callback_h cbptr);
void async_blit_settime(DWORD delay);
+BOOL async_watchdog();
#define ASYNC_DEFAULT 16
#define ASYNC_MIN 4
+#define ASYNC_WATCHDOG_INTERVALS 4
#endif /* __ASYNC_H__INCLUDED__ */
@@ -188,11 +188,13 @@ static void buildPixelFormat(LPDDHALMODEINFO lpMode, LPDDPIXELFORMAT lpddpf) */
static void buildDDHALInfo(VMDAHAL_t __far *hal, int modeidx)
{
+#if 0
static DWORD AlignTbl [ 9 ] = {
FBHDA_ROW_ALIGN, FBHDA_ROW_ALIGN, FBHDA_ROW_ALIGN,
FBHDA_ROW_ALIGN, FBHDA_ROW_ALIGN, FBHDA_ROW_ALIGN,
FBHDA_ROW_ALIGN, FBHDA_ROW_ALIGN, FBHDA_ROW_ALIGN
}; /* reduced to 8 to work correctly with glPixelStorei */
+#endif
int ii;
BOOL can_flip;
@@ -352,10 +354,11 @@ static void buildDDHALInfo(VMDAHAL_t __far *hal, int modeidx) /*
* required alignments of the scan lines for each kind of memory
*/
- hal->ddHALInfo.vmiData.dwOffscreenAlign = AlignTbl[ hda->bpp >> 2 ];
- hal->ddHALInfo.vmiData.dwOverlayAlign = 8;
- hal->ddHALInfo.vmiData.dwTextureAlign = 8;
- hal->ddHALInfo.vmiData.dwZBufferAlign = 8;
+ hal->ddHALInfo.vmiData.dwOffscreenAlign = FBHDA_ROW_ALIGN;
+ // ^ align offscreen surface to pages
+ hal->ddHALInfo.vmiData.dwOverlayAlign = FBHDA_ROW_ALIGN;
+ hal->ddHALInfo.vmiData.dwTextureAlign = FBHDA_ROW_ALIGN;
+ hal->ddHALInfo.vmiData.dwZBufferAlign = FBHDA_ROW_ALIGN;
/*
* callback functions
diff --git a/docs/svga-notes.txt b/docs/svga-notes.txt new file mode 100644 index 0000000..c61e8ad --- /dev/null +++ b/docs/svga-notes.txt @@ -0,0 +1,22 @@ +1: GMR_A[wram,ptr1] -> Surface 1 +2: GMR_B[wram,ptr2] -> Surface 2 +3: GMR_C[wram,ptr3] -> Surface 3 +4: FBGMR -> Surface 4 + +int SVGA_focus(wram_ptr, w, h, bpp); -> GMR id, surface id + + + +3D: + SID = focus(dst_surface); + render -> surface SID + +Flip or update: + SID = focus(wram_ptr) + SVGA3dCmdSurfaceCopy: SID -> 4 + (if cursor && sw cursor) wait + sw blit vram + cmd update + +256 or gamma: + sw blit + cmd update @@ -39,7 +39,7 @@ FIXLINK_CC = wcl386 -q fixlink\fixlink.c -fe=$(FIXLINK_EXE) #FLAGS += -DHWBLT
# Set DBGPRINT to add debug printf logging.
-#DBGPRINT = 1
+DBGPRINT = 1
# Generate code for i486, otherwise is code generated for Pentium Pro
#I486 = 1
diff --git a/vmdisp9x.inf b/vmdisp9x.inf index cea417e..08db32d 100644 --- a/vmdisp9x.inf +++ b/vmdisp9x.inf @@ -39,6 +39,7 @@ qxlmini.vxd=1 vesamini.drv=1
vesamini.vxd=1
;mesa:mesa3d.dll=1
+;mesa:mesasmp.dll=1
;mesa:vmwsgl32.dll=1
;openglide:glide2x.dll=1
;openglide:glide3x.dll=1
@@ -105,6 +106,7 @@ AddReg=VESA.AddReg,VM.AddReg,DX.addReg,VM.regextra boxvmini.drv,,,0x00000004
boxvmini.vxd,,,0x00000004
;mesa:mesa3d.dll,,,0x00000004
+;mesa:mesasmp.dll,,,0x00000004
;vmhal:vmhal9x.dll,,,0x00000004
;vmhal:vmhal3d.dll,,,0x00000004
;vmhal:vmdisp9x.dll,,,0x00000004
@@ -114,6 +116,7 @@ boxvmini.vxd,,,0x00000004 qemumini.drv,,,0x00000004
qemumini.vxd,,,0x00000004
;mesa:mesa3d.dll,,,0x00000004
+;mesa:mesasmp.dll,,,0x00000004
;vmhal:vmhal9x.dll,,,0x00000004
;vmhal:vmhal3d.dll,,,0x00000004
;vmhal:vmdisp9x.dll,,,0x00000004
@@ -123,6 +126,7 @@ qemumini.vxd,,,0x00000004 qxlmini.drv,,,0x00000004
qxlmini.vxd,,,0x00000004
;mesa:mesa3d.dll,,,0x00000004
+;mesa:mesasmp.dll,,,0x00000004
;vmhal:vmhal9x.dll,,,0x00000004
;vmhal:vmhal3d.dll,,,0x00000004
;vmhal:vmdisp9x.dll,,,0x00000004
@@ -133,6 +137,7 @@ vmwsmini.drv,,,0x00000004 vmwsmini.vxd,,,0x00000004
;mesa:vmwsgl32.dll,,,0x00000004
;mesa:mesa3d.dll,,,0x00000004
+;mesa:mesasmp.dll,,,0x00000004
;vmhal:vmhal9x.dll,,,0x00000004
;vmhal:vmhal3d.dll,,,0x00000004
;vmhal:vmdisp9x.dll,,,0x00000004
@@ -142,6 +147,7 @@ vmwsmini.vxd,,,0x00000004 vesamini.drv,,,0x00000004
vesamini.vxd,,,0x00000004
;mesa:mesa3d.dll,,,0x00000004
+;mesa:mesasmp.dll,,,0x00000004
;vmhal:vmhal9x.dll,,,0x00000004
;vmhal:vmhal3d.dll,,,0x00000004
;vmhal:vmdisp9x.dll,,,0x00000004
diff --git a/vxd_async.c b/vxd_async.c index 6c42256..42612ae 100644 --- a/vxd_async.c +++ b/vxd_async.c @@ -39,6 +39,8 @@ static DWORD screen_time = ASYNC_DEFAULT; // 60 Hz static blit_t *blit = NULL;
static draw_callback_h draw_callback = NULL;
volatile DWORD *curtime = NULL;
+static DWORD last_update = 0;
+static DWORD tm_handle = 0;
extern LONG fb_lock_cnt;
extern FBHDA_t *hda;
@@ -46,6 +48,8 @@ extern void *DeviceCTX; #define TIME_MIN_PLAN 4
+#define Set_Timeout Set_Global_Time_Out
+
DWORD calc_delta(DWORD draw_time)
{
DWORD m = (*curtime) % screen_time;
@@ -77,23 +81,25 @@ void __stdcall async_timeout(DWORD tardiness, DWORD refdata) //dbg_printf("async_timeout %d ...", refdata);
- if(FBHDA_lock())
+ last_update = act;
+
+ //if(FBHDA_lock())
{
if(fb_lock_cnt == 0) /* FIXME: check if locking surface is visible surface */
{
draw_callback(blit);
hda->onflip = 0;
}
- FBHDA_unlock();
+ //FBHDA_unlock();
}
burned = *curtime - act;
delta = calc_delta(burned);
- if(!Set_Async_Time_Out(delta, refdata+1, async_timeout_proc))
+ if(!Set_Timeout(delta, refdata+1, async_timeout_proc))
{
delta = calc_delta(0);
- Set_Async_Time_Out(delta, refdata+1, async_timeout_proc);
+ Set_Timeout(delta, refdata+1, async_timeout_proc);
}
//_ContextSwitch(curctx);
//dbg_printf("... set (%d)!\n", delta);
@@ -122,13 +128,13 @@ BOOL async_blit_init(blit_t *blitptr, draw_callback_h cbptr) curtime = Get_System_Time_Address();
dbg_printf("curtime = %X\n", curtime);
- if(Set_Async_Time_Out(calc_delta(0), 0, async_timeout_proc) != 0)
+ if(Set_Timeout(calc_delta(0), 0, async_timeout_proc) != 0)
{
return TRUE;
}
else
{
- dbg_printf("Set_Async_Time_Out FAILED!\n");
+ dbg_printf("Set_Timeout FAILED!\n");
}
}
@@ -142,3 +148,20 @@ void async_blit_settime(DWORD delay) screen_time = delay;
}
}
+
+BOOL async_watchdog()
+{
+ DWORD test;
+
+ test = (*curtime) - last_update;
+ if(test > screen_time*ASYNC_WATCHDOG_INTERVALS)
+ {
+ dbg_printf("HAF!\n");
+ if(Set_Timeout(calc_delta(0), 0, async_timeout_proc) == 0)
+ {
+ dbg_printf("WHOOOO!\n");
+ return FALSE;
+ }
+ }
+ return TRUE;
+}
diff --git a/vxd_halloc.c b/vxd_halloc.c index 250f01c..d9ad5f9 100644 --- a/vxd_halloc.c +++ b/vxd_halloc.c @@ -321,14 +321,14 @@ BOOL vxd_hinit() {
hblocks[0] = vxd_hinit_block(2048, FALSE, TRUE); // 8 MB
hblocks[1] = vxd_hinit_block(8192, FALSE, TRUE); // 32 MB
- hblocks[2] = vxd_hinit_block(32768, FALSE, TRUE); // 128 MB
+ hblocks[2] = vxd_hinit_block(32768, TRUE, TRUE); // 128 MB
hblocks[3] = vxd_hinit_block(65536, TRUE, TRUE); // 256 MB
}
else if(free_pages >= RAM_MB768)
{
hblocks[0] = vxd_hinit_block(2048, FALSE, TRUE); // 8 MB
hblocks[1] = vxd_hinit_block(8192, FALSE, TRUE); // 32 MB
- hblocks[2] = vxd_hinit_block(32768, FALSE, TRUE); // 128 MB
+ hblocks[2] = vxd_hinit_block(32768, TRUE, TRUE); // 128 MB
hblocks[3] = vxd_hinit_block(32768, TRUE, TRUE); // 128 MB
}
else if(free_pages >= RAM_MB512)
@@ -120,7 +120,7 @@ void *memmove(void *destination, const void *source, unsigned int num) src += num;
while(num--)
{
- *dst-- = *src--;
+ *--dst = *--src;
}
}
return destination;
@@ -643,20 +643,24 @@ BOOL VPICD_Virtualize_IRQ(struct _VPICD_IRQ_Descriptor *vid) void Hook_V86_Int_Chain(DWORD int_num, DWORD HookProc)
{
+ _asm push esi
_asm mov eax, [int_num]
_asm mov esi, [HookProc]
VMMCall(Hook_V86_Int_Chain)
+ _asm pop esi
}
DWORD Set_Async_Time_Out(DWORD delayms, DWORD refdata, void *callback)
{
volatile DWORD handle = 0;
+ _asm push esi
_asm mov eax, [delayms]
_asm mov edx, [refdata]
_asm mov esi, [callback]
VMMCall(Set_Async_Time_Out)
_asm mov [handle], esi
+ _asm pop esi
return handle;
}
@@ -667,6 +671,30 @@ DWORD Set_Async_Time_Out(DWORD delayms, DWORD refdata, void *callback) edx = refdata
*/
+
+DWORD Set_Global_Time_Out(DWORD delayms, DWORD refdata, void *callback)
+{
+ volatile DWORD handle = 0;
+
+ _asm push esi
+ _asm mov eax, [delayms]
+ _asm mov edx, [refdata]
+ _asm mov esi, [callback]
+ VMMCall(Set_Global_Time_Out)
+ _asm mov [handle], esi
+ _asm pop esi
+
+ return handle;
+}
+
+void Cancel_Time_Out(DWORD handle)
+{
+ _asm push esi
+ _asm mov esi, [handle]
+ VMMCall(Cancel_Time_Out)
+ _asm pop esi
+}
+
DWORD Get_System_Time()
{
VMMJmp(Get_System_Time);
@@ -92,8 +92,10 @@ void Enable_Global_Trapping(DWORD port); void Disable_Global_Trapping(DWORD port);
DWORD Set_Async_Time_Out(DWORD delayms, DWORD refdata, void *callback);
+DWORD Set_Global_Time_Out(DWORD delayms, DWORD refdata, void *callback);
DWORD Get_System_Time();
DWORD *Get_System_Time_Address();
+void Cancel_Time_Out(DWORD handle);
/**
* round size in bytes to number of pages
@@ -946,9 +946,10 @@ DWORD __stdcall Device_IO_Control_proc(DWORD vmhandle, struct DIOCParams *params {
memcpy(outio, inio, sizeof(SVGA_region_info_t));
}
- outio->address = NULL;
+ //outio->address = NULL;
if(!SVGA_region_create(outio))
{
+ outio->address = NULL;
//SVGA_flushcache();
//SVGA_region_create(outio);
// FIXME: return 1?
diff --git a/vxd_strings.h b/vxd_strings.h index 0073ed4..98f8096 100644 --- a/vxd_strings.h +++ b/vxd_strings.h @@ -50,8 +50,6 @@ DSTR(dbg_cb_ena, "CB context 0 enabled\n"); DSTR(dbg_region_info_1, "Region id = %d\n");
DSTR(dbg_region_info_2,"Region address = %lX, PPN = %lX, GMRBLK = %lX\n");
-DSTR(dbg_mapping, "Memory mapping:\n");
-DSTR(dbg_mapping_map, " %X -> %X\n");
DSTR(dbg_destroy, "Driver destroyed\n");
DSTR(dbg_siz, "Size of gSVGA(2) = %d %d\n");
@@ -30,21 +30,20 @@ THE SOFTWARE. #include "winhack.h"
#include "vmm.h"
#include "vxd.h"
-#include "vpicd.h"
+//#include "vpicd.h"
#include "vxd_lib.h"
+#include "vxd_terror.h"
+
+#include "wram.h"
+#include "async.h"
#include "svga_all.h"
#include "3d_accel.h"
-
#include "code32.h"
-
#include "vxd_svga.h"
-
#include "vxd_strings.h"
-
#include "svga_ver.h"
-
#include "vxd_color.h"
/*
@@ -76,8 +75,6 @@ static DWORD prefer_fifo = 1; static BOOL SVGA_is_valid = FALSE;
-BOOL surface_dirty = FALSE;
-
static DWORD fence_next_id = 1;
void *cmdbuf = NULL;
void *ctlbuf = NULL;
@@ -90,6 +87,13 @@ ULONG mem_sem = 0; BOOL gpu_allocated = FALSE;
+static blit_t wblit;
+static BOOL vga_mode = TRUE;
+static BOOL timer_set = FALSE;
+
+static void SVGA_draw(blit_t *blit);
+static void SVGA_draw_cond(BOOL swap);
+
/* vxd_mouse.vxd */
BOOL mouse_get_rect(DWORD *ptr_left, DWORD *ptr_top,
DWORD *ptr_right, DWORD *ptr_bottom);
@@ -99,18 +103,8 @@ BOOL mouse_get_rect(DWORD *ptr_left, DWORD *ptr_top, /*
* strings
*/
+extern const char reg_path[];
static char SVGA_conf_path[] = "Software\\vmdisp9x\\svga";
-static char SVGA_conf_hw_cursor[] = "HWCursor";
-/* ^ recovered */
-static char SVGA_conf_vram_limit[] = "VRAMLimit";
-static char SVGA_conf_rgb565bug[] = "RGB565bug";
-static char SVGA_conf_cb[] = "CommandBuffers";
-static char SVGA_conf_pref_fifo[] = "PreferFIFO";
-static char SVGA_conf_hw_version[] = "HWVersion";
-static char SVGA_conf_disable_multisample[] = "NoMultisample";
-static char SVGA_conf_reg_multisample[] = "RegMultisample";
-static char SVGA_conf_async_mobs[] = "AsyncMOBs";
-static char SVGA_conf_no_scr_accel[] = "NoScreenAccel";
static char SVGA_vxd_name[] = "vmwsmini.vxd";
@@ -153,7 +147,7 @@ static void SVGA_DB_alloc() sizeof(SVGA_DB_t) +
regions_map_size + contexts_map_size + surfaces_map_size;
- svga_db = (SVGA_DB_t*)_PageAllocate(RoundToPages(size), PG_VM, ThisVM, 0, PAGE_ALLOC_MIN, PAGE_ALLOC_MAX, NULL, PAGEFIXED);
+ svga_db = (SVGA_DB_t*)_PageAllocate(RoundToPages(size), PG_VM, ThisVM, 0, PAGE_ALLOC_MIN, PAGE_ALLOC_MAX, NULL, PAGEFIXED); /* TODO: could we save some RAM when this will no be PAGEFIXED? */
if(svga_db)
{
memset(svga_db, 0, size);
@@ -187,6 +181,8 @@ static void SVGA_DB_alloc() memset(svga_db->contexts_map, 0xFF, contexts_map_size);
memset(svga_db->surfaces_map, 0xFF, surfaces_map_size);
+
+
svga_db->stat_regions_usage = 0;
}
@@ -365,7 +361,7 @@ BOOL SVGA_vxdcmd(DWORD cmd, DWORD arg) return FALSE;
}
-static DWORD fb_pm16 = 0;
+//static DWORD fb_pm16 = 0;
//static DWORD st_pm16 = 0;
//static DWORD st_address = 0;
static DWORD st_surface_mb = 0;
@@ -412,6 +408,7 @@ BOOL SVGA_init_hw() DWORD conf_rgb565bug = 1;
DWORD conf_cb = 1;
DWORD conf_hw_version = SVGA_VERSION_2;
+ DWORD wram_size = 64;
#if 0
uint8 irq = 0;
#endif
@@ -423,18 +420,24 @@ BOOL SVGA_init_hw() cb_sem = Create_Semaphore(1);
/* configs in registry */
- RegReadConf(HKEY_LOCAL_MACHINE, SVGA_conf_path, SVGA_conf_vram_limit, &conf_vram_limit);
- RegReadConf(HKEY_LOCAL_MACHINE, SVGA_conf_path, SVGA_conf_rgb565bug, &conf_rgb565bug);
- RegReadConf(HKEY_LOCAL_MACHINE, SVGA_conf_path, SVGA_conf_cb, &conf_cb);
- RegReadConf(HKEY_LOCAL_MACHINE, SVGA_conf_path, SVGA_conf_hw_version, &conf_hw_version);
- RegReadConf(HKEY_LOCAL_MACHINE, SVGA_conf_path, SVGA_conf_pref_fifo, &prefer_fifo);
+ RegReadConf(HKEY_LOCAL_MACHINE, reg_path, "WRAMSize", &wram_size);
+ RegReadConf(HKEY_LOCAL_MACHINE, SVGA_conf_path, "VRAMLimit", &conf_vram_limit);
+ RegReadConf(HKEY_LOCAL_MACHINE, SVGA_conf_path, "RGB565bug", &conf_rgb565bug);
+ RegReadConf(HKEY_LOCAL_MACHINE, SVGA_conf_path, "CommandBuffers", &conf_cb);
+ RegReadConf(HKEY_LOCAL_MACHINE, SVGA_conf_path, "HWVersion", &conf_hw_version);
+ RegReadConf(HKEY_LOCAL_MACHINE, SVGA_conf_path, "PreferFIFO", &prefer_fifo);
- RegReadConf(HKEY_LOCAL_MACHINE, SVGA_conf_path, SVGA_conf_disable_multisample, &disable_multisample);
- RegReadConf(HKEY_LOCAL_MACHINE, SVGA_conf_path, SVGA_conf_reg_multisample, ®_multisample);
+ RegReadConf(HKEY_LOCAL_MACHINE, SVGA_conf_path, "NoMultisample", &disable_multisample);
+ RegReadConf(HKEY_LOCAL_MACHINE, SVGA_conf_path, "RegMultisample", ®_multisample);
- RegReadConf(HKEY_LOCAL_MACHINE, SVGA_conf_path, SVGA_conf_async_mobs, &async_mobs);
- RegReadConf(HKEY_LOCAL_MACHINE, SVGA_conf_path, SVGA_conf_hw_cursor, &hw_cursor);
- RegReadConf(HKEY_LOCAL_MACHINE, SVGA_conf_path, SVGA_conf_no_scr_accel, &disable_screen_accel);
+ RegReadConf(HKEY_LOCAL_MACHINE, SVGA_conf_path, "AsyncMOBs", &async_mobs);
+ RegReadConf(HKEY_LOCAL_MACHINE, SVGA_conf_path, "HWCursor", &hw_cursor);
+ RegReadConf(HKEY_LOCAL_MACHINE, SVGA_conf_path, "NoScreenAccel", &disable_screen_accel);
+
+ if(wram_size < WRAM_MIN_MB)
+ {
+ wram_size = WRAM_MIN_MB;
+ }
if(async_mobs < 1)
async_mobs = 1;
@@ -442,11 +445,6 @@ BOOL SVGA_init_hw() if(async_mobs >= SVGA_CB_MAX_QUEUED_PER_CONTEXT)
async_mobs = SVGA_CB_MAX_QUEUED_PER_CONTEXT-1;
- if(!FBHDA_init_hw())
- {
- return FALSE;
- }
-
dbg_printf(dbg_test, 0);
rc = SVGA_Init(FALSE, conf_hw_version);
@@ -462,20 +460,21 @@ BOOL SVGA_init_hw() gSVGA.userFlags |= SVGA_USER_FLAGS_RGB565_BROKEN;
}
+ gSVGA.fbSize = gSVGA.vramSize;
if(conf_vram_limit > SVGA_MIN_VRAM)
{
- if(gSVGA.vramSize > conf_vram_limit*(1024*1024))
+ if(gSVGA.fbSize > conf_vram_limit*(1024*1024))
{
- gSVGA.vramSize = conf_vram_limit*(1024*1024);
+ gSVGA.fbSize = conf_vram_limit*(1024*1024);
}
}
dbg_printf(dbg_Device_Init_proc_succ);
- dbg_printf(dbg_mapping_map, gSVGA.fbPhy, gSVGA.fifoPhy);
+ dbg_printf(" %X -> %X\n", gSVGA.fbPhy, gSVGA.fifoPhy);
/* map phys FB to linear */
- gSVGA.fbLinear = _MapPhysToLinear(gSVGA.fbPhy, gSVGA.vramSize, 0);
+ gSVGA.fbLinear = _MapPhysToLinear(gSVGA.fbPhy, gSVGA.fbSize, 0);
/* map phys FIFO to linear */
if(!SVGA_IsSVGA3())
@@ -486,10 +485,9 @@ BOOL SVGA_init_hw() if(!SVGA_IsSVGA3())
gSVGA.fifoMem = (uint32 *)gSVGA.fifoLinear;
- dbg_printf(dbg_mapping);
- dbg_printf(dbg_mapping_map, gSVGA.fbPhy, gSVGA.fbMem);
- dbg_printf(dbg_mapping_map, gSVGA.fifoPhy, gSVGA.fifoMem);
- //dbg_printf(dbg_mapping_map, gSVGA.fifo.bouncePhy, gSVGA.fifo.bounceMem);
+ dbg_printf("Memory mapping:\n");
+ dbg_printf(" %X -> %X\n", gSVGA.fbPhy, gSVGA.fbMem);
+ dbg_printf(" %X -> %X\n", gSVGA.fifoPhy, gSVGA.fifoMem);
dbg_printf(dbg_siz, sizeof(gSVGA), sizeof(uint8 FARP *));
SVGA_write_driver_id();
@@ -579,18 +577,31 @@ BOOL SVGA_init_hw() }
/* allocate 16bit selector for FB */
- fb_pm16 = map_pm16(1, gSVGA.fbLinear, gSVGA.vramSize);
+ //fb_pm16 = map_pm16(1, gSVGA.fbLinear, gSVGA.vramSize);
+
+ if(!wram_init(wram_size*1024*1024))
+ {
+ terrorf("Cannot alocate %d MB RAM!\n", wram_size);
+ terror("Please adjust WRAMSize registry key or increase physical RAM\n");
+ tpause();
+ return FALSE;
+ }
+
+ if(!FBHDA_init_hw())
+ {
+ return FALSE;
+ }
/* fill address in FBHDA */
- hda->vram_pm32 = (void*)gSVGA.fbLinear;
- hda->vram_size = gSVGA.vramSize;
- hda->vram_size_bar = gSVGA.vramSize;
- hda->vram_size_virt = conf_vram_limit*1024*1024;
- hda->vram_pm16 = fb_pm16;
- hda->vram_phylin = hda->vram_pm32; /* no fb buffer emulation */
+ hda->vram_size = gSVGA.fbSize;
+ hda->vram_size_bar = gSVGA.fbSize;
+
+ hda->vram_phylin = (void*)gSVGA.fbLinear; /* no fb buffer emulation */
+ hda->vram_pm32 = (BYTE*)wram + wram->regs.s.fbmin;
+ hda->vram_size_virt = wram->regs.s.fbmax - wram->regs.s.fbmin;
memcpy(hda->vxdname, SVGA_vxd_name, sizeof(SVGA_vxd_name));
-
+
hda->flags |= FB_ACCEL_VMSVGA;
if(cb_support && gb_support)
@@ -603,7 +614,9 @@ BOOL SVGA_init_hw() /* switch back to VGA mode, SVGA mode will be request by 16 bit driver later */
SVGA_HW_disable();
- FBHDA_memtest();
+ wblit.num_changes = 0;
+ timer_set = async_blit_init(&wblit, SVGA_draw);
+ dbg_printf("timer = %d\n", timer_set);
return TRUE;
}
@@ -746,7 +759,8 @@ static void SVGA_DefineGMRFB() wait_for_cmdbuf();
gmrfb = SVGA_cmd_ptr(cmdbuf, &cmd_offset, SVGA_CMD_DEFINE_GMRFB, sizeof(SVGAFifoCmdDefineGMRFB));
- SVGA_FillGMRFB(gmrfb, hda->surface, hda->pitch, hda->bpp);
+ //SVGA_FillGMRFB(gmrfb, hda->surface, hda->pitch, hda->bpp);
+ SVGA_FillGMRFB(gmrfb, 0, SVGA_pitch(hda->width, 32), 32);
submit_cmdbuf(cmd_offset, 0, 0);
//dbg_printf("SVGA_DefineGMRFB: %ld\n", hda->surface);
@@ -775,6 +789,8 @@ DWORD SVGA_fix_width(DWORD w, DWORD bpp) BOOL SVGA_validmode(DWORD w, DWORD h, DWORD bpp)
{
DWORD w_fix = SVGA_fix_width(w, bpp);
+
+ dbg_printf("SVGA_validmode(%d, %d, %d)\n", w, h, bpp);
switch(bpp)
{
@@ -791,9 +807,9 @@ BOOL SVGA_validmode(DWORD w, DWORD h, DWORD bpp) if(h <= SVGA_ReadReg(SVGA_REG_MAX_HEIGHT))
{
DWORD size = SVGA_pitch(w_fix, 32) * h;
- size += SVGA_pitch(w_fix, bpp) * h;
if(size > hda->vram_size)
{
+ dbg_printf("Resolution too large, vram_size=%ld!\n", hda->vram_size);
return FALSE;
}
return TRUE;
@@ -805,6 +821,7 @@ BOOL SVGA_validmode(DWORD w, DWORD h, DWORD bpp) static void SVGA_setmode_phy(DWORD w, DWORD h, DWORD bpp)
{
+ BOOL has3D = FALSE;
//SVGA_OTable_unload(); // unload otables
/* Make sure, that we drain full FIFO */
@@ -844,7 +861,7 @@ static void SVGA_setmode_phy(DWORD w, DWORD h, DWORD bpp) /* setting screen by fifo, this method is required in VB 6.1 */
if(SVGA_hasAccelScreen(FALSE))
{
- SVGA_defineScreen(w, h, bpp, 0);
+ SVGA_defineScreen(w, h, 32, 0);
/* reenable fifo */
SVGA_Enable();
@@ -859,6 +876,71 @@ static void SVGA_setmode_phy(DWORD w, DWORD h, DWORD bpp) SVGA_Sync();
SVGA_Flush_CB();
+
+ if(gpu_allocated)
+ {
+ has3D = SVGA3D_Init();
+ }
+ else
+ {
+ dbg_printf("!!!gpu_allocated\n");
+ }
+
+ hda->width = w;//SVGA_ReadReg(SVGA_REG_WIDTH);
+ hda->height = h;//SVGA_ReadReg(SVGA_REG_HEIGHT);
+ hda->bpp = bpp;
+ hda->pitch = SVGA_pitch(hda->width, bpp);
+
+ hda->system_surface = 0;
+ hda->surface = 0;
+ hda->stride = hda->height * hda->pitch;
+
+ if(has3D && SVGA_GetDevCap(SVGA3D_DEVCAP_3D) > 0)
+ {
+ hda->flags |= FB_ACCEL_VMSVGA3D;
+ hda->flags |= FB_ACCEL_GPUMEM;
+ dbg_printf("have 3D!\n");
+ }
+ else
+ {
+ hda->flags &= ~((DWORD)FB_ACCEL_VMSVGA3D);
+ dbg_printf("no 3D - %ld %ld!\n", has3D, SVGA_GetDevCap(SVGA3D_DEVCAP_3D));
+ }
+
+ hda->flags |= FB_SUPPORT_FLIPING;
+ if(SVGA_hasAccelScreen(TRUE))
+ {
+ SVGA_DefineGMRFB();
+ }
+
+ /* set VRAM destination */
+ wblit.base.ptr = hda->vram_phylin;
+ wblit.dst[0].flat.ptr = hda->vram_phylin;
+ wblit.dst[1].flat.ptr = NULL;
+ wblit.dst[2].flat.ptr = NULL;
+ wblit.dst_w = w;
+ wblit.dst_h = h;
+ wblit.dst_pitch = SVGA_pitch(w, 32);
+ wblit.dst_mode = MODE_32;
+ wblit.dst_scans = 1;
+ wblit.dst_padx = 0;
+ wblit.dst_pady = 0;
+
+ wram->regs.s.width = w;
+ wram->regs.s.height = h;
+ switch(bpp)
+ {
+ case 8: wram->regs.s.mode = MODE_8; break;
+ case 15: wram->regs.s.mode = MODE_15; break;
+ case 16: wram->regs.s.mode = MODE_16; break;
+ case 24: wram->regs.s.mode = MODE_24; break;
+ case 32: wram->regs.s.mode = MODE_32; break;
+ }
+ wram->regs.s.pitch = hda->pitch;
+
+ //SVGA_clear();
+
+
}
/* clear both physical screen and system surface */
@@ -881,7 +963,6 @@ void SVGA_clear() **/
BOOL SVGA_setmode(DWORD w, DWORD h, DWORD bpp)
{
- BOOL has3D = FALSE;
DWORD w_fix = SVGA_fix_width(w, bpp);
if(!SVGA_validmode(w_fix, h, bpp))
@@ -908,74 +989,18 @@ BOOL SVGA_setmode(DWORD w, DWORD h, DWORD bpp) operations are bit unstable)
*/
- mouse_invalidate();
- FBHDA_access_begin(0);
-
+ FBHDA_lock();
SVGA_setmode_phy(w_fix, h, bpp);
+ vga_mode = FALSE;
+ FBHDA_unlock();
- if(gpu_allocated)
- {
- has3D = SVGA3D_Init();
- }
-
- hda->flags &= ~((DWORD)FB_SUPPORT_FLIPING);
- hda->flags &= ~((DWORD)FB_ACCEL_VMSVGA10_ST);
-
-/*
- hda->vram_pm32 = (void*)gSVGA.fbLinear;
- hda->vram_size = gSVGA.vramSize;
- hda->vram_pm16 = fb_pm16;
- JH: this doesn't change at runtime!
-*/
- hda->width = w_fix;//SVGA_ReadReg(SVGA_REG_WIDTH);
- hda->height = h;//SVGA_ReadReg(SVGA_REG_HEIGHT);
-
- if(bpp >= 8)
- {
- DWORD offset = SVGA_DT_stride(hda->width, hda->height);
-
- hda->bpp = bpp;
- hda->pitch = SVGA_pitch(hda->width, bpp);
- hda->system_surface = offset;
- hda->surface = offset;
- }
- else
- {
- hda->bpp = SVGA_ReadReg(SVGA_REG_BITS_PER_PIXEL);
- hda->pitch = SVGA_ReadReg(SVGA_REG_BYTES_PER_LINE);
- hda->surface = 0;
- hda->system_surface = 0;
- }
-
- hda->stride = hda->height * hda->pitch;
-
- if(has3D && SVGA_GetDevCap(SVGA3D_DEVCAP_3D) > 0)
- {
- hda->flags |= FB_ACCEL_VMSVGA3D;
- hda->flags |= FB_ACCEL_GPUMEM;
- }
- else
- {
- hda->flags &= ~((DWORD)FB_ACCEL_VMSVGA3D);
- }
-
- if(hda->system_surface > 0)
- {
- hda->flags |= FB_SUPPORT_FLIPING;
- if(SVGA_hasAccelScreen(TRUE))
- {
- SVGA_DefineGMRFB();
- }
- }
-
- SVGA_clear();
-
+ async_blit_settime(ASYNC_DEFAULT);
+ dbg_printf("SVGA_setmode(%ld %ld %ld = %ld) = OK\n",
+ w_fix, h, bpp, hda->pitch
+ );
+
mouse_invalidate();
-
- FBHDA_access_end(0);
-
- fb_lock_cnt = 0; // reset lock counters
-
+
return TRUE;
}
@@ -1114,6 +1139,8 @@ void SVGA_HW_enable() SVGA_CB_start();
svga_saved_state.enabled = TRUE;
+
+ vga_mode = FALSE;
}
}
@@ -1126,6 +1153,8 @@ void SVGA_HW_disable() SVGA_Disable();
svga_saved_state.enabled = FALSE;
+
+ vga_mode = TRUE;
}
BOOL SVGA_valid()
@@ -1135,518 +1164,97 @@ BOOL SVGA_valid() BOOL FBHDA_swap(DWORD offset, DWORD flags)
{
- BOOL rc = FALSE;
-
+ void *new_fb;
if((flags & FBHDA_SWAP_QUERY) != 0)
{
return TRUE;
}
- if(hda->overlay > 0)
- {
- /* on overlay emulate behaviour */
- if(offset >= hda->system_surface && hda->bpp >= 8)
- {
- hda->surface = offset;
- return TRUE;
- }
- return FALSE;
- }
-
- if(offset >= hda->system_surface) /* DON'T touch surface 0 */
- {
- FBHDA_access_begin(0);
- if(hda->bpp >= 8)
- {
- hda->surface = offset;
- if(SVGA_hasAccelScreen(TRUE))
- {
- SVGA_DefineGMRFB();
- }
- rc = TRUE;
- }
- FBHDA_access_end(0);
- }
-
- return rc;
-}
-
-static DWORD rect_left;
-static DWORD rect_top;
-static DWORD rect_right;
-static DWORD rect_bottom;
-
-static inline void update_rect(DWORD left, DWORD top, DWORD right, DWORD bottom)
-{
- if(left < rect_left)
- rect_left = left;
-
- if(top < rect_top)
- rect_top = top;
-
- if(right > rect_right)
- {
- rect_right = right;
- if(rect_right > hda->width)
- {
- rect_right = hda->width;
- }
- }
-
- if(bottom > rect_bottom)
+ new_fb = ((BYTE*)hda->vram_pm32) + offset;
+ if(wram_swap(new_fb, &wblit))
{
- rect_bottom = bottom;
- if(rect_bottom > hda->height)
- {
- rect_bottom = hda->height;
- }
- }
-}
-
-static inline void check_dirty()
-{
- if(surface_dirty)
- {
- switch(hda->bpp)
- {
- case 32:
- {
- if(SVGA_hasAccelScreen(TRUE))
- {
- SVGAFifoCmdBlitScreenToGMRFB *gmrblit;
- DWORD cmd_offset = 0;
-
- wait_for_cmdbuf();
-
- gmrblit = SVGA_cmd_ptr(cmdbuf, &cmd_offset, SVGA_CMD_BLIT_SCREEN_TO_GMRFB, sizeof(SVGAFifoCmdBlitScreenToGMRFB));
-
- gmrblit->destOrigin.x = 0;
- gmrblit->destOrigin.y = 0;
- gmrblit->srcRect.left = 0;
- gmrblit->srcRect.top = 0;
- gmrblit->srcRect.right = hda->width;
- gmrblit->srcRect.bottom = hda->height;
- gmrblit->srcScreenId = 0;
-
- submit_cmdbuf(cmd_offset, SVGA_CB_UPDATE, 0);
- }
- else
- {
- memcpy(hda->vram_pm32, ((BYTE*)hda->vram_pm32)+hda->surface, hda->stride);
- }
- break;
- }
- case 16:
- {
- readback16(
- hda->vram_pm32, SVGA_pitch(hda->width, 32),
- ((BYTE*)hda->vram_pm32)+hda->surface, hda->pitch,
- 0, 0, hda->width, hda->height
- );
- break;
- }
- } // switch
-
- surface_dirty = FALSE;
+ SVGA_draw_cond(TRUE);
+ hda->surface = offset;
+ return TRUE;
}
+ return TRUE;
}
void FBHDA_access_rect(DWORD left, DWORD top, DWORD right, DWORD bottom)
{
- if(hda->overlay > 0)
- {
- return;
- }
-
FBHDA_lock();
-
- if(left > hda->width)
- {
- FBHDA_unlock();
- return;
- }
-
- if(top > hda->height)
- {
- FBHDA_unlock();
- return;
- }
-
- if(right > hda->width)
- right = hda->width;
-
- if(bottom > hda->height)
- bottom = hda->height;
-
- if(fb_lock_cnt++ == 0)
- {
- SVGA_CMB_wait_update();
- check_dirty();
-
- rect_left = left;
- rect_top = top;
- rect_right = right;
- rect_bottom = bottom;
-
- //mouse_erase();
-
- if(mouse_get_rect(&left, &top, &right, &bottom))
- {
- update_rect(left, top, right, bottom);
- }
- }
- else
- {
- update_rect(left, top, right, bottom);
- }
-
+ fb_lock_cnt++;
+ //dbg_printf("FBHDA_access_rect(%ld, %ld, ...)\n", left, right);
+ wram_changes(&wblit, left, top, right, bottom);
FBHDA_unlock();
}
void FBHDA_access_begin(DWORD flags)
{
- if(hda->overlay > 0)
- {
- return;
- }
+ FBHDA_lock();
+ fb_lock_cnt++;
+ //dbg_printf("FBHDA_access_begin()\n");
- if(flags & (FBHDA_ACCESS_RAW_BUFFERING | FBHDA_ACCESS_MOUSE_MOVE))
+ if(flags & FBHDA_ACCESS_MOUSE_MOVE)
{
- FBHDA_lock();
-
-// dbg_printf("FBHDA_access_begin(%ld)\n", flags);
-
- if(fb_lock_cnt++ == 0)
- {
- SVGA_CMB_wait_update();
- //mouse_erase();
- check_dirty();
-
- if(!mouse_get_rect(&rect_left, &rect_top, &rect_right, &rect_bottom))
- {
- rect_left = 0;
- rect_top = 0;
- rect_right = 0;
- rect_bottom = 0;
- }
- }
- else
+ DWORD left, top, right, bottom;
+ if(mouse_get_rect(&left, &top, &right, &bottom))
{
- DWORD l, t, r, b;
-
- if(mouse_get_rect(&l, &t, &r, &b))
- {
- update_rect(l, t, r, b);
- }
+ wram_changes(&wblit, left, top, right, bottom);
}
-
- FBHDA_unlock();
}
else
{
- FBHDA_access_rect(0, 0, hda->width, hda->height);
+ wram_changes(&wblit, 0, 0, hda->width, hda->height);
}
+
+ FBHDA_unlock();
}
void FBHDA_access_end(DWORD flags)
{
- //dbg_printf("+++ FBHDA_access_end: %ld\n", fb_lock_cnt);
-
- if(hda->overlay > 0)
- {
- return;
- }
-
FBHDA_lock();
- if(flags & FBHDA_ACCESS_SURFACE_DIRTY)
- {
- surface_dirty = TRUE;
- }
-
if(flags & FBHDA_ACCESS_MOUSE_MOVE)
{
- DWORD l, t, r, b;
-
- if(mouse_get_rect(&l, &t, &r, &b))
+ DWORD left, top, right, bottom;
+ if(mouse_get_rect(&left, &top, &right, &bottom))
{
- update_rect(l, t, r, b);
+ wram_changes(&wblit, left, top, right, bottom);
}
}
- if(--fb_lock_cnt <= 0)
- {
- DWORD w, h;
- BOOL need_refresh = ((hda->bpp == 32) && (hda->system_surface == 0));
-
- fb_lock_cnt = 0;
-
- w = rect_right - rect_left;
- h = rect_bottom - rect_top;
-
-/* dbg_printf("FBHDA_access_end(%ld %ld %ld %ld)\n",
- rect_left, rect_top, rect_right, rect_bottom);*/
-
- if(w > 0 && h > 0)
- {
- check_dirty();
- //mouse_blit();
- if(hda->surface > 0)
- {
- switch(hda->bpp)
- {
- case 32:
- {
- if(SVGA_hasAccelScreen(TRUE))
- {
- SVGAFifoCmdBlitGMRFBToScreen *gmrblit;
- DWORD cmd_offset = 0;
-
- wait_for_cmdbuf();
-
- gmrblit = SVGA_cmd_ptr(cmdbuf, &cmd_offset, SVGA_CMD_BLIT_GMRFB_TO_SCREEN, sizeof(SVGAFifoCmdBlitGMRFBToScreen));
-
- gmrblit->srcOrigin.x = rect_left;
- gmrblit->srcOrigin.y = rect_top;
- gmrblit->destRect.left = rect_left;
- gmrblit->destRect.top = rect_top;
- gmrblit->destRect.right = rect_right;
- gmrblit->destRect.bottom = rect_bottom;
+ fb_lock_cnt--;
+ if(fb_lock_cnt < 0) fb_lock_cnt = 0;
- gmrblit->destScreenId = 0;
+ SVGA_draw_cond(FALSE);
- submit_cmdbuf(cmd_offset, SVGA_CB_UPDATE, 0);
- }
- else
- {
- blit32(
- ((BYTE*)hda->vram_pm32)+hda->surface, hda->pitch,
- hda->vram_pm32, hda->pitch,
- rect_left, rect_top,
- rect_right - rect_left, rect_bottom - rect_top
- );
- need_refresh = TRUE;
- }
- break;
- }
- case 16:
- blit16(
- ((BYTE*)hda->vram_pm32)+hda->surface, hda->pitch,
- hda->vram_pm32, SVGA_pitch(hda->width, 32),
- rect_left, rect_top,
- rect_right - rect_left, rect_bottom - rect_top
- );
- need_refresh = TRUE;
- break;
- case 8:
- blit8(
- ((BYTE*)hda->vram_pm32)+hda->surface, hda->pitch,
- hda->vram_pm32, SVGA_pitch(hda->width, 32),
- rect_left, rect_top,
- rect_right - rect_left, rect_bottom - rect_top
- );
- need_refresh = TRUE;
- break;
- } // switch
- }
-
- if(need_refresh)
- {
- SVGAFifoCmdUpdate *cmd_update;
- DWORD cmd_offset = 0;
-
- wait_for_cmdbuf();
-
- cmd_update = SVGA_cmd_ptr(cmdbuf, &cmd_offset, SVGA_CMD_UPDATE, sizeof(SVGAFifoCmdUpdate));
- cmd_update->x = rect_left;
- cmd_update->y = rect_top;
- cmd_update->width = rect_right - rect_left;
- cmd_update->height = rect_bottom - rect_top;
-
- submit_cmdbuf(cmd_offset, SVGA_CB_UPDATE, 0);
- }
- }
- else
- {
- //mouse_blit(); /* in this case is mouse unvisible, but we need still switch visibility state */
- } // w == 0 && h == 0
- } // fb_lock_cnt == 0
-
FBHDA_unlock();
}
void FBHDA_palette_set(unsigned char index, DWORD rgb)
{
- if(hda->system_surface > 0)
- {
- palette_emulation[index] = rgb;
- }
- else
- {
- UINT sIndex = SVGA_PALETTE_BASE + index*3;
-
- SVGA_WriteReg(sIndex+0, (rgb >> 16) & 0xFF);
- SVGA_WriteReg(sIndex+1, (rgb >> 8) & 0xFF);
- SVGA_WriteReg(sIndex+2, rgb & 0xFF);
- }
- hda->palette_update++;
+ wram->palette[index].dw = rgb;
}
DWORD FBHDA_palette_get(unsigned char index)
{
- if(hda->system_surface > 0)
- {
- return palette_emulation[index];
- }
- else
- {
- UINT sIndex = SVGA_PALETTE_BASE + index*3;
-
- return ((SVGA_ReadReg(sIndex+0) & 0xFF) << 16) |
- ((SVGA_ReadReg(sIndex+1) & 0xFF) << 8) |
- (SVGA_ReadReg(sIndex+2) & 0xFF);
- }
+ return wram->palette[index].dw;
}
-static DWORD ov_width = 0;
-static DWORD ov_height = 0;
-static DWORD ov_pitch = 0;
-static DWORD ov_bpp = 0;
-
DWORD FBHDA_overlay_setup(DWORD overlay, DWORD width, DWORD height, DWORD bpp)
{
- DWORD width_fix = SVGA_fix_width(width, bpp);
-
- dbg_printf("FBHDA_overlay_setup: %ld\n", overlay);
-
- if(overlay >= FBHDA_OVERLAYS_MAX)
- return 0;
-
- if(overlay == 0)
- {
- /* restore */
- SVGA_setmode_phy(svga_saved_state.width, svga_saved_state.height, svga_saved_state.bpp);
- SVGA_DefineGMRFB();
-
- hda->overlay = 0;
-
- if(!svga_saved_state.enabled)
- {
- SVGA_Disable();
- }
- else
- {
- /* redraw framebuffer */
- FBHDA_access_begin(0);
- FBHDA_access_end(0);
- }
-
- return hda->pitch;
- }
- else
- {
- if(bpp == 32)
- {
- SVGAFifoCmdDefineGMRFB *gmrfb;
- DWORD cmd_offset = 0;
-
- DWORD pitch = SVGA_pitch(width_fix, bpp);
- DWORD offset = ((BYTE*)hda->overlays[overlay].ptr) - ((BYTE*)hda->vram_pm32);
- DWORD stride = pitch*height;
-
- if(hda->overlays[overlay].size > stride)
- {
- hda->overlay = overlay;
- SVGA_setmode_phy(width_fix, height, bpp);
-
- wait_for_cmdbuf();
- gmrfb = SVGA_cmd_ptr(cmdbuf, &cmd_offset, SVGA_CMD_DEFINE_GMRFB, sizeof(SVGAFifoCmdDefineGMRFB));
- SVGA_FillGMRFB(gmrfb, offset, pitch, bpp);
- submit_cmdbuf(cmd_offset, SVGA_CB_SYNC, 0);
-
- ov_width = width_fix;
- ov_height = height;
- ov_pitch = pitch;
- ov_bpp = bpp;
-
- /* clear screen */
- FBHDA_overlay_lock(0, 0, width_fix, height);
- memset(hda->overlays[overlay].ptr, 0, stride);
- FBHDA_overlay_unlock(0);
-
- return pitch;
- }
- } // bpp == 32
- } // overlay > 0
-
return 0;
}
-static int overlay_lock_cnt = 0;
-static DWORD ov_rect_left = 0;
-static DWORD ov_rect_top = 0;
-static DWORD ov_rect_right = 0;
-static DWORD ov_rect_bottom = 0;
-
void FBHDA_overlay_lock(DWORD left, DWORD top, DWORD right, DWORD bottom)
{
- if(hda->overlay == 0) return;
-
- if(overlay_lock_cnt++ == 0)
- {
- ov_rect_left = left;
- ov_rect_top = top;
- ov_rect_right = right;
- ov_rect_bottom = bottom;
- }
- else
- {
- if(left < ov_rect_left) ov_rect_left = left;
-
- if(top < ov_rect_top) ov_rect_top = top;
-
- if(right > ov_rect_right) ov_rect_right = right;
- if(bottom > ov_rect_bottom) ov_rect_bottom = bottom;
-
- }
-
- if(ov_rect_right > ov_width) ov_rect_right = ov_width;
-
- if(ov_rect_bottom > ov_height) ov_rect_right = ov_height;
}
void FBHDA_overlay_unlock(DWORD flags)
{
- if(hda->overlay == 0) return;
-
- if(--overlay_lock_cnt <= 0)
- {
- if(ov_rect_left < ov_rect_right && ov_rect_top < ov_rect_bottom)
- {
- SVGAFifoCmdBlitGMRFBToScreen *gmrblit;
- DWORD cmd_offset = 0;
-
- wait_for_cmdbuf();
- gmrblit = SVGA_cmd_ptr(cmdbuf, &cmd_offset, SVGA_CMD_BLIT_GMRFB_TO_SCREEN, sizeof(SVGAFifoCmdBlitGMRFBToScreen));
-
- gmrblit->srcOrigin.x = ov_rect_left;
- gmrblit->srcOrigin.y = ov_rect_top;
- gmrblit->destRect.left = ov_rect_left;
- gmrblit->destRect.top = ov_rect_top;
- gmrblit->destRect.right = ov_rect_right;
- gmrblit->destRect.bottom = ov_rect_bottom;
-
- gmrblit->destScreenId = 0;
-
- submit_cmdbuf(cmd_offset, SVGA_CB_UPDATE, 0);
- }
- if(overlay_lock_cnt < 0)
- {
- overlay_lock_cnt = 0;
- }
- }
}
#define BSTEP (sizeof(DWORD)*8)
@@ -1866,3 +1474,60 @@ void SVGA_AllProcessCleanup() critical_section_leave();
}
+
+static void SVGA_draw(blit_t *blit)
+{
+ if(vga_mode) return;
+
+ if(blit->num_changes)
+ {
+ SVGAFifoCmdUpdate *update;
+ DWORD cmd_offset = 0;
+
+ wram_blit(blit);
+
+ wait_for_cmdbuf();
+
+ update = SVGA_cmd_ptr(cmdbuf, &cmd_offset, SVGA_CMD_UPDATE, sizeof(SVGAFifoCmdUpdate));
+ update->x = blit->src_sx;
+ update->y = blit->src_sy;
+ update->width = blit->src_ex - blit->src_sx;
+ update->height = blit->src_ey - blit->src_sy;
+
+ submit_cmdbuf(cmd_offset, SVGA_CB_UPDATE, 0);
+
+ blit->num_changes = 0;
+
+ //dbg_printf("SVGA_draw\n");
+ }
+}
+
+static void SVGA_draw_cond(BOOL swap)
+{
+ if(swap)
+ {
+ if(!timer_set)
+ {
+ SVGA_draw(&wblit);
+ }
+ else
+ {
+ hda->onflip = 1;
+ async_watchdog();
+ }
+ }
+ else
+ {
+ if(!timer_set)
+ {
+ if(fb_lock_cnt == 0)
+ {
+ SVGA_draw(&wblit);
+ }
+ }
+ else
+ {
+ async_watchdog();
+ }
+ }
+}
@@ -2,8 +2,11 @@ #define __VXD_SVGA_H__INCLUDED__
/* consts */
-#define ST_REGION_ID 1
-#define ST_SURFACE_ID 1
+//#define ST_REGION_ID 1
+//#define ST_SURFACE_ID 1
+
+#define WRAM_REGION_ID 1
+#define WRAM_SURFACE_ID 1
#define ST_16BPP 1
#define ST_CURSOR 2
diff --git a/vxd_svga_cb.c b/vxd_svga_cb.c index 30d05e7..f76e21d 100644 --- a/vxd_svga_cb.c +++ b/vxd_svga_cb.c @@ -80,7 +80,7 @@ extern BOOL gb_support; extern BOOL cb_support;
extern BOOL cb_context0;
-extern BOOL surface_dirty;
+//extern BOOL surface_dirty;
//extern DWORD present_fence;
//extern BOOL ST_FB_invalid;
@@ -505,7 +505,7 @@ void SVGA_CMB_submit(DWORD FBPTR cmb, DWORD cmb_size, SVGA_CMB_status_t FBPTR st if(flags & SVGA_CB_DIRTY_SURFACE)
{
- surface_dirty = TRUE;
+ //surface_dirty = TRUE;
}
if(proc_by_cb)
diff --git a/vxd_svga_mem.c b/vxd_svga_mem.c index c61f39c..ada0a3c 100644 --- a/vxd_svga_mem.c +++ b/vxd_svga_mem.c @@ -419,7 +419,7 @@ BOOL SVGA_region_create(SVGA_region_info_t *rinfo) ULONG nPages = RoundToPages(new_size);
//ULONG nPages = RoundToPages64k(rinfo->size);
SVGAGuestMemDescriptor *desc;
- ULONG size_total = 0;
+ //ULONG size_total = 0;
DWORD pt_pages = PT_count(new_size);
@@ -440,16 +440,32 @@ BOOL SVGA_region_create(SVGA_region_info_t *rinfo) ULONG blk_pages_raw = 0;
/* allocate user block */
-
- if(!vxd_halloc(nPages+pt_pages, (void**)&maddr))
+ if(rinfo->alloctype == SVGA_REGION_ALLOC)
{
- Signal_Semaphore(mem_sem);
- return FALSE;
+ if(!vxd_halloc(nPages+pt_pages, (void**)&maddr))
+ {
+ Signal_Semaphore(mem_sem);
+ return FALSE;
+ }
+ cachePPN(maddr, nPages+pt_pages);
+ laddr = maddr + pt_pages*P_SIZE;
+ }
+ else
+ {
+ if(!vxd_halloc(pt_pages, (void**)&maddr))
+ {
+ Signal_Semaphore(mem_sem);
+ return FALSE;
+ }
+
+ if(rinfo->alloctype == SVGA_REGION_USE_USERMEM)
+ {
+ _LinPageLock(_PAGE((DWORD)rinfo->address), nPages, 0);
+ }
+
+ laddr = (DWORD)rinfo->address;
+ cachePPN(laddr, nPages);
}
-
- cachePPN(maddr, nPages+pt_pages);
-
- laddr = maddr + pt_pages*P_SIZE;
if(!rinfo->mobonly)
{
@@ -486,7 +502,7 @@ BOOL SVGA_region_create(SVGA_region_info_t *rinfo) //pgblk = _PageAllocate(blk_pages, pa_type, pa_vm, pa_align, 0x0, 0x100000, NULL, pa_flags);
if(!vxd_halloc(blk_pages, (void**)&pgblk))
{
- vxd_hfree((void*)laddr);
+ vxd_hfree((void*)maddr);
Signal_Semaphore(mem_sem);
return FALSE;
}
@@ -545,7 +561,7 @@ BOOL SVGA_region_create(SVGA_region_info_t *rinfo) rinfo->region_address = (void*)pgblk;
rinfo->region_ppn = getPPN(pgblk);
- size_total = (nPages + blk_pages + pt_pages)*P_SIZE;
+ //size_total = (nPages + blk_pages + pt_pages)*P_SIZE;
//dbg_printf(dbg_region_fragmented);
}
@@ -667,16 +683,98 @@ void SVGA_region_free(SVGA_region_info_t *rinfo) else
{
//_PageFree((PVOID)free_ptr, 0);
- vxd_hfree((PVOID)free_ptr);
+ if(rinfo->alloctype == SVGA_REGION_ALLOC)
+ {
+ vxd_hfree((PVOID)free_ptr);
+ }
}
-
+
+ if(rinfo->alloctype == SVGA_REGION_ALLOC)
+ {
+ rinfo->address = NULL;
+ }
+ else if(rinfo->alloctype == SVGA_REGION_USE_USERMEM)
+ {
+ _LinPageUnLock(_PAGE((DWORD)(rinfo->address)), RoundToPages(rinfo->size), 0);
+ }
+
//dbg_printf(dbg_pagefree_end, rinfo->region_id, rinfo->size, saved_in_cache);
Signal_Semaphore(mem_sem);
- rinfo->address = NULL;
rinfo->region_address = NULL;
rinfo->mob_address = NULL;
rinfo->region_ppn = 0;
rinfo->mob_ppn = 0;
rinfo->mob_pt_depth = 0;
}
+
+#define TMP_GMR_STARTID 1
+#define TMP_GMR_CNT 3
+
+typedef struct _tmp_gmr_t
+{
+ ULONG flat;
+ DWORD w;
+ DWORD h;
+ DWORD bpp;
+} tmp_gmr_t;
+
+static tmp_gmr_t tmp_gmr[TMP_GMR_CNT] = {{0}, {0}, {0}};
+
+static int tmp_gmr_cur = 0;
+
+/**
+ * Point temporary regions (1-3) to user memory.
+ * @param mem: linear address, it is required that point to system RAM and
+ * is align to page boundary
+ *
+ * return: GMR ID (1-3) on success or -1 on failure
+ *
+ **/
+int SVGA_region_focus(void FBPTR mem, DWORD w, DWORD h, DWORD bpp)
+{
+ ULONG flat = (ULONG)mem;
+ int i;
+ tmp_gmr_t *gmr;
+ SVGA_region_info_t *rinfo;
+
+ if((flat % P_SIZE) != 0) return -1;
+ for(i = 0; i < TMP_GMR_CNT; i++)
+ {
+ if(tmp_gmr[i].flat == flat)
+ {
+ if(tmp_gmr[i].w == w && tmp_gmr[i].h == h && tmp_gmr[i].bpp == bpp)
+ {
+ return TMP_GMR_STARTID+i;
+ }
+ break;
+ }
+ }
+
+ if(i == TMP_GMR_CNT)
+ {
+ i = tmp_gmr_cur;
+ tmp_gmr_cur = (tmp_gmr_cur + 1) % TMP_GMR_CNT;
+ }
+
+ gmr = tmp_gmr+i;
+ rinfo = &svga_db->regions[TMP_GMR_STARTID+i-1].info;
+
+ if(gmr->flat != 0)
+ {
+ SVGA_region_free(rinfo);
+ }
+
+ rinfo->region_id = TMP_GMR_STARTID+i;
+ rinfo->size = SVGA_pitch(w, bpp)*h;
+ rinfo->address = mem;
+ rinfo->alloctype = SVGA_REGION_USE_FIXEDMEM; // FIXME: check user mem!
+
+ if(SVGA_region_create(rinfo))
+ {
+ return TMP_GMR_STARTID+i;
+ }
+
+ return -1;
+}
+
@@ -99,6 +99,7 @@ void vesa_bios_V86(CRS_32 *V86regs) {
CRS_32 *pstate = ®_state;
+ _asm push ebx
// sizeof(CRS_32) = 108
_asm mov ebx, [ThisVM]
_asm mov ecx, [V86regs]
@@ -122,6 +123,7 @@ void vesa_bios_V86(CRS_32 *V86regs) //_asm mov esi, esp
_asm mov esi, [pstate]
VMMCall(Restore_Client_State)
+ _asm pop ebx
//_asm add esp, 128
}
@@ -241,7 +243,8 @@ static void mode_sort_freqs(int m) DWORD vram_phy = 0;
-static char VESA_conf_path[] = "Software\\vmdisp9x\\vesa";
+extern const char reg_path[];
+static const char VESA_conf_path[] = "Software\\vmdisp9x\\vesa";
void VESA_load_vbios_pm();
@@ -253,8 +256,8 @@ BOOL VESA_init_hw() dbg_printf("VESA init begin...\n");
+ RegReadConf(HKEY_LOCAL_MACHINE, reg_path, "WRAMSize", &wram_size);
RegReadConf(HKEY_LOCAL_MACHINE, VESA_conf_path, "VRAMLimit", &conf_vram_limit);
- RegReadConf(HKEY_LOCAL_MACHINE, VESA_conf_path, "WRAMSize", &wram_size);
RegReadConf(HKEY_LOCAL_MACHINE, VESA_conf_path, "MTRR", &conf_mtrr);
RegReadConf(HKEY_LOCAL_MACHINE, VESA_conf_path, "DosWindowSetMode", &conf_dos_window);
RegReadConf(HKEY_LOCAL_MACHINE, VESA_conf_path, "HWDoubleBuffer", &conf_hw_double_buf);
@@ -423,7 +426,8 @@ BOOL VESA_init_hw() if(vesa_modes_cnt == 0)
{
- return FALSE;
+ terrorf("No VESA modes found, bad VBIOS?\n");
+ tpause();
}
vesa_version = info->VESAVersion;
@@ -447,7 +451,9 @@ BOOL VESA_init_hw() if(!wram_init(wram_size*1024*1024))
{
- dbg_printf("cannot allocated %d MB RAM!\n", wram_size);
+ terrorf("Cannot alocate %d MB RAM!\n", wram_size);
+ terror("Please adjust WRAMSize registry key or increase physical RAM\n");
+ tpause();
return FALSE;
}
|
