[Mesa-dev] [PATCH 3/3] wgl: Ensure PIXELFORMATDESCRIPTOR members are zeroed.
Roland Scheidegger
sroland at vmware.com
Wed Nov 19 12:27:51 PST 2014
Some small nitpick below, but otherwise the series is:
Reviewed-by: Roland Scheidegger <sroland at vmware.com>
Am 19.11.2014 um 19:23 schrieb jfonseca at vmware.com:
> From: José Fonseca <jfonseca at vmware.com>
>
> I suddenly started seeing many simple GL apps, including wglinfo,
> choosing Microsoft GDI OpenGL implementation, even though hardware
> accelerated pixel formats were available.
>
> It turned out that:
> - the screen was in 16bpp mode (some WHCK tests have the nasty habit
> of doing that)
> - NVIDIA opengl driver only reports R5G6B5 pixel formats (ie no alpha
> bits) in this case
> - non-zero cAlphaBits was being passed to ChoosePixelformat (or in the
> wglinfo case, garbage, as the structure wasn't being properly zeroed)
> - ChoosePixelFormat will choose a SW pixel format, just to honour the
The sentence here is incomplete.
>
> At least on the wglinfo and friends case the alpha bits are not needed,
> so this change will make sure that HW accelerated formats will be chosen
> before SW ones.
> ---
> src/wgl/sharedtex_mt.c | 6 ++++--
> src/wgl/wglinfo.c | 1 +
> src/wgl/wglthreads.c | 3 ++-
> 3 files changed, 7 insertions(+), 3 deletions(-)
>
> diff --git a/src/wgl/sharedtex_mt.c b/src/wgl/sharedtex_mt.c
> index 161b2bb..073b100 100644
> --- a/src/wgl/sharedtex_mt.c
> +++ b/src/wgl/sharedtex_mt.c
> @@ -118,7 +118,7 @@ initMainthread(void)
> {
> WNDCLASS wc = {0};
> HWND win;
> - PIXELFORMATDESCRIPTOR pfd = {0};
> + PIXELFORMATDESCRIPTOR pfd;
> int visinfo;
>
> wc.lpfnWndProc = WndProc;
> @@ -147,6 +147,7 @@ initMainthread(void)
> Error("Couldn't obtain HDC");
> }
>
> + memset(&pfd, 0, sizeof(pfd));
> pfd.cColorBits = 24;
> pfd.cDepthBits = 24;
> pfd.dwFlags = PFD_DOUBLEBUFFER | PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL;
> @@ -405,7 +406,7 @@ threadRunner (void *arg)
> {
> struct thread_init_arg *tia = (struct thread_init_arg *) arg;
> struct window *win;
> - PIXELFORMATDESCRIPTOR pfd = {0};
> + PIXELFORMATDESCRIPTOR pfd;
> int visinfo;
>
> win = &Windows[tia->id];
> @@ -419,6 +420,7 @@ threadRunner (void *arg)
> if(tia->id > 0)
> WaitForSingleObject(Windows[tia->id - 1].hEventInitialised, INFINITE);
>
> + memset(&pfd, 0, sizeof(pfd));
> pfd.cColorBits = 24;
> pfd.cDepthBits = 24;
> pfd.dwFlags = PFD_DOUBLEBUFFER | PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL;
> diff --git a/src/wgl/wglinfo.c b/src/wgl/wglinfo.c
> index 30b1307..b6285ec 100644
> --- a/src/wgl/wglinfo.c
> +++ b/src/wgl/wglinfo.c
> @@ -123,6 +123,7 @@ print_screen_info(HDC _hdc, GLboolean limits, GLboolean singleLine,
> return;
> }
>
> + memset(&pfd, 0, sizeof(pfd));
> pfd.cColorBits = 3;
> pfd.cRedBits = 1;
> pfd.cGreenBits = 1;
> diff --git a/src/wgl/wglthreads.c b/src/wgl/wglthreads.c
> index 27dca10..2ee42e2 100644
> --- a/src/wgl/wglthreads.c
> +++ b/src/wgl/wglthreads.c
> @@ -430,7 +430,7 @@ create_window(struct winthread *wt, HGLRC shareCtx)
> int ypos = (wt->Index / 8) * (width + 20);
> HWND win;
> HDC hdc;
> - PIXELFORMATDESCRIPTOR pfd = {0};
> + PIXELFORMATDESCRIPTOR pfd;
> int visinfo;
> HGLRC ctx;
>
> @@ -463,6 +463,7 @@ create_window(struct winthread *wt, HGLRC shareCtx)
> Error("Couldn't obtain HDC");
> }
>
> + memset(&pfd, 0, sizeof(pfd));
> pfd.cColorBits = 24;
> pfd.cDepthBits = 24;
> pfd.dwFlags = PFD_DOUBLEBUFFER | PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL;
>
More information about the mesa-dev
mailing list