wgl: Refactor screen creation to a function

Fixes: 8955980f ("gallium/targets/libgl-gdi: prefer d3d12 driver")
Reviewed-by: Jose Fonseca <jfonseca@vmware.com>
Tested-by: Prodea Alexandru-Liviu <liviuprodea@yahoo.com>
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/4022
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8865>
(cherry picked from commit e6cf34d611)
This commit is contained in:
Jesse Natalie 2021-02-04 07:58:06 -08:00 committed by Dylan Baker
parent 63d0fbb07b
commit 83f99bbb4f
2 changed files with 47 additions and 44 deletions

View file

@ -3289,7 +3289,7 @@
"description": "wgl: Refactor screen creation to a function",
"nominated": true,
"nomination_type": 1,
"resolution": 0,
"resolution": 1,
"master_sha": null,
"because_sha": "8955980f17f902d24c50962502a20285dcd11642"
},

View file

@ -78,6 +78,48 @@ static boolean use_d3d12 = FALSE;
static boolean use_zink = FALSE;
#endif
static struct pipe_screen *
gdi_screen_create_by_name(HDC hDC, const char* driver, struct sw_winsys *winsys)
{
struct pipe_screen* screen = NULL;
#ifdef GALLIUM_LLVMPIPE
if (strcmp(driver, "llvmpipe") == 0) {
screen = llvmpipe_create_screen(winsys);
if (screen)
use_llvmpipe = TRUE;
}
#endif
#ifdef GALLIUM_SWR
if (strcmp(driver, "swr") == 0) {
screen = swr_create_screen(winsys);
if (screen)
use_swr = TRUE;
}
#endif
#ifdef GALLIUM_D3D12
if (strcmp(driver, "d3d12") == 0) {
screen = d3d12_wgl_create_screen(winsys, hDC);
if (screen)
use_d3d12 = TRUE;
}
#endif
#ifdef GALLIUM_ZINK
if (strcmp(driver, "zink") == 0) {
screen = zink_create_screen(winsys);
if (screen)
use_zink = TRUE;
}
#endif
#ifdef GALLIUM_SOFTPIPE
if (strcmp(driver, "softpipe") == 0) {
screen = softpipe_create_screen(winsys);
}
#endif
return screen;
}
static struct pipe_screen *
gdi_screen_create(HDC hDC)
{
@ -87,8 +129,8 @@ gdi_screen_create(HDC hDC)
struct sw_winsys *winsys;
winsys = gdi_create_sw_winsys();
if(!winsys)
goto no_winsys;
if (!winsys)
return screen;
#ifdef GALLIUM_D3D12
default_driver = "d3d12";
@ -103,50 +145,11 @@ gdi_screen_create(HDC hDC)
#endif
driver = debug_get_option("GALLIUM_DRIVER", default_driver);
#ifdef GALLIUM_LLVMPIPE
if (strcmp(driver, "llvmpipe") == 0) {
screen = llvmpipe_create_screen( winsys );
if (screen)
use_llvmpipe = TRUE;
}
#endif
#ifdef GALLIUM_SWR
if (strcmp(driver, "swr") == 0) {
screen = swr_create_screen( winsys );
if (screen)
use_swr = TRUE;
}
#endif
#ifdef GALLIUM_D3D12
if (strcmp(driver, "d3d12") == 0) {
screen = d3d12_wgl_create_screen( winsys, hDC );
if (screen)
use_d3d12 = TRUE;
}
#endif
#ifdef GALLIUM_ZINK
if (strcmp(driver, "zink") == 0) {
screen = zink_create_screen( winsys );
if (screen)
use_zink = TRUE;
}
#endif
(void) driver;
#ifdef GALLIUM_SOFTPIPE
if (screen == NULL)
screen = softpipe_create_screen( winsys );
#endif
screen = gdi_screen_create_by_name(hDC, driver, winsys);
if (!screen)
goto no_screen;
winsys->destroy(winsys);
return screen;
no_screen:
winsys->destroy(winsys);
no_winsys:
return NULL;
}