#include <windows.h>
-#include "os/os_thread.h"
+#include "util/u_debug.h"
+
struct pipe_resource;
struct st_framebuffer_iface;
* This mutex has two purposes:
* - protect the access to the mutable data members below
* - prevent the framebuffer from being deleted while being accessed.
- *
- * It is OK to lock this mutex while holding the stw_device::fb_mutex lock,
- * but the opposite must never happen.
+ *
+ * Note: if both this mutex and the stw_device::fb_mutex need to be locked,
+ * the stw_device::fb_mutex needs to be locked first.
*/
- pipe_mutex mutex;
+ CRITICAL_SECTION mutex;
/*
* Immutable members.
void
stw_framebuffer_update(struct stw_framebuffer *fb);
+
+static inline void
+stw_framebuffer_lock(struct stw_framebuffer *fb)
+{
+ assert(fb);
+ EnterCriticalSection(&fb->mutex);
+}
+
+
/**
* Release stw_framebuffer::mutex lock. This framebuffer must not be accessed
* after calling this function, as it may have been deleted by another thread
* in the meanwhile.
*/
-void
-stw_framebuffer_release(struct stw_framebuffer *fb);
+static inline void
+stw_framebuffer_release(struct stw_framebuffer *fb)
+{
+ assert(fb);
+ LeaveCriticalSection(&fb->mutex);
+}
+
/**
* Cleanup any existing framebuffers when exiting application.