wgl: do not create screen from DllMain
There's a lot of operations that aren't allowed from DllMain, so we shouldn't create a driver-screen from there. So let's instead delay this until it's needed from a normal function call. See https://docs.microsoft.com/en-us/windows/win32/dlls/dllmain for details about what is allowed and isn't from DllMain. Reviewed-by: Neha Bhende <bhenden@vmware.com> Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4307> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4307>
This commit is contained in:
parent
99a0864b48
commit
7b7dbd4fc8
|
@ -125,9 +125,7 @@ stw_init(const struct stw_winsys *stw_winsys)
|
||||||
|
|
||||||
stw_dev->smapi->get_param = stw_get_param;
|
stw_dev->smapi->get_param = stw_get_param;
|
||||||
|
|
||||||
if (!init_screen(stw_winsys))
|
InitializeCriticalSection(&stw_dev->screen_mutex);
|
||||||
goto error1;
|
|
||||||
|
|
||||||
InitializeCriticalSection(&stw_dev->ctx_mutex);
|
InitializeCriticalSection(&stw_dev->ctx_mutex);
|
||||||
InitializeCriticalSection(&stw_dev->fb_mutex);
|
InitializeCriticalSection(&stw_dev->fb_mutex);
|
||||||
|
|
||||||
|
@ -136,8 +134,6 @@ stw_init(const struct stw_winsys *stw_winsys)
|
||||||
goto error1;
|
goto error1;
|
||||||
}
|
}
|
||||||
|
|
||||||
stw_pixelformat_init();
|
|
||||||
|
|
||||||
/* env var override for WGL_EXT_swap_control, useful for testing/debugging */
|
/* env var override for WGL_EXT_swap_control, useful for testing/debugging */
|
||||||
const char *s = os_get_option("WGL_SWAP_INTERVAL");
|
const char *s = os_get_option("WGL_SWAP_INTERVAL");
|
||||||
if (s) {
|
if (s) {
|
||||||
|
@ -158,6 +154,23 @@ error1:
|
||||||
return FALSE;
|
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
|
boolean
|
||||||
stw_init_thread(void)
|
stw_init_thread(void)
|
||||||
|
@ -202,6 +215,7 @@ stw_cleanup(void)
|
||||||
|
|
||||||
DeleteCriticalSection(&stw_dev->fb_mutex);
|
DeleteCriticalSection(&stw_dev->fb_mutex);
|
||||||
DeleteCriticalSection(&stw_dev->ctx_mutex);
|
DeleteCriticalSection(&stw_dev->ctx_mutex);
|
||||||
|
DeleteCriticalSection(&stw_dev->screen_mutex);
|
||||||
|
|
||||||
if (stw_dev->smapi->destroy)
|
if (stw_dev->smapi->destroy)
|
||||||
stw_dev->smapi->destroy(stw_dev->smapi);
|
stw_dev->smapi->destroy(stw_dev->smapi);
|
||||||
|
|
|
@ -48,6 +48,8 @@ struct stw_device
|
||||||
{
|
{
|
||||||
const struct stw_winsys *stw_winsys;
|
const struct stw_winsys *stw_winsys;
|
||||||
|
|
||||||
|
CRITICAL_SECTION screen_mutex;
|
||||||
|
bool screen_initialized;
|
||||||
struct pipe_screen *screen;
|
struct pipe_screen *screen;
|
||||||
|
|
||||||
/* Cache some PIPE_CAP_* */
|
/* Cache some PIPE_CAP_* */
|
||||||
|
@ -88,6 +90,8 @@ struct stw_device
|
||||||
|
|
||||||
extern struct stw_device *stw_dev;
|
extern struct stw_device *stw_dev;
|
||||||
|
|
||||||
|
boolean
|
||||||
|
stw_init_screen(void);
|
||||||
|
|
||||||
static inline struct stw_context *
|
static inline struct stw_context *
|
||||||
stw_lookup_context_locked( DHGLRC dhglrc )
|
stw_lookup_context_locked( DHGLRC dhglrc )
|
||||||
|
|
|
@ -313,6 +313,9 @@ stw_pixelformat_init(void)
|
||||||
uint
|
uint
|
||||||
stw_pixelformat_get_count(void)
|
stw_pixelformat_get_count(void)
|
||||||
{
|
{
|
||||||
|
if (!stw_init_screen())
|
||||||
|
return 0;
|
||||||
|
|
||||||
return stw_dev->pixelformat_count;
|
return stw_dev->pixelformat_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -320,6 +323,9 @@ stw_pixelformat_get_count(void)
|
||||||
uint
|
uint
|
||||||
stw_pixelformat_get_extended_count(void)
|
stw_pixelformat_get_extended_count(void)
|
||||||
{
|
{
|
||||||
|
if (!stw_init_screen())
|
||||||
|
return 0;
|
||||||
|
|
||||||
return stw_dev->pixelformat_extended_count;
|
return stw_dev->pixelformat_extended_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue