Now using WIN32 event / wait functions in the Voodoo2 thread. I noticed a speed
improvement of around 10 % (tested with donut demo only). TODO: Use similar functions of the pthread library for improvements on other platforms.
This commit is contained in:
parent
bd39f8c103
commit
3cee1f74ee
@ -164,10 +164,18 @@ BX_THREAD_FUNC(cmdfifo_thread, indata)
|
||||
{
|
||||
UNUSED(indata);
|
||||
while (1) {
|
||||
#ifndef WIN32
|
||||
while (!v->fbi.cmdfifo[0].enable || (v->fbi.cmdfifo[0].depth < v->fbi.cmdfifo[0].depth_needed)) {
|
||||
BX_MSLEEP(1);
|
||||
}
|
||||
cmdfifo_process();
|
||||
#else
|
||||
if (WaitForSingleObject(v->fbi.cmdfifo[0].event, 1) == WAIT_OBJECT_0) {
|
||||
while (v->fbi.cmdfifo[0].enable && (v->fbi.cmdfifo[0].depth >= v->fbi.cmdfifo[0].depth_needed)) {
|
||||
cmdfifo_process();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
BX_THREAD_EXIT;
|
||||
}
|
||||
@ -187,6 +195,9 @@ bx_voodoo_c::~bx_voodoo_c()
|
||||
if (BX_VOODOO_THIS s.model == VOODOO_2) {
|
||||
BX_THREAD_KILL(cmdfifo_thread_var);
|
||||
BX_FINI_MUTEX(cmdfifo_mutex);
|
||||
#ifdef WIN32
|
||||
CloseHandle(v->fbi.cmdfifo[0].event);
|
||||
#endif
|
||||
}
|
||||
if (v != NULL) {
|
||||
free(v->fbi.ram);
|
||||
@ -245,6 +256,9 @@ void bx_voodoo_c::init(void)
|
||||
if (BX_VOODOO_THIS s.model == VOODOO_2) {
|
||||
v->fbi.cmdfifo[0].depth_needed = BX_MAX_BIT32U;
|
||||
BX_INIT_MUTEX(cmdfifo_mutex);
|
||||
#ifdef WIN32
|
||||
v->fbi.cmdfifo[0].event = CreateEvent(NULL, FALSE, FALSE, "cmdfifo_event");
|
||||
#endif
|
||||
BX_THREAD_CREATE(cmdfifo_thread, this, cmdfifo_thread_var);
|
||||
}
|
||||
|
||||
|
@ -1439,6 +1439,9 @@ struct _cmdfifo_info
|
||||
Bit32u depth; /* current depth */
|
||||
Bit32u depth_needed; /* depth needed for command */
|
||||
Bit32u holes; /* number of holes */
|
||||
#ifdef WIN32
|
||||
HANDLE event;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
|
@ -2466,6 +2466,11 @@ void cmdfifo_w(Bit32u fbi_offset, Bit32u data)
|
||||
if (v->fbi.cmdfifo[0].depth_needed == BX_MAX_BIT32U) {
|
||||
v->fbi.cmdfifo[0].depth_needed = cmdfifo_calc_depth_needed();
|
||||
}
|
||||
#ifdef WIN32
|
||||
if (v->fbi.cmdfifo[0].depth >= v->fbi.cmdfifo[0].depth_needed) {
|
||||
SetEvent(v->fbi.cmdfifo[0].event);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
Bit32u cmdfifo_r(void)
|
||||
|
Loading…
Reference in New Issue
Block a user