PDA

View Full Version : Intel HD graphics mutlisampling problem (bug?)



paulk124
10-11-2012, 04:05 PM
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):

1) If I set numMultiSamples to 1, then the problem goes away.
2) 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?

dukey
10-17-2012, 06:00 AM
All the intel card I've tried dont support any kind of multisampling.

kyle_
10-17-2012, 06:20 AM
Is there any reason you use pbuffers instead of FBOs?

randall
10-17-2012, 07:31 AM
What he did is window-less OpenGL on Windows. Very nice.

paulk124
10-18-2012, 06:27 AM
I'm using a pbuffer instead of a FBO because I'm creating an off-screen bitmap that will be saved to a file.

randall
10-18-2012, 07:33 AM
And you don't want to create a window, right?

paulk124
10-19-2012, 07:14 AM
Correct, I don't want to create a window.

dukey
10-21-2012, 04:20 PM
just use an FBO and save to a bitmap.