diff options
Diffstat (limited to 'src/gallium/frontends/wgl/stw_device.c')
-rw-r--r-- | src/gallium/frontends/wgl/stw_device.c | 77 |
1 files changed, 43 insertions, 34 deletions
diff --git a/src/gallium/frontends/wgl/stw_device.c b/src/gallium/frontends/wgl/stw_device.c index 8ffe752570c..e6fe54a05af 100644 --- a/src/gallium/frontends/wgl/stw_device.c +++ b/src/gallium/frontends/wgl/stw_device.c @@ -25,6 +25,8 @@ * **************************************************************************/ +#include "state_tracker/st_context.h" + #include <windows.h> #include "glapi/glapi.h" @@ -38,6 +40,7 @@ #include "stw_device.h" #include "stw_winsys.h" #include "stw_pixelformat.h" +#include "stw_gdishim.h" #include "gldrv.h" #include "stw_tls.h" #include "stw_framebuffer.h" @@ -47,7 +50,7 @@ struct stw_device *stw_dev = NULL; static int -stw_get_param(struct st_manager *smapi, +stw_get_param(struct pipe_frontend_screen *fscreen, enum st_manager_param param) { switch (param) { @@ -70,7 +73,8 @@ stw_get_param(struct st_manager *smapi, static int get_refresh_rate(void) { - DEVMODE devModes; +#ifndef _GAMING_XBOX + DEVMODE devModes = { .dmSize = sizeof(DEVMODE) }; if (EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &devModes)) { /* clamp the value, just in case we get garbage */ @@ -80,6 +84,9 @@ get_refresh_rate(void) /* reasonable default */ return 60; } +#else + return 60; +#endif /* _GAMING_XBOX */ } static bool @@ -92,21 +99,22 @@ init_screen(const struct stw_winsys *stw_winsys, HDC hdc) if (stw_winsys->get_adapter_luid) stw_winsys->get_adapter_luid(screen, hdc, &stw_dev->AdapterLuid); - stw_dev->smapi->screen = screen; + stw_dev->fscreen->screen = screen; stw_dev->screen = screen; + stw_dev->zink = !memcmp(screen->get_name(screen), "zink", 4); stw_dev->max_2d_length = screen->get_param(screen, PIPE_CAP_MAX_TEXTURE_2D_SIZE); return true; } +static const driOptionDescription gallium_driconf[] = { + #include "pipe-loader/driinfo_gallium.h" +}; + static void init_options() { - const driOptionDescription gallium_driconf[] = { - #include "pipe-loader/driinfo_gallium.h" - }; - const char *driver_name = stw_dev->stw_winsys->get_name ? stw_dev->stw_winsys->get_name() : NULL; driParseOptionInfo(&stw_dev->option_info, gallium_driconf, ARRAY_SIZE(gallium_driconf)); driParseConfigFiles(&stw_dev->option_cache, &stw_dev->option_info, 0, @@ -115,12 +123,19 @@ init_options() u_driconf_fill_st_options(&stw_dev->st_options, &stw_dev->option_cache); } -boolean +char * +stw_get_config_xml(void) +{ + return driGetOptionsXml(gallium_driconf, ARRAY_SIZE(gallium_driconf)); +} + +bool stw_init(const struct stw_winsys *stw_winsys) { static struct stw_device stw_dev_storage; - debug_disable_error_message_boxes(); + if (debug_get_bool_option("WGL_DISABLE_ERROR_DIALOGS", false)) + debug_disable_win32_error_dialogs(); assert(!stw_dev); @@ -131,12 +146,11 @@ stw_init(const struct stw_winsys *stw_winsys) stw_dev->stw_winsys = stw_winsys; - stw_dev->stapi = stw_st_create_api(); - stw_dev->smapi = CALLOC_STRUCT(st_manager); - if (!stw_dev->stapi || !stw_dev->smapi) + stw_dev->fscreen = CALLOC_STRUCT(pipe_frontend_screen); + if (!stw_dev->fscreen) goto error1; - stw_dev->smapi->get_param = stw_get_param; + stw_dev->fscreen->get_param = stw_get_param; InitializeCriticalSection(&stw_dev->screen_mutex); InitializeCriticalSection(&stw_dev->ctx_mutex); @@ -147,6 +161,9 @@ stw_init(const struct stw_winsys *stw_winsys) goto error1; } + /* Per WGL_EXT_swap_control, the default swap interval is 1. */ + stw_dev->swap_interval = 1; + /* env var override for WGL_EXT_swap_control, useful for testing/debugging */ const char *s = os_get_option("WGL_SWAP_INTERVAL"); if (s) { @@ -156,18 +173,16 @@ stw_init(const struct stw_winsys *stw_winsys) stw_dev->initialized = true; - return TRUE; + return true; error1: - FREE(stw_dev->smapi); - if (stw_dev->stapi) - stw_dev->stapi->destroy(stw_dev->stapi); + FREE(stw_dev->fscreen); stw_dev = NULL; - return FALSE; + return false; } -boolean +bool stw_init_screen(HDC hdc) { EnterCriticalSection(&stw_dev->screen_mutex); @@ -192,7 +207,7 @@ stw_get_device(void) return stw_dev; } -boolean +bool stw_init_thread(void) { return stw_tls_init_thread(); @@ -211,7 +226,7 @@ stw_cleanup(void) { DHGLRC dhglrc; - debug_printf("%s\n", __FUNCTION__); + debug_printf("%s\n", __func__); if (!stw_dev) return; @@ -224,13 +239,14 @@ stw_cleanup(void) dhglrc = handle_table_get_first_handle(stw_dev->ctx_table); stw_unlock_contexts(stw_dev); if (dhglrc) { - debug_printf("%s: contexts still active -- cleanup aborted\n", __FUNCTION__); + debug_printf("%s: contexts still active -- cleanup aborted\n", __func__); stw_dev = NULL; return; } free(stw_dev->st_options.force_gl_vendor); free(stw_dev->st_options.force_gl_renderer); + free(stw_dev->st_options.mesa_extension_override); driDestroyOptionCache(&stw_dev->option_cache); driDestroyOptionInfo(&stw_dev->option_info); @@ -242,18 +258,11 @@ stw_cleanup(void) DeleteCriticalSection(&stw_dev->ctx_mutex); DeleteCriticalSection(&stw_dev->screen_mutex); - if (stw_dev->smapi->destroy) - stw_dev->smapi->destroy(stw_dev->smapi); - - FREE(stw_dev->smapi); - stw_dev->stapi->destroy(stw_dev->stapi); + st_screen_destroy(stw_dev->fscreen); + FREE(stw_dev->fscreen); - stw_dev->screen->destroy(stw_dev->screen); - - /* glapi is statically linked: we can call the local destroy function. */ -#ifdef _GLAPI_NO_EXPORTS - _glapi_destroy_multithread(); -#endif + if (stw_dev->screen) + stw_dev->screen->destroy(stw_dev->screen); stw_tls_cleanup(); @@ -290,5 +299,5 @@ DrvValidateVersion(ULONG ulVersion) * ignore it. */ (void)ulVersion; - return TRUE; + return true; } |