Hey;
I could use some help, I'm trying to do the RESZ-resolve of a depth-buffer (AutoDepthStencil D24S8), but I can do the resolve exactly one time, then the surface remains static:
The context is:
The code to resolve (ResolveDepthBuffer) is:
I've thrown a lot of stupid stuff into the code to see if it changes anything, the Begin/End are not necessary, I don't even think the GetDepthStencilSurface is necessary, the SetRenderTarget may not be necessary. Despite being an official feature there is nothing to be found in the net (no code, no explanation, nada). I can provide links to the entire code-base if necessary.
Please, help ...
It's the remaining piece to enable MSAA in Oblivion, while having the depthbuffer for effects.
I could use some help, I'm trying to do the RESZ-resolve of a depth-buffer (AutoDepthStencil D24S8), but I can do the resolve exactly one time, then the surface remains static:
The context is:
Code:
// Sets up the viewport.
float test[4] = { 0.0, 1.0, 1.0, 0.0 };
Renderer->SetupScreenSpaceCamera(test);
// Set up world/view/proj matrices to identity in case there's no vertex effect.
D3DXMATRIX mIdent;
D3DXMatrixIdentity(&mIdent);
D3DDevice->SetTransform(D3DTS_PROJECTION, &mIdent);
D3DDevice->SetTransform(D3DTS_VIEW, &mIdent);
D3DDevice->SetTransform(D3DTS_WORLD, &mIdent);
UpdateFrameConstants(Renderer);
/* is multi-sampled? this has to be done before everything else
* as a geometry-call will be done to resolve the depth-target
*/
bool resz;
D3DDevice->SetRenderTarget(0, RenderTo);
if ((resz = ResolveDepthBuffer(D3DDevice))) {
OrigDS.Initialise(GetDepthBufferTexture());
// FXMan->OrigDS.SetTexture("oblv_CurrDepthStencilZ_MAINPASS", pEffect);
}
Renderer->RenderStateManager->SetRenderState(D3DRS_COLORWRITEENABLE, D3DCOLORWRITEENABLE_ALPHA | D3DCOLORWRITEENABLE_BLUE | D3DCOLORWRITEENABLE_GREEN | D3DCOLORWRITEENABLE_RED, false);
Renderer->RenderStateManager->SetRenderState(D3DRS_ALPHATESTENABLE, false, false);
Renderer->RenderStateManager->SetRenderState(D3DRS_ALPHABLENDENABLE, false, false);
Renderer->RenderStateManager->SetRenderState(D3DRS_ZENABLE, D3DZB_FALSE, false);
Renderer->RenderStateManager->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE, false);
/* full-screen quad */
D3DDevice->SetStreamSource(0, EffectVertex, 0, sizeof(EffectQuad));
Renderer->RenderStateManager->SetFVF(EFFECTQUADFORMAT, false);
The code to resolve (ResolveDepthBuffer) is:
Code:
bool ResolveDepthBuffer(IDirect3DDevice9 *Device) {
if (DoResolve) {
IDirect3DSurface9 *pSurface = NULL;
Device->GetDepthStencilSurface(&pSurface);
if (pSurface != pOldSurface)
Device->SetDepthStencilSurface(pOldSurface);
Device->EndScene();
Device->BeginScene();
// Bind depth stencil texture to texture sampler 0
Device->SetTexture(0, pDepthTexture);
// Perform a dummy draw call to ensure texture sampler 0 is set before the
// resolve is triggered
// Vertex declaration and shaders may need to be adjusted to ensure no debug
// error message is produced
D3DXVECTOR3 vDummyPoint(0.0f, 0.0f, 0.0f);
Device->SetRenderState(D3DRS_ZENABLE, D3DZB_FALSE);
Device->SetRenderState(D3DRS_ZWRITEENABLE, D3DZB_FALSE);
Device->SetRenderState(D3DRS_COLORWRITEENABLE, 0);
Device->SetVertexShader(NULL);
Device->SetPixelShader(NULL);
Device->SetFVF(D3DFVF_XYZ);
Device->DrawPrimitiveUP(D3DPT_POINTLIST, 1, vDummyPoint, sizeof(D3DXVECTOR3));
Device->SetRenderState(D3DRS_COLORWRITEENABLE, 0x0F);
// Device->SetRenderState(D3DRS_ZENABLE, D3DZB_TRUE);
// Device->SetRenderState(D3DRS_ZWRITEENABLE, D3DZB_TRUE);
#define RESZ_MAGIC 0x7fa05000
// Trigger the depth buffer resolve; after this call texture sampler 0
// will contain the contents of the resolve operation
Device->SetRenderState(D3DRS_POINTSIZE, RESZ_MAGIC);
Device->EndScene();
Device->BeginScene();
Device->SetDepthStencilSurface(pSurface);
return true;
}
return false;
};
I've thrown a lot of stupid stuff into the code to see if it changes anything, the Begin/End are not necessary, I don't even think the GetDepthStencilSurface is necessary, the SetRenderTarget may not be necessary. Despite being an official feature there is nothing to be found in the net (no code, no explanation, nada). I can provide links to the entire code-base if necessary.
Please, help ...
It's the remaining piece to enable MSAA in Oblivion, while having the depthbuffer for effects.