Turn all mutexes into critical sections

Removing all win32 mutexes and turning them into critical
sections, since mutexes in win32 are meant generally for
inter process communication, tend to be slower, and aren't
really needed for current purposes. Critical sections
are roughly equivalent to std::mutex in the c++ stl.
This commit is contained in:
luisjoseromero
2021-01-20 22:47:24 +00:00
parent df79a17dae
commit 9ddd0a841f
5 changed files with 34 additions and 74 deletions

View File

@@ -514,11 +514,11 @@ static void voodoo_writel(uint32_t addr, uint32_t val, void *p)
if (voodoo->initEnable & 0x01)
{
voodoo->fbiInit0 = val;
thread_wait_light_mutex(voodoo->force_blit_mutex);
thread_wait_mutex(voodoo->force_blit_mutex);
voodoo->can_blit = (voodoo->fbiInit0 & FBIINIT0_VGA_PASS) ? 1 : 0;
if (!voodoo->can_blit)
voodoo->force_blit_count = 0;
thread_release_light_mutex(voodoo->force_blit_mutex);
thread_release_mutex(voodoo->force_blit_mutex);
if (voodoo->set->nr_cards == 2)
svga_set_override(voodoo->svga, (voodoo->set->voodoos[0]->fbiInit0 | voodoo->set->voodoos[1]->fbiInit0) & 1);
@@ -887,17 +887,17 @@ static void voodoo_force_blit(void *p)
{
voodoo_set_t *voodoo_set = (voodoo_set_t *)p;
thread_wait_light_mutex(voodoo_set->voodoos[0]->force_blit_mutex);
thread_wait_mutex(voodoo_set->voodoos[0]->force_blit_mutex);
if(voodoo_set->voodoos[0]->can_blit) {
voodoo_set->voodoos[0]->force_blit_count++;
}
thread_release_light_mutex(voodoo_set->voodoos[0]->force_blit_mutex);
thread_release_mutex(voodoo_set->voodoos[0]->force_blit_mutex);
if(voodoo_set->nr_cards == 2) {
thread_wait_light_mutex(voodoo_set->voodoos[1]->force_blit_mutex);
thread_wait_mutex(voodoo_set->voodoos[1]->force_blit_mutex);
if(voodoo_set->voodoos[1]->can_blit) {
voodoo_set->voodoos[1]->force_blit_count++;
}
thread_release_light_mutex(voodoo_set->voodoos[1]->force_blit_mutex);
thread_release_mutex(voodoo_set->voodoos[1]->force_blit_mutex);
}
}
@@ -1041,7 +1041,7 @@ void *voodoo_card_init()
voodoo->force_blit_count = 0;
voodoo->can_blit = 0;
voodoo->force_blit_mutex = thread_create_light_mutex();
voodoo->force_blit_mutex = thread_create_mutex_with_spin_count(MUTEX_DEFAULT_SPIN_COUNT);
return voodoo;
}
@@ -1158,7 +1158,7 @@ void *voodoo_2d3d_card_init(int type)
voodoo->force_blit_count = 0;
voodoo->can_blit = 0;
voodoo->force_blit_mutex = thread_create_light_mutex();
voodoo->force_blit_mutex = thread_create_mutex_with_spin_count(MUTEX_DEFAULT_SPIN_COUNT);
return voodoo;
}
@@ -1274,7 +1274,7 @@ void voodoo_card_close(voodoo_t *voodoo)
free(voodoo->tex_mem[0]);
}
thread_close_light_mutex(voodoo->force_blit_mutex);
thread_close_mutex(voodoo->force_blit_mutex);
free(voodoo);
}

View File

@@ -646,13 +646,13 @@ skip_draw:
if (voodoo->line == voodoo->v_disp)
{
int force_blit = 0;
thread_wait_light_mutex(voodoo->force_blit_mutex);
thread_wait_mutex(voodoo->force_blit_mutex);
if(voodoo->force_blit_count) {
force_blit = 1;
if(--voodoo->force_blit_count < 0)
voodoo->force_blit_count = 0;
}
thread_release_light_mutex(voodoo->force_blit_mutex);
thread_release_mutex(voodoo->force_blit_mutex);
if (voodoo->dirty_line_high > voodoo->dirty_line_low || force_blit)
svga_doblit(0, voodoo->v_disp, voodoo->h_disp, voodoo->v_disp-1, voodoo->svga);