mirror of
https://github.com/libretro/RetroArch
synced 2025-04-03 10:21:31 +00:00
Merge pull request #9942 from libretro/fix_video_filters
Only use threads when the number > 1
This commit is contained in:
commit
c0160095fa
@ -237,26 +237,28 @@ static bool create_softfilter_graph(rarch_softfilter_t *filt,
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_THREADS
|
#ifdef HAVE_THREADS
|
||||||
filt->thread_data = (struct filter_thread_data*)
|
if(filt->threads>1){
|
||||||
calloc(threads, sizeof(*filt->thread_data));
|
filt->thread_data = (struct filter_thread_data*)
|
||||||
if (!filt->thread_data)
|
calloc(threads, sizeof(*filt->thread_data));
|
||||||
return false;
|
if (!filt->thread_data)
|
||||||
|
return false;
|
||||||
|
|
||||||
for (i = 0; i < threads; i++)
|
for (i = 0; i < threads; i++)
|
||||||
{
|
{
|
||||||
filt->thread_data[i].userdata = filt->impl_data;
|
filt->thread_data[i].userdata = filt->impl_data;
|
||||||
filt->thread_data[i].done = true;
|
filt->thread_data[i].done = true;
|
||||||
|
|
||||||
filt->thread_data[i].lock = slock_new();
|
filt->thread_data[i].lock = slock_new();
|
||||||
if (!filt->thread_data[i].lock)
|
if (!filt->thread_data[i].lock)
|
||||||
return false;
|
return false;
|
||||||
filt->thread_data[i].cond = scond_new();
|
filt->thread_data[i].cond = scond_new();
|
||||||
if (!filt->thread_data[i].cond)
|
if (!filt->thread_data[i].cond)
|
||||||
return false;
|
return false;
|
||||||
filt->thread_data[i].thread = sthread_create(
|
filt->thread_data[i].thread = sthread_create(
|
||||||
filter_thread_loop, &filt->thread_data[i]);
|
filter_thread_loop, &filt->thread_data[i]);
|
||||||
if (!filt->thread_data[i].thread)
|
if (!filt->thread_data[i].thread)
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -475,19 +477,21 @@ void rarch_softfilter_free(rarch_softfilter_t *filt)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_THREADS
|
#ifdef HAVE_THREADS
|
||||||
for (i = 0; i < filt->threads; i++)
|
if(filt->threads>1){
|
||||||
{
|
for (i = 0; i < filt->threads; i++)
|
||||||
if (!filt->thread_data[i].thread)
|
{
|
||||||
continue;
|
if (!filt->thread_data[i].thread)
|
||||||
slock_lock(filt->thread_data[i].lock);
|
continue;
|
||||||
filt->thread_data[i].die = true;
|
slock_lock(filt->thread_data[i].lock);
|
||||||
scond_signal(filt->thread_data[i].cond);
|
filt->thread_data[i].die = true;
|
||||||
slock_unlock(filt->thread_data[i].lock);
|
scond_signal(filt->thread_data[i].cond);
|
||||||
sthread_join(filt->thread_data[i].thread);
|
slock_unlock(filt->thread_data[i].lock);
|
||||||
slock_free(filt->thread_data[i].lock);
|
sthread_join(filt->thread_data[i].thread);
|
||||||
scond_free(filt->thread_data[i].cond);
|
slock_free(filt->thread_data[i].lock);
|
||||||
|
scond_free(filt->thread_data[i].cond);
|
||||||
|
}
|
||||||
|
free(filt->thread_data);
|
||||||
}
|
}
|
||||||
free(filt->thread_data);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (filt->conf)
|
if (filt->conf)
|
||||||
@ -533,29 +537,34 @@ void rarch_softfilter_process(rarch_softfilter_t *filt,
|
|||||||
output, output_stride, input, width, height, input_stride);
|
output, output_stride, input, width, height, input_stride);
|
||||||
|
|
||||||
#ifdef HAVE_THREADS
|
#ifdef HAVE_THREADS
|
||||||
/* Fire off workers */
|
if(filt->threads>1){
|
||||||
for (i = 0; i < filt->threads; i++)
|
/* Fire off workers */
|
||||||
{
|
for (i = 0; i < filt->threads; i++)
|
||||||
|
{
|
||||||
#if 0
|
#if 0
|
||||||
RARCH_LOG("Firing off filter thread %u ...\n", i);
|
RARCH_LOG("Firing off filter thread %u ...\n", i);
|
||||||
#endif
|
#endif
|
||||||
filt->thread_data[i].packet = &filt->packets[i];
|
filt->thread_data[i].packet = &filt->packets[i];
|
||||||
slock_lock(filt->thread_data[i].lock);
|
slock_lock(filt->thread_data[i].lock);
|
||||||
filt->thread_data[i].done = false;
|
filt->thread_data[i].done = false;
|
||||||
scond_signal(filt->thread_data[i].cond);
|
scond_signal(filt->thread_data[i].cond);
|
||||||
slock_unlock(filt->thread_data[i].lock);
|
slock_unlock(filt->thread_data[i].lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Wait for workers */
|
/* Wait for workers */
|
||||||
for (i = 0; i < filt->threads; i++)
|
for (i = 0; i < filt->threads; i++)
|
||||||
{
|
{
|
||||||
#if 0
|
#if 0
|
||||||
RARCH_LOG("Waiting for filter thread %u ...\n", i);
|
RARCH_LOG("Waiting for filter thread %u ...\n", i);
|
||||||
#endif
|
#endif
|
||||||
slock_lock(filt->thread_data[i].lock);
|
slock_lock(filt->thread_data[i].lock);
|
||||||
while (!filt->thread_data[i].done)
|
while (!filt->thread_data[i].done)
|
||||||
scond_wait(filt->thread_data[i].cond, filt->thread_data[i].lock);
|
scond_wait(filt->thread_data[i].cond, filt->thread_data[i].lock);
|
||||||
slock_unlock(filt->thread_data[i].lock);
|
slock_unlock(filt->thread_data[i].lock);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (i = 0; i < filt->threads; i++)
|
||||||
|
filt->packets[i].work(filt->impl_data, filt->packets[i].thread_data);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
for (i = 0; i < filt->threads; i++)
|
for (i = 0; i < filt->threads; i++)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user