aboutsummaryrefslogtreecommitdiff
path: root/gtk
diff options
context:
space:
mode:
authorTakamichi Horikawa <takamichiho@gmail.com>2017-04-01 14:53:59 +0900
committerTakamichi Horikawa <takamichiho@gmail.com>2017-04-01 14:53:59 +0900
commit24225349831278c23c6dfc4515e071f4b27b2c41 (patch)
tree35a853f7f35a53560a5b1bcfd5eda3213990b872 /gtk
parent5460067b61f86843a0435ebb06a6ebb8223c3dca (diff)
add sse2/ssse3 simd optimization
Diffstat (limited to 'gtk')
-rw-r--r--gtk/Makefile.am21
-rw-r--r--gtk/configure.ac8
-rw-r--r--gtk/main.c32
3 files changed, 51 insertions, 10 deletions
diff --git a/gtk/Makefile.am b/gtk/Makefile.am
index 0a9a95b..5d75f84 100644
--- a/gtk/Makefile.am
+++ b/gtk/Makefile.am
@@ -18,12 +18,29 @@ FMDSP_SRC=../fmdsp/fmdsp.c \
../fmdsp/font_rom.c \
../fmdsp/font_fmdsp_small.c
+#fmplayer_CFLAGS=$(CFLAGS)
+#CFLAGS=
+fmplayer_CPPFLAGS=-Wall -Wextra -pedantic \
+ -I.. \
+ $(GTK3_CFLAGS) $(PORTAUDIO_CFLAGS)
+fmplayer_LDADD=$(GTK3_LIBS) $(PORTAUDIO_LIBS)
+
if ENABLE_NEON
LIBOPNA_SRC+=../libopna/opnassg-sinc-neon.s
FMDSP_SRC+=../fmdsp/fmdsp-vramlookup-neon.s
fmplayer_CCASFLAGS=-march=armv8-a -mfpu=crypto-neon-fp-armv8
endif
+if ENABLE_SSE
+noinst_LIBRARIES=libsse.a
+fmplayer_LDADD+=libsse.a
+libsse_a_SOURCES=../libopna/opnassg-sinc-sse2.c \
+ ../fmdsp/fmdsp-vramlookup-ssse3.c
+libsse_a_CPPFLAGS=$(fmplayer_CPPFLAGS)
+#no way to add -O3?? (always overridden by CFLAGS)
+libsse_a_CFLAGS=-mssse3
+endif
+
fmplayer_SOURCES=main.c \
toneview.c \
oscilloview.c \
@@ -34,7 +51,3 @@ fmplayer_SOURCES=main.c \
$(FMDRIVER_SRC) \
$(FMDSP_SRC)
-fmplayer_CPPFLAGS=-Wall -Wextra -pedantic \
- -I.. \
- $(GTK3_CFLAGS) $(PORTAUDIO_CFLAGS)
-fmplayer_LDADD=$(GTK3_LIBS) $(PORTAUDIO_LIBS)
diff --git a/gtk/configure.ac b/gtk/configure.ac
index 2727888..f49bd74 100644
--- a/gtk/configure.ac
+++ b/gtk/configure.ac
@@ -2,6 +2,8 @@ AC_INIT([fmplayer], [0.1.0])
AM_INIT_AUTOMAKE([-Wall -Werror foreign subdir-objects])
AM_SILENT_RULES([yes])
AC_PROG_CC_C99
+AC_PROG_RANLIB
+AM_PROG_AR
AM_PROG_AS
dnl AM_PATH_SDL2([2.0.5])
@@ -14,5 +16,11 @@ AS_IF([test "x$enable_neon" = "xyes"], [
AC_DEFINE([ENABLE_NEON])
])
+AC_CHECK_HEADER([emmintrin.h], [emmintrin_found=yes])
+AM_CONDITIONAL([ENABLE_SSE], [test "x$emmintrin_found" = "xyes"])
+AS_IF([test "x$emmintrin_found" = "xyes"], [
+ AC_DEFINE([ENABLE_SSE])
+])
+
AC_CONFIG_FILES([Makefile])
AC_OUTPUT
diff --git a/gtk/main.c b/gtk/main.c
index fc72d62..855fbf4 100644
--- a/gtk/main.c
+++ b/gtk/main.c
@@ -55,7 +55,9 @@ static struct {
const char *current_uri;
bool oscillo_should_update;
struct oscillodata oscillodata_audiothread[LIBOPNA_OSCILLO_TRACK_COUNT];
-} g;
+} g = {
+ .oscillo_should_update = true
+};
static void quit(void) {
if (g.pastream) {
@@ -67,18 +69,26 @@ static void quit(void) {
}
static void on_destroy(GtkWidget *w, gpointer ptr) {
+ (void)w;
+ (void)ptr;
quit();
}
static void on_menu_quit(GtkMenuItem *menuitem, gpointer ptr) {
+ (void)menuitem;
+ (void)ptr;
quit();
}
static void on_tone_view(GtkMenuItem *menuitem, gpointer ptr) {
+ (void)menuitem;
+ (void)ptr;
show_toneview();
}
static void on_oscillo_view(GtkMenuItem *menuitem, gpointer ptr) {
+ (void)menuitem;
+ (void)ptr;
show_oscilloview();
}
@@ -95,6 +105,9 @@ static int pastream_cb(const void *inptr, void *outptr, unsigned long frames,
const PaStreamCallbackTimeInfo *timeinfo,
PaStreamCallbackFlags statusFlags,
void *userdata) {
+ (void)inptr;
+ (void)timeinfo;
+ (void)statusFlags;
struct opna_timer *timer = (struct opna_timer *)userdata;
int16_t *buf = (int16_t *)outptr;
memset(outptr, 0, sizeof(int16_t)*frames*2);
@@ -133,7 +146,8 @@ static void opna_writereg_libopna(struct fmdriver_work *work, unsigned addr, uns
}
static unsigned opna_readreg_libopna(struct fmdriver_work *work, unsigned addr) {
- struct opna_timer *timer = (struct opna_timer *)work->opna;
+ (void)work;
+ //struct opna_timer *timer = (struct opna_timer *)work->opna;
return opna_readreg(&g.opna, addr);
}
@@ -280,7 +294,7 @@ static bool openfile(const char *uri) {
g.pa_paused = false;
{
const char *turi = strdup(uri);
- free(g.current_uri);
+ free((void *)g.current_uri);
g.current_uri = turi;
}
return true;
@@ -290,6 +304,7 @@ err:
}
static void on_file_activated(GtkFileChooser *chooser, gpointer ptr) {
+ (void)ptr;
gchar *filename = gtk_file_chooser_get_uri(chooser);
if (filename) {
openfile(filename);
@@ -326,6 +341,8 @@ static GtkWidget *create_menubar() {
static gboolean draw_cb(GtkWidget *w,
cairo_t *cr,
gpointer p) {
+ (void)w;
+ (void)p;
fmdsp_update(&g.fmdsp, &g.work, &g.opna, g.vram);
fmdsp_vrampalette(&g.fmdsp, g.vram, g.vram32, g.vram32_stride);
cairo_surface_t *s = cairo_image_surface_create_for_data(
@@ -341,6 +358,7 @@ static gboolean draw_cb(GtkWidget *w,
static gboolean tick_cb(GtkWidget *w,
GdkFrameClock *frame_clock,
gpointer p) {
+ (void)w;
(void)frame_clock;
gtk_widget_queue_draw(GTK_WIDGET(p));
return G_SOURCE_CONTINUE;
@@ -472,6 +490,7 @@ static void drag_data_recv_cb(
gint x, gint y,
GtkSelectionData *data,
guint info, guint time, gpointer ptr) {
+ (void)w;
(void)x;
(void)y;
(void)info;
@@ -484,14 +503,15 @@ static void drag_data_recv_cb(
gtk_drag_finish(ctx, TRUE, FALSE, time);
}
-void opna_ssg_sinc_calc_neon(unsigned, const int16_t *, int32_t *);
-void fmdsp_vramlookup_neon(uint8_t *, const uint8_t *, const uint8_t *, int);
-
int main(int argc, char **argv) {
#ifdef ENABLE_NEON
opna_ssg_sinc_calc_func = opna_ssg_sinc_calc_neon;
fmdsp_vramlookup_func = fmdsp_vramlookup_neon;
#endif
+#ifdef ENABLE_SSE
+ if (__builtin_cpu_supports("sse2")) opna_ssg_sinc_calc_func = opna_ssg_sinc_calc_sse2;
+ if (__builtin_cpu_supports("ssse3")) fmdsp_vramlookup_func = fmdsp_vramlookup_ssse3;
+#endif
load_fontrom();
gtk_init(&argc, &argv);
GtkWidget *w = gtk_window_new(GTK_WINDOW_TOPLEVEL);