summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJon Turney <jon.turney@dronecode.org.uk>2016-07-11 22:17:21 +0100
committerJon Turney <jon.turney@dronecode.org.uk>2016-07-11 23:08:21 +0100
commit39cdfcd2fcb16a35ca25923d0787f15522afcb26 (patch)
tree2293195a2ed1c85913b4a1a59b88037bb54f32f0
parent9afc6ac0860b1c0eb3ad61112b070201229fcc64 (diff)
More Windows-DRI Fixes11.2.2-patches
Initialize renderType in driwindows_create_context_attribs() ../../../src/glx/driwindows_glx.c: In function ‘driwindows_create_context_attribs’: ../../../src/glx/driwindows_glx.c:247:9: warning: ‘renderType’ may be used uninitialized in this function [-Wmaybe-uninitialized] This presumably caused driwindows_create_context_attribs() to usually fail, causing mesa to fallback to an indirect context, masking other problems with create_context_attribs(). Fix windows_create_context()/windows_create_context_attribs() to return NULL on failure, not a broken context. Fix windows_create_context_attribs() not to deref shared if it is NULL to indicate no shared context.
-rw-r--r--src/glx/driwindows_glx.c2
-rw-r--r--src/glx/windows/windowsgl.c19
2 files changed, 18 insertions, 3 deletions
diff --git a/src/glx/driwindows_glx.c b/src/glx/driwindows_glx.c
index d0f9276ca2..f77b258e19 100644
--- a/src/glx/driwindows_glx.c
+++ b/src/glx/driwindows_glx.c
@@ -224,7 +224,7 @@ driwindows_create_context_attribs(struct glx_screen *base,
windowsContext *shared = NULL;
int i;
- uint32_t renderType;
+ uint32_t renderType = GLX_RGBA_TYPE;
/* Extract renderType from attribs */
for (i = 0; i < num_attribs; i++) {
diff --git a/src/glx/windows/windowsgl.c b/src/glx/windows/windowsgl.c
index be7c31c617..d3f591a28a 100644
--- a/src/glx/windows/windowsgl.c
+++ b/src/glx/windows/windowsgl.c
@@ -107,12 +107,18 @@ windows_create_context(int pxfi, windowsContext *shared)
gc->ctx = wglCreateContext(hdc);
- if (shared)
+ if (shared && gc->ctx)
wglShareLists(shared->ctx, gc->ctx);
ReleaseDC(hwnd, hdc);
DestroyWindow(hwnd);
+ if (!gc->ctx)
+ {
+ free(gc);
+ return NULL;
+ }
+
return gc;
}
@@ -155,16 +161,25 @@ windows_create_context_attribs(int pxfi, windowsContext *shared, const int *attr
0, 0, 0, 0,
NULL, NULL, GetModuleHandle(NULL), NULL);
HDC hdc = GetDC(hwnd);
+ HGLRC shareContext = NULL;
+ if (shared)
+ shareContext = shared->ctx;
// We must set the windows pixel format before we can create a WGL context
gc->pxfi = pxfi;
SetPixelFormat(hdc, gc->pxfi, NULL);
- gc->ctx = wglCreateContextAttribsARB(hdc, shared->ctx, attribList);
+ gc->ctx = wglCreateContextAttribsARB(hdc, shareContext, attribList);
ReleaseDC(hwnd, hdc);
DestroyWindow(hwnd);
+ if (!gc->ctx)
+ {
+ free(gc);
+ return NULL;
+ }
+
return gc;
}