Commit c3eca06a authored by Alex Henrie's avatar Alex Henrie Committed by Alexandre Julliard

opengl32/tests: Make the wglShareLists tests comprehensive.

parent 467604c6
......@@ -541,54 +541,84 @@ static void test_setpixelformat(HDC winhdc)
static void test_sharelists(HDC winhdc)
{
HGLRC hglrc1, hglrc2, hglrc3;
BOOL res;
hglrc1 = wglCreateContext(winhdc);
res = wglShareLists(0, 0);
ok(res == FALSE, "Sharing display lists for no contexts passed!\n");
BOOL res, nvidia, amd, source_current, source_sharing, dest_current, dest_sharing;
HGLRC source, dest, other;
/* Test 1: Create a context and just share lists without doing anything special */
hglrc2 = wglCreateContext(winhdc);
if(hglrc2)
{
res = wglShareLists(hglrc1, hglrc2);
ok(res, "Sharing of display lists failed\n");
wglDeleteContext(hglrc2);
}
res = wglShareLists(NULL, NULL);
ok(!res, "Sharing display lists for no contexts passed!\n");
/* Test 2: Share display lists with a 'destination' context which has been made current */
hglrc2 = wglCreateContext(winhdc);
if(hglrc2)
{
res = wglMakeCurrent(winhdc, hglrc2);
ok(res, "Make current failed\n");
res = wglShareLists(hglrc1, hglrc2);
todo_wine ok(res, "Sharing display lists with a destination context which has been made current failed\n");
wglMakeCurrent(0, 0);
wglDeleteContext(hglrc2);
}
nvidia = !!strstr((const char*)glGetString(GL_VENDOR), "NVIDIA");
amd = strstr((const char*)glGetString(GL_VENDOR), "AMD") ||
strstr((const char*)glGetString(GL_VENDOR), "ATI");
/* Test 3: Share display lists with a context which already shares display lists with another context.
* According to MSDN the second parameter cannot share any display lists but some buggy drivers might allow it */
hglrc3 = wglCreateContext(winhdc);
if(hglrc3)
for (source_current = FALSE; source_current <= TRUE; source_current++)
{
res = wglShareLists(hglrc3, hglrc1);
ok(res == FALSE, "Sharing of display lists passed for a context which already shared lists before\n");
wglDeleteContext(hglrc3);
}
/* Test 4: Share display lists with a 'source' context which has been made current */
hglrc2 = wglCreateContext(winhdc);
if(hglrc2)
{
res = wglMakeCurrent(winhdc, hglrc1);
ok(res, "Make current failed\n");
res = wglShareLists(hglrc1, hglrc2);
ok(res, "Sharing display lists with a source context which has been made current failed\n");
wglMakeCurrent(0, 0);
wglDeleteContext(hglrc2);
for (source_sharing = FALSE; source_sharing <= TRUE; source_sharing++)
{
for (dest_current = FALSE; dest_current <= TRUE; dest_current++)
{
for (dest_sharing = FALSE; dest_sharing <= TRUE; dest_sharing++)
{
winetest_push_context("source_current=%d source_sharing=%d dest_current=%d dest_sharing=%d",
source_current, source_sharing, dest_current, dest_sharing);
source = wglCreateContext(winhdc);
ok(!!source, "Create source context failed\n");
dest = wglCreateContext(winhdc);
ok(!!dest, "Create dest context failed\n");
other = wglCreateContext(winhdc);
ok(!!other, "Create other context failed\n");
if (source_current)
{
res = wglMakeCurrent(winhdc, source);
ok(res, "Make source current failed\n");
}
if (source_sharing)
{
res = wglShareLists(other, source);
todo_wine_if(source_current)
ok(res, "Sharing of display lists from other to source failed\n");
}
if (dest_current)
{
res = wglMakeCurrent(winhdc, dest);
ok(res, "Make dest current failed\n");
}
if (dest_sharing)
{
res = wglShareLists(other, dest);
todo_wine_if(dest_current)
ok(res, "Sharing of display lists from other to dest failed\n");
}
res = wglShareLists(source, dest);
todo_wine_if(dest_current || dest_sharing)
ok(res || broken(nvidia && !source_sharing && dest_sharing),
"Sharing of display lists from source to dest failed\n");
if (source_current || dest_current)
{
res = wglMakeCurrent(NULL, NULL);
ok(res, "Make none current failed\n");
}
res = wglDeleteContext(source);
ok(res, "Delete source context failed\n");
res = wglDeleteContext(dest);
ok(res, "Delete dest context failed\n");
if (!strcmp(winetest_platform, "wine") || !amd || source_sharing || !dest_sharing)
{
/* If source_sharing=FALSE and dest_sharing=TRUE, wglShareLists succeeds on AMD, but
* sometimes wglDeleteContext crashes afterwards. On Wine, both functions should always
* succeed in this case. */
res = wglDeleteContext(other);
ok(res, "Delete other context failed\n");
}
winetest_pop_context();
}
}
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment