How to Fix RESZ if it only works for a single frame

We had a customer report the following "we are testing our game on Intel laptops and are having some problems when using some of the D3D9 hacks, namely the RESZ hack used to copy MSAA depth buffers onto an INTZ texture. It seems to work the first frame, but the contents of the texture are not updated in subsequent frames. The same code path works properly on AMD hardware, which supports the same extensions".

If you are unfamiliar with RESZ you can refer to the following document.  Link

I was reading through some code from another developer and saw the following lines of code.  Adding the very last line fixes this issue, which was confirmed by our original customer report.

       if (m_isRESZ)





             // Bind depth stencil texture to texture sampler 0

             device->SetTexture(0, m_pTexture);

             // Perform a dummy draw call to ensure texture sampler 0 is set before the // resolve is triggered

             // Vertex declaration and shaders may need to me adjusted to ensure no debug

             // error message is produced

             D3DXVECTOR3vDummyPoint(0.0f, 0.0f, 0.0f);

             device->SetRenderState(D3DRS_ZENABLE, FALSE);

             device->SetRenderState(D3DRS_ZWRITEENABLE, FALSE);

             device->SetRenderState(D3DRS_COLORWRITEENABLE, 0);

             device->DrawPrimitiveUP(D3DPT_POINTLIST, 1, vDummyPoint, sizeof(D3DXVECTOR3));

             device->SetRenderState(D3DRS_ZWRITEENABLE, TRUE);

             device->SetRenderState(D3DRS_ZENABLE, TRUE);

             device->SetRenderState(D3DRS_COLORWRITEENABLE, 0x0F);


             // Trigger the depth buffer resolve; after this call texture sampler 0

             // will contain the contents of the resolve operation

             device->SetRenderState(D3DRS_POINTSIZE, RESZ_CODE);


             // This hack to fix resz hack, has been found by Maksym Bezus!!!

             // Without this line resz will be resolved only for first frame

             device->SetRenderState(D3DRS_POINTSIZE, 0); // TROLOLO!!!


Anyway I thought I would pass this along in a Blog post in case others get stuck with this same issue.

For more complete information about compiler optimizations, see our Optimization Notice.