Module: Mesa Branch: master Commit: f6d2d3cb580ca24312669f01cc27354ad6c26c7a URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=f6d2d3cb580ca24312669f01cc27354ad6c26c7a
Author: Jesse Natalie <[email protected]> Date: Tue Mar 17 14:40:47 2020 -0700 wgl: Marshal HDC into screen creation and LUID querying Reviewed-by: Charmaine Lee <[email protected]> Reviewed-by: Erik Faye-Lund <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7535> --- src/gallium/frontends/wgl/stw_device.c | 10 +++++----- src/gallium/frontends/wgl/stw_device.h | 2 +- src/gallium/frontends/wgl/stw_ext_pixelformat.c | 23 ++++++++++------------- src/gallium/frontends/wgl/stw_framebuffer.c | 2 +- src/gallium/frontends/wgl/stw_pixelformat.c | 16 ++++++---------- src/gallium/frontends/wgl/stw_pixelformat.h | 4 ++-- src/gallium/frontends/wgl/stw_winsys.h | 3 ++- src/gallium/targets/libgl-d3d12/libgl_d3d12.c | 4 ++-- src/gallium/targets/libgl-gdi/libgl_gdi.c | 4 ++-- 9 files changed, 31 insertions(+), 37 deletions(-) diff --git a/src/gallium/frontends/wgl/stw_device.c b/src/gallium/frontends/wgl/stw_device.c index f5064da9f29..b8cfeb8ec9f 100644 --- a/src/gallium/frontends/wgl/stw_device.c +++ b/src/gallium/frontends/wgl/stw_device.c @@ -81,14 +81,14 @@ get_refresh_rate(void) } static bool -init_screen(const struct stw_winsys *stw_winsys) +init_screen(const struct stw_winsys *stw_winsys, HDC hdc) { - struct pipe_screen *screen = stw_winsys->create_screen(); + struct pipe_screen *screen = stw_winsys->create_screen(hdc); if (!screen) return false; if (stw_winsys->get_adapter_luid) - stw_winsys->get_adapter_luid(screen, &stw_dev->AdapterLuid); + stw_winsys->get_adapter_luid(screen, hdc, &stw_dev->AdapterLuid); stw_dev->smapi->screen = screen; stw_dev->screen = screen; @@ -151,13 +151,13 @@ error1: } boolean -stw_init_screen() +stw_init_screen(HDC hdc) { EnterCriticalSection(&stw_dev->screen_mutex); if (!stw_dev->screen_initialized) { stw_dev->screen_initialized = true; - if (!init_screen(stw_dev->stw_winsys)) { + if (!init_screen(stw_dev->stw_winsys, hdc)) { LeaveCriticalSection(&stw_dev->screen_mutex); return false; } diff --git a/src/gallium/frontends/wgl/stw_device.h b/src/gallium/frontends/wgl/stw_device.h index a2cd6c7487c..6c57e874a57 100644 --- a/src/gallium/frontends/wgl/stw_device.h +++ b/src/gallium/frontends/wgl/stw_device.h @@ -91,7 +91,7 @@ struct stw_device extern struct stw_device *stw_dev; boolean -stw_init_screen(void); +stw_init_screen(HDC hdc); static inline struct stw_context * stw_lookup_context_locked( DHGLRC dhglrc ) diff --git a/src/gallium/frontends/wgl/stw_ext_pixelformat.c b/src/gallium/frontends/wgl/stw_ext_pixelformat.c index 8fc6da1df2e..aee39b2974f 100644 --- a/src/gallium/frontends/wgl/stw_ext_pixelformat.c +++ b/src/gallium/frontends/wgl/stw_ext_pixelformat.c @@ -49,12 +49,12 @@ static boolean -stw_query_attrib(int iPixelFormat, int iLayerPlane, int attrib, int *pvalue) +stw_query_attrib(HDC hdc, int iPixelFormat, int iLayerPlane, int attrib, int *pvalue) { uint count; const struct stw_pixelformat_info *pfi; - count = stw_pixelformat_get_extended_count(); + count = stw_pixelformat_get_extended_count(hdc); if (attrib == WGL_NUMBER_PIXEL_FORMATS_ARB) { *pvalue = (int) count; @@ -331,7 +331,8 @@ struct stw_pixelformat_score static BOOL -score_pixelformats(struct stw_pixelformat_score *scores, +score_pixelformats(HDC hdc, + struct stw_pixelformat_score *scores, uint count, int attribute, int expected_value) @@ -357,7 +358,7 @@ score_pixelformats(struct stw_pixelformat_score *scores, for (index = 0; index < count; index++) { int actual_value; - if (!stw_query_attrib(index + 1, 0, attribute, &actual_value)) + if (!stw_query_attrib(hdc, index + 1, 0, attribute, &actual_value)) return FALSE; if (ami->exact) { @@ -403,7 +404,7 @@ wglChoosePixelFormatARB(HDC hdc, const int *piAttribIList, * points for a mismatch when the match does not have to be exact. * Set a score to 0 if there is a mismatch for an exact match criteria. */ - count = stw_pixelformat_get_extended_count(); + count = stw_pixelformat_get_extended_count(hdc); scores = (struct stw_pixelformat_score *) MALLOC(count * sizeof(struct stw_pixelformat_score)); if (scores == NULL) @@ -417,7 +418,7 @@ wglChoosePixelFormatARB(HDC hdc, const int *piAttribIList, */ if (piAttribIList != NULL) { while (*piAttribIList != 0) { - if (!score_pixelformats(scores, count, piAttribIList[0], + if (!score_pixelformats(hdc, scores, count, piAttribIList[0], piAttribIList[1])) { FREE(scores); return FALSE; @@ -427,7 +428,7 @@ wglChoosePixelFormatARB(HDC hdc, const int *piAttribIList, } if (pfAttribFList != NULL) { while (*pfAttribFList != 0) { - if (!score_pixelformats(scores, count, (int) pfAttribFList[0], + if (!score_pixelformats(hdc, scores, count, (int) pfAttribFList[0], (int) pfAttribFList[1])) { FREE(scores); return FALSE; @@ -484,12 +485,10 @@ wglGetPixelFormatAttribfvARB(HDC hdc, int iPixelFormat, int iLayerPlane, { UINT i; - (void) hdc; - for (i = 0; i < nAttributes; i++) { int value = 0; - if (!stw_query_attrib(iPixelFormat, iLayerPlane, + if (!stw_query_attrib(hdc, iPixelFormat, iLayerPlane, piAttributes[i], &value)) return FALSE; pfValues[i] = (FLOAT) value; @@ -506,10 +505,8 @@ wglGetPixelFormatAttribivARB(HDC hdc, int iPixelFormat, int iLayerPlane, { UINT i; - (void) hdc; - for (i = 0; i < nAttributes; i++) { - if (!stw_query_attrib(iPixelFormat, iLayerPlane, + if (!stw_query_attrib(hdc, iPixelFormat, iLayerPlane, piAttributes[i], &piValues[i])) return FALSE; } diff --git a/src/gallium/frontends/wgl/stw_framebuffer.c b/src/gallium/frontends/wgl/stw_framebuffer.c index 6d3a0402130..49911a6d48d 100644 --- a/src/gallium/frontends/wgl/stw_framebuffer.c +++ b/src/gallium/frontends/wgl/stw_framebuffer.c @@ -431,7 +431,7 @@ DrvSetPixelFormat(HDC hdc, LONG iPixelFormat) return FALSE; index = (uint) iPixelFormat - 1; - count = stw_pixelformat_get_count(); + count = stw_pixelformat_get_count(hdc); if (index >= count) return FALSE; diff --git a/src/gallium/frontends/wgl/stw_pixelformat.c b/src/gallium/frontends/wgl/stw_pixelformat.c index c4f8ff194ea..dc922afd140 100644 --- a/src/gallium/frontends/wgl/stw_pixelformat.c +++ b/src/gallium/frontends/wgl/stw_pixelformat.c @@ -311,9 +311,9 @@ stw_pixelformat_init(void) uint -stw_pixelformat_get_count(void) +stw_pixelformat_get_count(HDC hdc) { - if (!stw_init_screen()) + if (!stw_init_screen(hdc)) return 0; return stw_dev->pixelformat_count; @@ -321,9 +321,9 @@ stw_pixelformat_get_count(void) uint -stw_pixelformat_get_extended_count(void) +stw_pixelformat_get_extended_count(HDC hdc) { - if (!stw_init_screen()) + if (!stw_init_screen(hdc)) return 0; return stw_dev->pixelformat_extended_count; @@ -355,12 +355,10 @@ DrvDescribePixelFormat(HDC hdc, INT iPixelFormat, ULONG cjpfd, uint count; const struct stw_pixelformat_info *pfi; - (void) hdc; - if (!stw_dev) return 0; - count = stw_pixelformat_get_count(); + count = stw_pixelformat_get_count(hdc); if (ppfd == NULL) return count; @@ -425,9 +423,7 @@ stw_pixelformat_choose(HDC hdc, CONST PIXELFORMATDESCRIPTOR *ppfd) uint bestindex; uint bestdelta; - (void) hdc; - - count = stw_pixelformat_get_extended_count(); + count = stw_pixelformat_get_extended_count(hdc); bestindex = 0; bestdelta = ~0U; diff --git a/src/gallium/frontends/wgl/stw_pixelformat.h b/src/gallium/frontends/wgl/stw_pixelformat.h index e3ab1ee7514..25e265a12bb 100644 --- a/src/gallium/frontends/wgl/stw_pixelformat.h +++ b/src/gallium/frontends/wgl/stw_pixelformat.h @@ -53,10 +53,10 @@ void stw_pixelformat_init( void ); uint -stw_pixelformat_get_count( void ); +stw_pixelformat_get_count( HDC hdc ); uint -stw_pixelformat_get_extended_count( void ); +stw_pixelformat_get_extended_count( HDC hdc ); const struct stw_pixelformat_info * stw_pixelformat_get_info( int iPixelFormat ); diff --git a/src/gallium/frontends/wgl/stw_winsys.h b/src/gallium/frontends/wgl/stw_winsys.h index 83ffd6bda36..99245fba2a8 100644 --- a/src/gallium/frontends/wgl/stw_winsys.h +++ b/src/gallium/frontends/wgl/stw_winsys.h @@ -41,7 +41,7 @@ struct stw_shared_surface; struct stw_winsys { struct pipe_screen * - (*create_screen)( void ); + (*create_screen)( HDC hDC ); /* XXX is it actually possible to have non-zero level/layer ??? */ /** @@ -59,6 +59,7 @@ struct stw_winsys */ boolean (*get_adapter_luid)( struct pipe_screen *screen, + HDC hDC, LUID *pAdapterLuid ); /** diff --git a/src/gallium/targets/libgl-d3d12/libgl_d3d12.c b/src/gallium/targets/libgl-d3d12/libgl_d3d12.c index 01037ed3440..9f98c7f2437 100644 --- a/src/gallium/targets/libgl-d3d12/libgl_d3d12.c +++ b/src/gallium/targets/libgl-d3d12/libgl_d3d12.c @@ -39,7 +39,7 @@ #include "d3d12/d3d12_public.h" static struct pipe_screen * -gdi_screen_create(void) +gdi_screen_create(HDC hDC) { struct pipe_screen *screen = NULL; struct sw_winsys *winsys; @@ -50,7 +50,7 @@ gdi_screen_create(void) goto no_winsys; if (stw_dev && stw_dev->callbacks.pfnGetAdapterLuid) { - stw_dev->callbacks.pfnGetAdapterLuid(NULL, &local_luid); + stw_dev->callbacks.pfnGetAdapterLuid(hDC, &local_luid); adapter_luid = &local_luid; } screen = d3d12_create_screen( winsys, adapter_luid ); diff --git a/src/gallium/targets/libgl-gdi/libgl_gdi.c b/src/gallium/targets/libgl-gdi/libgl_gdi.c index 94739bfb165..4813e252402 100644 --- a/src/gallium/targets/libgl-gdi/libgl_gdi.c +++ b/src/gallium/targets/libgl-gdi/libgl_gdi.c @@ -78,7 +78,7 @@ static boolean use_zink = FALSE; #endif static struct pipe_screen * -gdi_screen_create(void) +gdi_screen_create(HDC hDC) { const char *default_driver; const char *driver; @@ -119,7 +119,7 @@ gdi_screen_create(void) if (strcmp(driver, "d3d12") == 0) { LUID* adapter_luid = NULL, local_luid; if (stw_dev && stw_dev->callbacks.pfnGetAdapterLuid) { - stw_dev->callbacks.pfnGetAdapterLuid(NULL, &local_luid); + stw_dev->callbacks.pfnGetAdapterLuid(hDC, &local_luid); adapter_luid = &local_luid; } screen = d3d12_create_screen( winsys, adapter_luid ); _______________________________________________ mesa-commit mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/mesa-commit
