mirror of https://github.com/snes9xgit/snes9x.git
GTK+: Fix threaded filters.
This commit is contained in:
parent
ebf1b6dadc
commit
93a99a4807
|
@ -1100,6 +1100,21 @@ create_thread_pool ()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void wait_for_jobs_to_complete ()
|
||||||
|
{
|
||||||
|
while (1)
|
||||||
|
{
|
||||||
|
int complete = 1;
|
||||||
|
for (int i = 0; i < gui_config->num_threads; i++)
|
||||||
|
complete = complete && job[i].complete;
|
||||||
|
|
||||||
|
if (complete)
|
||||||
|
break;
|
||||||
|
|
||||||
|
sched_yield ();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
internal_threaded_convert (void *src_buffer,
|
internal_threaded_convert (void *src_buffer,
|
||||||
void *dst_buffer,
|
void *dst_buffer,
|
||||||
|
@ -1131,17 +1146,7 @@ internal_threaded_convert (void *src_buffer,
|
||||||
g_thread_pool_push (pool, (gpointer) &(job[i]), NULL);
|
g_thread_pool_push (pool, (gpointer) &(job[i]), NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
while (1)
|
wait_for_jobs_to_complete ();
|
||||||
{
|
|
||||||
int complete = 1;
|
|
||||||
for (int i = 0; i < gui_config->num_threads; i++)
|
|
||||||
complete = complete && job[i].complete;
|
|
||||||
|
|
||||||
if (complete)
|
|
||||||
break;
|
|
||||||
|
|
||||||
sched_yield ();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void internal_threaded_convert_mask (void *src_buffer,
|
static void internal_threaded_convert_mask (void *src_buffer,
|
||||||
|
@ -1180,17 +1185,7 @@ static void internal_threaded_convert_mask (void *src_buffer,
|
||||||
g_thread_pool_push (pool, (gpointer) &(job[i]), NULL);
|
g_thread_pool_push (pool, (gpointer) &(job[i]), NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
while (1)
|
wait_for_jobs_to_complete ();
|
||||||
{
|
|
||||||
int complete = 1;
|
|
||||||
for (int i = 0; i < gui_config->num_threads; i++)
|
|
||||||
complete = complete && job[i].complete;
|
|
||||||
|
|
||||||
if (complete)
|
|
||||||
break;
|
|
||||||
|
|
||||||
sched_yield ();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void internal_threaded_filter (uint8 *src_buffer,
|
static void internal_threaded_filter (uint8 *src_buffer,
|
||||||
|
@ -1200,14 +1195,16 @@ static void internal_threaded_filter (uint8 *src_buffer,
|
||||||
int &width,
|
int &width,
|
||||||
int &height)
|
int &height)
|
||||||
{
|
{
|
||||||
int src_coverage = 0, dst_coverage = 0;
|
int dst_width = width, dst_height = height;
|
||||||
int xscale = 1, yscale = 1;
|
|
||||||
|
|
||||||
get_filter_scale (xscale, yscale);
|
|
||||||
|
|
||||||
/* If the threadpool doesn't exist, create it */
|
/* If the threadpool doesn't exist, create it */
|
||||||
create_thread_pool ();
|
create_thread_pool ();
|
||||||
|
|
||||||
|
get_filter_scale (dst_width, dst_height);
|
||||||
|
|
||||||
|
int yscale = dst_height / height;
|
||||||
|
int coverage = 0;
|
||||||
|
|
||||||
for (int i = 0; i < gui_config->num_threads; i++)
|
for (int i = 0; i < gui_config->num_threads; i++)
|
||||||
{
|
{
|
||||||
job[i].operation_type = JOB_FILTER;
|
job[i].operation_type = JOB_FILTER;
|
||||||
|
@ -1215,28 +1212,17 @@ static void internal_threaded_filter (uint8 *src_buffer,
|
||||||
job[i].width = width;
|
job[i].width = width;
|
||||||
job[i].src_pitch = src_pitch;
|
job[i].src_pitch = src_pitch;
|
||||||
job[i].dst_pitch = dst_pitch;
|
job[i].dst_pitch = dst_pitch;
|
||||||
job[i].src_buffer = src_buffer + (src_pitch * src_coverage);
|
job[i].src_buffer = src_buffer + (src_pitch * coverage);
|
||||||
job[i].dst_buffer = dst_buffer + (dst_pitch * dst_coverage);
|
job[i].dst_buffer = dst_buffer + (dst_pitch * coverage * yscale);
|
||||||
job[i].height = (height / gui_config->num_threads) & ~3; /* Cut to multiple of 4 */
|
job[i].height = (height / gui_config->num_threads) & ~3; /* Cut to multiple of 4 */
|
||||||
if (i == gui_config->num_threads - 1)
|
if (i == gui_config->num_threads - 1)
|
||||||
job[i].height = height - src_coverage;
|
job[i].height = height - coverage;
|
||||||
src_coverage += job[i].height;
|
coverage += job[i].height;
|
||||||
dst_coverage += job[i].height * yscale;
|
|
||||||
|
|
||||||
g_thread_pool_push (pool, (gpointer) &(job[i]), NULL);
|
g_thread_pool_push (pool, (gpointer) &(job[i]), NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
while (1)
|
wait_for_jobs_to_complete ();
|
||||||
{
|
|
||||||
int complete = 1;
|
|
||||||
for (int i = 0; i < gui_config->num_threads; i++)
|
|
||||||
complete = complete && job[i].complete;
|
|
||||||
|
|
||||||
if (complete)
|
|
||||||
break;
|
|
||||||
|
|
||||||
sched_yield ();
|
|
||||||
}
|
|
||||||
|
|
||||||
get_filter_scale (width, height);
|
get_filter_scale (width, height);
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,14 +73,10 @@ typedef struct thread_job_t
|
||||||
int dst_pitch;
|
int dst_pitch;
|
||||||
int width;
|
int width;
|
||||||
int height;
|
int height;
|
||||||
int dst_width;
|
|
||||||
int dst_height;
|
|
||||||
int bpp;
|
int bpp;
|
||||||
int inv_rmask;
|
int inv_rmask;
|
||||||
int inv_gmask;
|
int inv_gmask;
|
||||||
int inv_bmask;
|
int inv_bmask;
|
||||||
int line_start;
|
|
||||||
int line_end;
|
|
||||||
|
|
||||||
volatile bool complete;
|
volatile bool complete;
|
||||||
} thread_job_t;
|
} thread_job_t;
|
||||||
|
|
Loading…
Reference in New Issue