* \file
* Implementation of fenced buffers.
*
- * \author José Fonseca <jrfonseca-at-tungstengraphics-dot-com>
- * \author Thomas Hellström <thomas-at-tungstengraphics-dot-com>
+ * \author José Fonseca <jrfonseca-at-tungstengraphics-dot-com>
+ * \author Thomas Hellström <thomas-at-tungstengraphics-dot-com>
*/
#include "pb_buffer.h"
#include "pb_buffer_fenced.h"
-#ifndef __MSC__
+#ifndef WIN32
#include <unistd.h>
#endif
}
-
-
static void
_fenced_buffer_list_check_free(struct fenced_buffer_list *fenced_list,
int wait)
int signaled = -1;
list = fenced_list->delayed.next;
-
- if (fenced_list->numDelayed > 3) {
- unsigned i;
-
- for (i = 0; i < fenced_list->numDelayed; i += 3) {
- list = list->next;
- }
- }
-
prev = list->prev;
for (; list != &fenced_list->delayed; list = prev, prev = list->prev) {
}
}
- if (signaled != 0)
+ if (signaled != 0) {
+#if 0
/* XXX: we are assuming that buffers are freed in the same order they
* are fenced which may not always be true...
*/
break;
+#else
+ signaled = -1;
+ continue;
+#endif
+ }
winsys->fence_reference(winsys, &fenced_buf->fence, NULL);
struct fenced_buffer_list *fenced_list = fenced_buf->list;
if (fenced_buf->fence) {
- LIST_ADDTAIL(&fenced_buf->head, &fenced_list->delayed);
- fenced_list->numDelayed++;
+ struct pipe_winsys *winsys = fenced_list->winsys;
+ if(winsys->fence_finish(winsys, fenced_buf->fence, 0) != 0) {
+ LIST_ADDTAIL(&fenced_buf->head, &fenced_list->delayed);
+ fenced_list->numDelayed++;
+ }
+ else {
+ winsys->fence_reference(winsys, &fenced_buf->fence, NULL);
+ pb_reference(&fenced_buf->buffer, NULL);
+ FREE(fenced_buf);
+ }
}
else {
pb_reference(&fenced_buf->buffer, NULL);
/* Wait on outstanding fences */
while (fenced_list->numDelayed) {
_glthread_UNLOCK_MUTEX(fenced_list->mutex);
-#ifndef __MSC__
+#ifndef WIN32
sched_yield();
#endif
_fenced_buffer_list_check_free(fenced_list, 1);