commit 1ca256bd293ecdac07e55ffeba030406e17ce6a3
parent e0cef1334a18540e75cce81d591c10dd334801c7
Author: bsandro <[email protected]>
Date: Tue, 1 Aug 2023 21:54:41 +0300
Removed x86_64 only code, added -ffast-math.
Diffstat:
3 files changed, 15 insertions(+), 4 deletions(-)
diff --git a/gui/Makefile b/gui/Makefile
@@ -3,7 +3,7 @@ SRC:=$(wildcard *.c)
DEPS:=$(wildcard ../include/*.h)
OBJ:=$(SRC:.c=.o)
LIBS:=libwebp libwebpdemux x11
-CFLAGS=-Og -g -std=c99 -Wall -Wextra -I. -I../include/ ${shell pkg-config --cflags $(LIBS)}
+CFLAGS=-Og -g -std=c99 -Wall -Wextra -ffast-math -I. -I../include/ ${shell pkg-config --cflags $(LIBS)}
LDFLAGS=-lc -lm ${shell pkg-config --libs $(LIBS)}
all: $(NAME)
diff --git a/gui/main.c b/gui/main.c
@@ -209,7 +209,7 @@ spritesheet_t gen_spritesheet(animation_t *img, int cols) {
}
}
int stride = full_line;
- printf("stride: %d\n", stride);
+ //printf("stride: %d\n", stride);
//size_t encoded = WebPEncodeLosslessRGBA(merged_orig, img->width * cols, img->height * rows, stride, &out);
//printf("size: %zu, encoded: %zu\n", img->width*img->height*sizeof(uint32_t), encoded);
//assert(encoded!=0);
@@ -238,7 +238,7 @@ int ButtonCloseEvent(UIElement *element, UIMessage msg, int di, void *dp) {
void update_preview(UIImageDisplay *img_disp) {
// gen new spritesheet and refresh the preview
spritesheet_t ss = gen_spritesheet(img, cols);
- printf("spritesheet width: %d, height: %d, stride: %d, len: %zu\n", ss.width, ss.height, ss.stride, ss.len);
+ //printf("spritesheet width: %d, height: %d, stride: %d, len: %zu\n", ss.width, ss.height, ss.stride, ss.len);
uint32_t *frame0 = calloc(ss.width*ss.height, sizeof(uint32_t));
assert(frame0!=NULL);
@@ -274,7 +274,7 @@ int SliderEvent(UIElement *element, UIMessage msg, int di, void *dp) {
float step = 1.0f / (float)img->frame_count;
int new_cols = (int)(slider_pos / step);
if (new_cols > 0 && cols != new_cols) {
- printf("new_cols: %d\n", new_cols);
+ //printf("new_cols: %d\n", new_cols);
cols = new_cols;
update_preview(element->cp);
}
diff --git a/include/luigi.h b/include/luigi.h
@@ -15,9 +15,12 @@
#include <X11/Xatom.h>
#include <X11/cursorfont.h>
+#if defined(__x86_64__) || defined(_M_X64)
#include <xmmintrin.h>
#endif
+#endif
+
#define _UI_TO_STRING_1(x) #x
#define _UI_TO_STRING_2(x) _UI_TO_STRING_1(x)
@@ -899,7 +902,9 @@ bool UIRectangleContains(UIRectangle a, int x, int y) {
return a.l <= x && a.r > x && a.t <= y && a.b > y;
}
+#if defined(__x86_64__) || defined(_M_X64)
#include <xmmintrin.h>
+#endif
typedef union _UIConvertFloatInteger {
float f;
@@ -928,9 +933,15 @@ float _UIFloorFloat(float x) {
}
float _UISquareRootFloat(float x) {
+#if defined(__x86_64__) || defined(_M_X64)
float result[4];
_mm_storeu_ps(result, _mm_sqrt_ps(_mm_set_ps(0, 0, 0, x)));
return result[0];
+#else
+//@todo fsqrt.s for risc-v?
+//clang already does that with this and -ffast-math
+ return sqrtf(x);
+#endif
}
#define _F(x) (((_UIConvertFloatInteger) { .i = (x) }).f)