wglMakeCurrent fails + WGL_NV_gpu_affinity

System config:-

Windows XP 32-bit
Single Quadro FX 4600
Driver version 197.54

I’m trying to understand the WGL_NV_gpu_affinity extension. I know that I have only 1 GPU at the moment and I actually dont need to use this extension. My application will have to scale to multiple GPUs eventually.

  1. hWnd = CreateWindow()

  2. hDC = GetDC(hWnd)

  3. hRC = wglCreateContext(hDC)

  4. affDC = wglCreateAffinityDCNV(hGPU)

  5. affRC = wglCreateContext(affDC)

Things that work:-

Case 1:
wglMakeCurrent(hDC, hRC);

  • The usual and it works fine.

Case 2:
wglMakeCurrent(affDC, affRC);

  • This works fine too.

Case 3:
wglMakeCurrent(hDC, affRC); => regularDC + affinityRC

  • It does not work. wglMakeCurrent() call FAILS.

According to the spec of WGL_NV_gpu_affinity it is legal to do this. Did anyone have this problem ?

Is the pixel formats of the hDC and affDC the same? They need to be.
Are you remembering to set the pixel format of the affDC?

yes, I have set the pixel format for affDC and they have the same pixel format.

Does GetLastError() return anything useful?

Apologies, my pixel format was different. After making it the same it works fine but have different problem now.

Problem:-

  1. Create win1 on disp1 connected to gpu1
  2. Create win2 on disp2 connected to gpu2
  3. Create (hDC1, hRC1) & (affDC1, affRC1) for win1/gpu1
  4. Create (hDC2, hRC2) & (affDC2, affRC2) for win2/gpu2

Drawing white to win1 & win2
5) wglMakeCurrent(hDC1, affRC1) and glClear(GL_COLOR_BUFFER_BIT)
6) wglMakeCurrent(hDC2, affRC2) and glClear(GL_COLOR_BUFFER_BIT)

  • Step 5 displays white on win1
  • Step 6 DOES NOT display white on win2 ?
  • When win1 spans across disp1 & disp2, with step 5, I thought it should clear only the portion of win1 that belongs to disp1/gpu1 but clears the entire win1 (even the portion that is on disp2/gpu2)

The wglMakeCurrent calls are successful and no GL errors either.

I’ve learn that on certain setups, on new Nvidia drivers, the behavior for GPU affinity has changed (sadly). This is how things work on Windows 7 also, but they’ve brought it back to XP also.
You can’t bind a affinity RC to a window DC (except for the first GPU it seems). You should do your rendering to an FBO using the affinity DC + affinity RC.
Then copy the frame to a texture in a non-affinity RC (bound to the windows DC) using
WGL_NV_COPY_IMAGE
http://www.opengl.org/registry/specs/NV/copy_image.txt

Render the texture as a screen aligned quad.