return (struct stw_st_framebuffer *) stfb;
}
+
+/**
+ * Is the given mutex held by the calling thread?
+ */
+static bool
+own_mutex(const CRITICAL_SECTION *cs)
+{
+ // We can't compare OwningThread with our thread handle/id (see
+ // http://stackoverflow.com/a/12675635 ) but we can compare with the
+ // OwningThread member of a critical section we know we own.
+ CRITICAL_SECTION dummy;
+ InitializeCriticalSection(&dummy);
+ EnterCriticalSection(&dummy);
+ if (0)
+ _debug_printf("%p %p\n", cs->OwningThread, dummy.OwningThread);
+ bool ret = cs->OwningThread == dummy.OwningThread;
+ LeaveCriticalSection(&dummy);
+ DeleteCriticalSection(&dummy);
+ return ret;
+}
+
+
/**
* Remove outdated textures and create the requested ones.
*/
struct stw_st_framebuffer *stwfb = stw_st_framebuffer(stfb);
struct pipe_resource *resource;
+ assert(own_mutex(&stwfb->fb->mutex));
+
resource = stwfb->textures[statt];
if (resource) {
stw_framebuffer_present_locked(hdc, stwfb->fb, resource);
stw_framebuffer_unlock(stwfb->fb);
}
+ assert(!own_mutex(&stwfb->fb->mutex));
+
return TRUE;
}