stw_dev->smapi->get_param = stw_get_param;
- if (!init_screen(stw_winsys))
- goto error1;
-
+ InitializeCriticalSection(&stw_dev->screen_mutex);
InitializeCriticalSection(&stw_dev->ctx_mutex);
InitializeCriticalSection(&stw_dev->fb_mutex);
goto error1;
}
- stw_pixelformat_init();
-
/* env var override for WGL_EXT_swap_control, useful for testing/debugging */
const char *s = os_get_option("WGL_SWAP_INTERVAL");
if (s) {
return FALSE;
}
+boolean
+stw_init_screen()
+{
+ EnterCriticalSection(&stw_dev->screen_mutex);
+
+ if (!stw_dev->screen_initialized) {
+ stw_dev->screen_initialized = true;
+ if (!init_screen(stw_dev->stw_winsys)) {
+ LeaveCriticalSection(&stw_dev->screen_mutex);
+ return false;
+ }
+ stw_pixelformat_init();
+ }
+
+ LeaveCriticalSection(&stw_dev->screen_mutex);
+ return stw_dev->screen != NULL;
+}
boolean
stw_init_thread(void)
DeleteCriticalSection(&stw_dev->fb_mutex);
DeleteCriticalSection(&stw_dev->ctx_mutex);
+ DeleteCriticalSection(&stw_dev->screen_mutex);
if (stw_dev->smapi->destroy)
stw_dev->smapi->destroy(stw_dev->smapi);
struct stw_device
{
const struct stw_winsys *stw_winsys;
-
+
+ CRITICAL_SECTION screen_mutex;
+ bool screen_initialized;
struct pipe_screen *screen;
-
+
/* Cache some PIPE_CAP_* */
unsigned max_2d_length;
extern struct stw_device *stw_dev;
+boolean
+stw_init_screen(void);
static inline struct stw_context *
stw_lookup_context_locked( DHGLRC dhglrc )
uint
stw_pixelformat_get_count(void)
{
+ if (!stw_init_screen())
+ return 0;
+
return stw_dev->pixelformat_count;
}
uint
stw_pixelformat_get_extended_count(void)
{
+ if (!stw_init_screen())
+ return 0;
+
return stw_dev->pixelformat_extended_count;
}