summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosé Fonseca <jfonseca@vmware.com>2014-11-19 18:10:39 +0000
committerJosé Fonseca <jfonseca@vmware.com>2014-11-19 21:05:20 +0000
commita819167f7daf8fe060efd75d02825b082f1fd255 (patch)
tree33c3d0d9205c7336af91233c4d7832eae203bb04
parentbcd5a7d93770a1cd83a574c9d1026a45d48cc309 (diff)
downloadmesa-demos-a819167f7daf8fe060efd75d02825b082f1fd255.zip
mesa-demos-a819167f7daf8fe060efd75d02825b082f1fd255.tar.xz
wgl: Ensure PIXELFORMATDESCRIPTOR members are zeroed.
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 if has to in order to honour non-zero cAlphaBits. 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. Reviewed-by: Roland Scheidegger <sroland@vmware.com>
-rw-r--r--src/wgl/sharedtex_mt.c6
-rw-r--r--src/wgl/wglinfo.c1
-rw-r--r--src/wgl/wglthreads.c3
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;