Merge pull request #9942 from libretro/fix_video_filters

Only use threads when the number > 1
This commit is contained in:
Twinaphex 2020-01-04 16:42:12 +01:00 committed by GitHub
commit c0160095fa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -237,6 +237,7 @@ static bool create_softfilter_graph(rarch_softfilter_t *filt,
}
#ifdef HAVE_THREADS
if(filt->threads>1){
filt->thread_data = (struct filter_thread_data*)
calloc(threads, sizeof(*filt->thread_data));
if (!filt->thread_data)
@ -258,6 +259,7 @@ static bool create_softfilter_graph(rarch_softfilter_t *filt,
if (!filt->thread_data[i].thread)
return false;
}
}
#endif
return true;
@ -475,6 +477,7 @@ void rarch_softfilter_free(rarch_softfilter_t *filt)
#endif
#ifdef HAVE_THREADS
if(filt->threads>1){
for (i = 0; i < filt->threads; i++)
{
if (!filt->thread_data[i].thread)
@ -488,6 +491,7 @@ void rarch_softfilter_free(rarch_softfilter_t *filt)
scond_free(filt->thread_data[i].cond);
}
free(filt->thread_data);
}
#endif
if (filt->conf)
@ -533,6 +537,7 @@ void rarch_softfilter_process(rarch_softfilter_t *filt,
output, output_stride, input, width, height, input_stride);
#ifdef HAVE_THREADS
if(filt->threads>1){
/* Fire off workers */
for (i = 0; i < filt->threads; i++)
{
@ -557,6 +562,10 @@ void rarch_softfilter_process(rarch_softfilter_t *filt,
scond_wait(filt->thread_data[i].cond, 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
for (i = 0; i < filt->threads; i++)
filt->packets[i].work(filt->impl_data, filt->packets[i].thread_data);