Re: [AD] X11 unresponsiveness and vsync |
[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
Okay, you can pretty much forget about the previous patch I posted. I
thought of another solution. Basically what it does is.. everytime an
input update call is blocked, it increments a variable, and when XUNLOCK
actually unlocks, it forces an input update for each time missed.
I also noticed a small problem with _xwin_vsync. It does the flush
buffer thing durring a lock and when it finishes, it reads the
refresh_count var and waits for the next tic. Shouldn't it read the
refresh_count var before flushing the buffer in case it tics while
flushing? That'd be a nice spot for slow down to occur.
I attached patches for both src/x/xwin.c and
include/allegro/platform/aintunix.h
- Kitty Cat
--- xwin.c 2004-07-11 03:33:10.000000000 -0700
+++ xwin.c 2004-07-12 17:23:50.000000000 -0700
@@ -139,6 +139,10 @@
NULL /* window close hook */
};
+#ifndef ALLEGRO_MULTITHREADED
+int _xwin_missed_input;
+#endif
+
void *allegro_icon = alex_xpm;
int _xwin_last_line = -1;
@@ -2092,13 +2096,13 @@
void _xwin_vsync(void)
{
+ int prev = retrace_count;
+
XLOCK();
_xwin_private_vsync();
XUNLOCK();
if (_timer_installed) {
- int prev = retrace_count;
-
do {
} while (retrace_count == prev);
}
@@ -2434,7 +2438,12 @@
void _xwin_handle_input(void)
{
- if (_xwin.lock_count) return;
+#ifndef ALLEGRO_MULTITHREADED
+ if (_xwin.lock_count) {
+ ++_xwin_missed_input;
+ return;
+ }
+#endif
XLOCK();
--- aintunix.h 2003-02-07 05:29:06.000000000 -0800
+++ aintunix.h 2004-07-12 17:41:27.000000000 -0700
@@ -94,6 +94,10 @@
_xwin.lock_count++; \
} while (0)
+
+#ifndef ALLEGRO_MULTITHREADED
+
+ AL_VAR(int, _xwin_missed_input);
#define XUNLOCK() \
do { \
if (_unix_bg_man->multi_threaded) { \
@@ -101,8 +105,27 @@
XUnlockDisplay(_xwin.display); \
} \
_xwin.lock_count--; \
+ if (_xwin.lock_count == 0) { \
+ while(_xwin_missed_input) { \
+ _xwin_handle_input(); \
+ --xwin_missed_input; \
+ } \
+ } \
} while (0)
+#else
+
+ #define XUNLOCK() \
+ do { \
+ if (_unix_bg_man->multi_threaded) { \
+ if (_xwin.display) \
+ XUnlockDisplay(_xwin.display); \
+ } \
+ _xwin.lock_count--; \
+ } while (0)
+
+#endif
+
#endif