aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJaroslav Hensl <emulator@emulace.cz>2024-02-22 00:11:41 +0100
committerJaroslav Hensl <emulator@emulace.cz>2024-02-22 00:11:41 +0100
commit1725ae3a841d51e8fda682ad8a8265cc760e1e16 (patch)
tree142dc6840764068b09a58f039e416ab63d983080
parent742ae4829e1e3fa3b55be838d4ea049fd62e6616 (diff)
downloadvmdisp9x-1725ae3a841d51e8fda682ad8a8265cc760e1e16.tar.gz
VXD optimizations, fixed mouse blit bug, barriers and memory management
-rw-r--r--3d_accel.h6
-rw-r--r--enable.c16
-rw-r--r--makefile6
-rw-r--r--vxd_lib.c4
-rw-r--r--vxd_lib.h4
-rw-r--r--vxd_main.c3
-rw-r--r--vxd_mouse_conv.h8
-rw-r--r--vxd_svga.c109
8 files changed, 109 insertions, 47 deletions
diff --git a/3d_accel.h b/3d_accel.h
index a263afb..3a69afe 100644
--- a/3d_accel.h
+++ b/3d_accel.h
@@ -59,6 +59,7 @@ THE SOFTWARE.
#define OP_SVGA_QUERY_VECTOR 0x200E /* VXD */
#define OP_SVGA_DB_SETUP 0x200F /* VXD */
#define OP_SVGA_OT_SETUP 0x2010 /* VXD */
+#define OP_SVGA_FLUSHCACHE 0x2011 /* VXD */
#define OP_VBE_VALID 0x3000 /* VXD, DRV */
#define OP_VBE_SETMODE 0x3001 /* DRV */
@@ -113,6 +114,7 @@ typedef struct FBHDA
#define FB_ACCEL_VMSVGA3D 32
#define FB_ACCEL_VMSVGA10 64
#define FB_MOUSE_NO_BLIT 128
+#define FB_FORCE_SOFTWARE 256
/* for internal use in RING-0 by VXD only */
BOOL FBHDA_init_hw();
@@ -206,6 +208,8 @@ typedef struct SVGA_DB_surface
DWORD height;
DWORD bpp;
DWORD gmrId; /* != 0 for GB surfaces */
+ DWORD gmrMngt; /* 1 when auto destroy MOB and region when releasing surface */
+ DWORD size; /* surface size in bytes */
} SVGA_DB_surface_t;
typedef struct SVGA_DB
@@ -284,6 +288,8 @@ typedef struct SVGA_OT_info_entry
SVGA_OT_info_entry_t *SVGA_OT_setup();
+void SVGA_flushcache();
+
#endif /* SVGA */
/*
diff --git a/enable.c b/enable.c
index c7434d7..544bc11 100644
--- a/enable.c
+++ b/enable.c
@@ -146,12 +146,10 @@ DWORD PASCAL CreateDIBPDeviceX( LPBITMAPINFO lpInfo, LPPDEVICE lpDevice, LPVOID
VOID WINAPI __loadds BeginAccess_VXD( LPPDEVICE lpDevice, WORD wLeft, WORD wTop, WORD wRight, WORD wBottom, WORD wFlags )
{
DWORD dflags = 0;
- if(!(wFlags & CURSOREXCLUDE))
+ if(wFlags & CURSOREXCLUDE)
{
- dflags |= FBHDA_IGNORE_CURSOR;
+ FBHDA_access_begin(dflags);
}
-
- FBHDA_access_begin(dflags);
if(!mouse_vxd)
{
DIB_BeginAccess(lpDevice, wLeft, wTop, wRight, wBottom, wFlags);
@@ -161,16 +159,14 @@ VOID WINAPI __loadds BeginAccess_VXD( LPPDEVICE lpDevice, WORD wLeft, WORD wTop,
VOID WINAPI __loadds EndAccess_VXD( LPPDEVICE lpDevice, WORD wFlags )
{
DWORD dflags = 0;
- if(!(wFlags & CURSOREXCLUDE))
- {
- dflags |= FBHDA_IGNORE_CURSOR;
- }
-
if(!mouse_vxd)
{
DIB_EndAccess(lpDevice, wFlags);
}
- FBHDA_access_end(dflags);
+ if(wFlags & CURSOREXCLUDE)
+ {
+ FBHDA_access_end(dflags);
+ }
}
diff --git a/makefile b/makefile
index 0635e2b..c02bc10 100644
--- a/makefile
+++ b/makefile
@@ -11,7 +11,7 @@ OBJS += &
INCS = -I$(%WATCOM)\h\win -Iddk -Ivmware
-VER_BUILD = 32
+VER_BUILD = 34
FLAGS = -DDRV_VER_BUILD=$(VER_BUILD)
@@ -32,13 +32,15 @@ DBGFILE =
DBGFILE32 =
!endif
CFLAGS = -q -wx -s -zu -zls -6 -fp6
-CFLAGS32 = -q -wx -s -zls -6s -fp6 -mf -DVXD32
+CFLAGS32 = -q -wx -s -zls -6s -fp6 -mf -DVXD32 -fpi87 -ei -oeatxhn
CC = wcc
CC32 = wcc386
# Log VXD to com2
!ifdef DBGPRINT
CFLAGS32 += -DCOM2
+!else
+CFLAGS32 += -d0
!endif
#all : boxvmini.drv vmwsmini.drv qemumini.drv vmwsmini.vxd qemumini.vxd
diff --git a/vxd_lib.c b/vxd_lib.c
index 07fc652..5c77b58 100644
--- a/vxd_lib.c
+++ b/vxd_lib.c
@@ -101,7 +101,7 @@ DWORD Get_VMM_Version()
return ver;
}
-void __cdecl Begin_Critical_Section(ULONG Flags)
+volatile void __cdecl Begin_Critical_Section(ULONG Flags)
{
static ULONG sFlags;
sFlags = Flags;
@@ -112,7 +112,7 @@ void __cdecl Begin_Critical_Section(ULONG Flags)
_asm pop ecx
}
-void __cdecl End_Critical_Section()
+volatile void __cdecl End_Critical_Section()
{
VMMCall(End_Critical_Section);
}
diff --git a/vxd_lib.h b/vxd_lib.h
index 4589be9..760e8f6 100644
--- a/vxd_lib.h
+++ b/vxd_lib.h
@@ -39,8 +39,8 @@ ULONG __cdecl _PhysIntoV86(ULONG PhysPage, ULONG VM, ULONG VMLinPgNum, ULONG nPa
DWORD __cdecl _RegOpenKey(DWORD hKey, char *lpszSubKey, DWORD *lphKey);
DWORD __cdecl _RegCloseKey(DWORD hKey);
DWORD __cdecl _RegQueryValueEx(DWORD hKey, char *lpszValueName, DWORD *lpdwReserved, DWORD *lpdwType, BYTE *lpbData, DWORD *lpcbData);
-void __cdecl Begin_Critical_Section(ULONG Flags);
-void __cdecl End_Critical_Section();
+volatile void __cdecl Begin_Critical_Section(ULONG Flags);
+volatile void __cdecl End_Critical_Section();
ULONG __cdecl Create_Semaphore(ULONG TokenCount);
void __cdecl Destroy_Semaphore(ULONG SemHandle);
void __cdecl Wait_Semaphore(ULONG semHandle, ULONG flags);
diff --git a/vxd_main.c b/vxd_main.c
index bb2e967..499112f 100644
--- a/vxd_main.c
+++ b/vxd_main.c
@@ -550,6 +550,9 @@ DWORD __stdcall Device_IO_Control_proc(struct DIOCParams *params)
case OP_SVGA_OT_SETUP:
outBuf[0] = (DWORD)SVGA_OT_setup();
return 0;
+ case OP_SVGA_FLUSHCACHE:
+ SVGA_flushcache();
+ return 0;
#endif /* SVGA */
}
diff --git a/vxd_mouse_conv.h b/vxd_mouse_conv.h
index 62071fb..778e5c8 100644
--- a/vxd_mouse_conv.h
+++ b/vxd_mouse_conv.h
@@ -6,24 +6,28 @@ static BOOL calc_save(int x, int y)
if(mouse_swap_x < 0)
{
- mouse_swap_w -= x;
+ mouse_swap_w += mouse_swap_x;
mouse_swap_x = 0;
}
if(mouse_swap_x + mouse_swap_w > hda->width)
+ {
mouse_swap_w = hda->width - mouse_swap_x;
+ }
mouse_swap_h = mouse_h;
mouse_swap_y = y - mouse_pointy;
if(mouse_swap_y < 0)
{
- mouse_swap_h -= y;
+ mouse_swap_h += mouse_swap_y;
mouse_swap_y = 0;
}
if(mouse_swap_y + mouse_swap_h > hda->height)
+ {
mouse_swap_h = hda->height - mouse_swap_y;
+ }
if(mouse_swap_w <= 0 || mouse_swap_h <= 0)
{
diff --git a/vxd_svga.c b/vxd_svga.c
index faa445d..6484789 100644
--- a/vxd_svga.c
+++ b/vxd_svga.c
@@ -63,7 +63,6 @@ THE SOFTWARE.
#pragma pack(1)
typedef struct _cb_enable_t
{
-// SVGACBHeader cbheader;
uint32 cmd;
SVGADCCmdStartStop cbstart;
} cb_enable_t;
@@ -84,7 +83,7 @@ static BOOL cb_context0 = FALSE;
static BOOL SVGA_is_valid = FALSE;
-static SVGACBHeader *last_cb = NULL;
+static volatile SVGACBHeader *last_cb = NULL;
/* temp for reading registry */
static union
@@ -139,10 +138,8 @@ static void SVGA_Sync()
SVGA_WriteReg(SVGA_REG_SYNC, 1);
}
-static void SVGA_Flush_CB()
+static void SVGA_Flush_CB_critical()
{
- Begin_Critical_Section(0);
-
/* wait for actual CB */
if(last_cb != NULL)
{
@@ -154,7 +151,12 @@ static void SVGA_Flush_CB()
/* drain FIFO */
SVGA_Flush();
-
+}
+
+static void SVGA_Flush_CB()
+{
+ Begin_Critical_Section(0);
+ SVGA_Flush_CB_critical();
End_Critical_Section();
}
@@ -386,8 +388,7 @@ DWORD *SVGA_CMB_alloc()
void SVGA_CMB_free(DWORD *cmb)
{
- SVGACBHeader *cb = (SVGACBHeader *)cmb;
- --cb;
+ SVGACBHeader *cb = ((SVGACBHeader *)cmb)-1;
Begin_Critical_Section(0);
@@ -475,6 +476,7 @@ void SVGA_CMB_submit(DWORD FBPTR cmb, DWORD cmb_size, SVGA_CMB_status_t FBPTR st
cb->id.hi = cb_next_id.hi;
cb->length = cmb_size;
+#if 0
/* wait for last CB to complete */
if(last_cb && cb != last_cb)
{
@@ -483,12 +485,11 @@ void SVGA_CMB_submit(DWORD FBPTR cmb, DWORD cmb_size, SVGA_CMB_status_t FBPTR st
SVGA_Sync();
}
}
+#endif
- //Begin_Critical_Section(0);
SVGA_WriteReg(SVGA_REG_COMMAND_HIGH, 0); // high part of 64-bit memory address...
- SVGA_WriteReg(SVGA_REG_COMMAND_LOW, cb->ptr.pa.low - sizeof(SVGACBHeader) | cbhwctxid);
+ SVGA_WriteReg(SVGA_REG_COMMAND_LOW, (cb->ptr.pa.low - sizeof(SVGACBHeader)) | cbhwctxid);
SVGA_Sync();
- //End_Critical_Section();
last_cb = cb;
@@ -543,8 +544,6 @@ void SVGA_CMB_submit(DWORD FBPTR cmb, DWORD cmb_size, SVGA_CMB_status_t FBPTR st
dwords += 2;
- //Begin_Critical_Section(0);
-
nextCmd = gSVGA.fifoMem[SVGA_FIFO_NEXT_CMD];
max = gSVGA.fifoMem[SVGA_FIFO_MAX];
min = gSVGA.fifoMem[SVGA_FIFO_MIN];
@@ -564,8 +563,6 @@ void SVGA_CMB_submit(DWORD FBPTR cmb, DWORD cmb_size, SVGA_CMB_status_t FBPTR st
dwords--;
}
- //End_Critical_Section();
-
if(flags & SVGA_CB_SYNC)
{
SVGA_fence_wait(fence);
@@ -967,21 +964,17 @@ BOOL SVGA_region_create(SVGA_region_info_t *rinfo)
spare_region_used:
- End_Critical_Section();
-
// JH: no need here
//SVGA_Flush_CB();
if(rinfo->region_id <= SVGA_ReadReg(SVGA_REG_GMR_MAX_IDS))
{
/* register GMR */
- Begin_Critical_Section(0);
SVGA_WriteReg(SVGA_REG_GMR_ID, rinfo->region_id);
SVGA_WriteReg(SVGA_REG_GMR_DESCRIPTOR, rinfo->region_ppn);
SVGA_Sync(); // notify register change
- End_Critical_Section();
- SVGA_Flush_CB();
+ SVGA_Flush_CB_critical();
}
else
{
@@ -989,6 +982,8 @@ BOOL SVGA_region_create(SVGA_region_info_t *rinfo)
rinfo->region_ppn = 0;
}
+ End_Critical_Section();
+
//dbg_printf(dbg_gmr_succ, rinfo->size);
return TRUE;
@@ -1002,14 +997,13 @@ void SVGA_region_free(SVGA_region_info_t *rinfo)
{
BYTE *free_ptr = (BYTE*)rinfo->address;
- SVGA_Flush_CB();
-
Begin_Critical_Section(0);
+ SVGA_Sync();
+ SVGA_Flush_CB_critical();
+
SVGA_WriteReg(SVGA_REG_GMR_ID, rinfo->region_id);
SVGA_WriteReg(SVGA_REG_GMR_DESCRIPTOR, 0);
SVGA_Sync(); // notify register change
-
- //SVGA_Flush_CB();
/* save 2 large regions */
if(rinfo->size >= SPARE_REGION_LARGE_SIZE)
@@ -1073,8 +1067,53 @@ void SVGA_region_free(SVGA_region_info_t *rinfo)
rinfo->mob_address = NULL;
rinfo->region_ppn = 0;
rinfo->mob_ppn = 0;
+
+}
+
+/**
+ * Destroy saved regions and free memory
+ *
+ **/
+void SVGA_flushcache()
+{
+ int i;
+
+ Begin_Critical_Section(0);
+
+ for(i = 0; i < SPARE_REGIONS; i++)
+ {
+ if(spare_regions[i].used != FALSE)
+ {
+ SVGA_region_info_t *rinfo = &spare_regions[i].region;
+ BYTE *free_ptr = (BYTE*)rinfo->address;
+
+ spare_regions[i].used = FALSE;
+
+ if(rinfo->region_address != NULL)
+ {
+ dbg_printf(dbg_pagefree, rinfo->region_address);
+ _PageFree((PVOID)rinfo->region_address, 0);
+ }
+ else
+ {
+ free_ptr -= P_SIZE;
+ }
+
+ if(rinfo->mob_address != NULL)
+ {
+ dbg_printf(dbg_pagefree, rinfo->mob_address);
+ _PageFree((PVOID)rinfo->mob_address, 0);
+ }
+
+ dbg_printf(dbg_pagefree, free_ptr);
+ _PageFree((PVOID)free_ptr, 0);
+ }
+ }
+
+ End_Critical_Section();
}
+
/**
* GPU10: start context0
*
@@ -1285,14 +1324,22 @@ BOOL SVGA_setmode(DWORD w, DWORD h, DWORD bpp)
return FALSE;
}
+ /* free chached regions */
+ SVGA_flushcache();
+
+ FBHDA_access_begin(0);
+
+ Begin_Critical_Section(0);
+
/* Make sure, that we drain full FIFO */
- SVGA_Flush_CB();
+ SVGA_Sync();
+ SVGA_Flush_CB_critical();
/* stop command buffer context 0 */
SVGA_CB_stop();
SVGA_SetModeLegacy(w, h, bpp); /* setup by legacy registry */
- SVGA_Flush_CB(); /* make sure, that is really set */
+ SVGA_Flush_CB_critical(); /* make sure, that is really set */
has3D = SVGA3D_Init();
@@ -1300,9 +1347,9 @@ BOOL SVGA_setmode(DWORD w, DWORD h, DWORD bpp)
if(SVGA_hasAccelScreen())
{
SVGA_defineScreen(w, h, bpp);
- SVGA_Flush_CB();
+ SVGA_Flush_CB_critical();
}
-
+
/* start command buffer context 0 */
SVGA_CB_start();
@@ -1326,7 +1373,7 @@ BOOL SVGA_setmode(DWORD w, DWORD h, DWORD bpp)
SVGA_WriteReg(SVGA_REG_ENABLE, TRUE);
SVGA_Sync();
- SVGA_Flush_CB();
+ SVGA_Flush_CB_critical();
hda->width = SVGA_ReadReg(SVGA_REG_WIDTH);
hda->height = SVGA_ReadReg(SVGA_REG_HEIGHT);
@@ -1345,6 +1392,10 @@ BOOL SVGA_setmode(DWORD w, DWORD h, DWORD bpp)
{
hda->flags &= ~((DWORD)FB_ACCEL_VMSVGA3D);
}
+
+ End_Critical_Section();
+
+ FBHDA_access_end(0);
return TRUE;
}