I think I’ve found a bug with the Intel HD graphics driver but want to confirm with this community. The problem happens with an Intel HD P4000 video adapter with their latest driver. When I enable multisample above 1x, any drawing to the frame buffer causes the entire frame buffer to clear itself to RGBA color (0,0,0,0). Here’s the Windows code that demonstrates the problem:
int numMultiSamples = 4;
const int attributes[] =
{
WGL_SUPPORT_OPENGL_ARB, GL_TRUE, // need OpenGL supported
WGL_DRAW_TO_PBUFFER_ARB, GL_TRUE, // enable render to pbuffer
WGL_PIXEL_TYPE_ARB, WGL_TYPE_RGBA_ARB, // need RGBA colors
WGL_COLOR_BITS_ARB, 24, // at least 24 bits for color
WGL_SAMPLE_BUFFERS_ARB, GL_TRUE, // enable FSAA
WGL_SAMPLES_ARB, numMultiSamples,
NULL // end with a NULL terminator
};
int pixelFormat = 0;
UINT numFormats = 0;
HWND hWnd = ::GetDesktopWindow();
HDC hDC = ::GetDC (hWnd);
wglChoosePixelFormat (hDC, attributes, NULL, 1, &pixelFormat, &numFormats);
HPBUFFERARB hBitmapPbuffer = wglCreatePbuffer (hDC, pixelFormat, 100, 100, NULL);
HDC hBitmapPbufferDC = wglGetPbufferDC (hBitmapPbuffer);
HGLRC hBitmapRC = ::wglCreateContext (hBitmapPbufferDC);
VERIFY(wglMakeCurrent (hBitmapPbufferDC, hBitmapRC) != FALSE);
glDrawBuffer (GL_FRONT);
glClearColor(1.0f,1.0f,1.0f,1.0f);
glClear(GL_COLOR_BUFFER_BIT);
glDisable(GL_DEPTH_TEST);
glReadBuffer(GL_FRONT);
RGBQUAD rgbQuad;
glReadPixels (0, 0, 1, 1, GL_BGRA_EXT, GL_UNSIGNED_BYTE, (GLvoid *) &rgbQuad);
ASSERT(rgbQuad.rgbRed == 255);
glBegin (GL_POINTS);
glVertex3i (10,20,30);
glEnd();
glReadPixels (0, 0, 1, 1, GL_BGRA_EXT, GL_UNSIGNED_BYTE, (GLvoid *) &rgbQuad);
ASSERT(rgbQuad.rgbRed == 255);
The ASSERTs in the code just verify that the background red color is still 1. The first ASSERT passes but the second one fails. Note that between the two ASSERTs, there are only a few OpenGL function calls to draw a single pixel. In fact, not only is the pixel at x=0,y=0 cleared to RGBA color (0,0,0,0), but the entire color buffer is cleared.
I’ve found two workarounds to this bug (either of these will fix the problem):
- If I set numMultiSamples to 1, then the problem goes away.
- If I set the clear color to something other than (1,1,1,1), then the problem goes away. For example, glClearColor(1,0.9999f,1,1).
I’ve tried this same code on an Nvidia card and there is no problem. Can any of you please tell me if I’m doing something wrong of if this is indeed a bug in Intel’s driver code?