c++ - Multisampling in a DirectX 9 application on Windows 7 -


in application try use multisampling anti-aliasing on simple 2d geometry. developed on windows xp had no problem enabling multisampling directx device , additional swap chains. now, on windows 7 multisampling feature seems not work @ all.

i've extracted short example code, nothing displaying triangle. when run program on windows xp, edge anti-aliased, on windows 7 isn't.

void testdx() {     struct customvertex {         float x, y, z, rhw;         dword color;     };      customvertex vertices[] = {         {0.0f, 0.0f, 1.0f, 1.0f, d3dcolor_xrgb(255, 0, 0),},         {700.0f, 500.0f, 1.0f, 1.0f, d3dcolor_xrgb(255, 0, 0),},         {0.0f, 500.0f, 1.0f, 1.0f, d3dcolor_xrgb(255, 0, 0),},     };      hresult hr;     dxwindow window;     window.new(getdesktopwindow(), "main window", 0, 0, 800, 600);      idirect3d9ptr d3d = direct3dcreate9(d3d_sdk_version);      d3dpresent_parameters d3dpp;     zeromemory(&d3dpp, sizeof d3dpp);     d3dpp.flags                     = (d3dpresentflag_video | d3dpresentflag_deviceclip) & ~d3dpresentflag_lockable_backbuffer;     d3dpp.windowed                  = true;     d3dpp.hdevicewindow             = window.gethandle();     d3dpp.backbufferwidth           = 800;     d3dpp.backbufferheight          = 600;     d3dpp.swapeffect                = d3dswapeffect_discard;     d3dpp.multisampletype           = d3dmultisample_nonmaskable;     d3dpp.multisamplequality        = 7;     d3dpp.presentationinterval      = d3dpresent_interval_immediate;     //d3dpp.backbufferformat        = m_d3ddm.format;     d3dpp.backbuffercount           = 0;     //d3dpp.enableautodepthstencil  = true;     //d3dpp.autodepthstencilformat  = d3dfmt_d16; // d3dfmt_d24x8;      idirect3ddevice9ptr device;      hr = d3d->createdevice(0, d3ddevtype_hal, window.gethandle(), d3dcreate_fpu_preserve | d3dcreate_hardware_vertexprocessing, &d3dpp, &device);      idirect3dswapchain9ptr swapchain;     hr = device->getswapchain(0, &swapchain);      hr = device->setfvf(d3dfvf_xyzrhw | d3dfvf_diffuse);      while (!window.shouldquit()) {         sleep(50);          idirect3dsurface9ptr targetsurface;         hr = swapchain->getbackbuffer(0, d3dbackbuffer_type_mono, &targetsurface);         hr = device->setrendertarget(0, targetsurface);          hr = device->clear(0, 0, d3dclear_target, d3dcolor_argb(255, 0, 0, 0), 1.0f, 0);         hr = device->beginscene();          hr = device->drawprimitiveup(d3dpt_trianglestrip, 1, vertices, sizeof customvertex);          hr = device->endscene();         hr = swapchain->present(0, 0, (hwnd)0, 0, d3dpresent_donotwait);     } } 

i tried compare code antialias sample microsoft ships directx sdk. , while anti-aliasing effect works in example code, not find significant difference (however, program flow not intuitive).

my question is, why anti-aliasing via multisampling work on windows xp not on windows 7 , can fix this?

removing d3dpresentflag_video helped enable multisampling on windows 7. added because application uses directx display video. flag not documented , seems hint video driver, don't know side effects setting or not setting flag has. has no other obvious effect, maybe there performance penalty i'm not aware of.


Comments