Sign in to follow this  

D3DSurfaces and Reset/Lost device.[SOLVED]

This topic is 3873 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey all, I'm having a hell of a time dealing with Reset/Lost device in a post process effect I've been working on. I thought I was releasing and re-creating surfaces properly, but I guess not. DirectX debug libraries is telling me I'm leaking memory and going from Window mode to Fullscreen results in a crash(lock up). I've had windowed to fullscreen working flawlessly until I added this new effect so I know the problem lies here. Anyway, here is the surfaces I'm working with.
        LPDIRECT3DSURFACE9     m_Surface, m_OldBackBuffer;
        LPDIRECT3DTEXTURE9     m_SceneTexture;


Pretty simple. One surface for rendering, the other to hold the previous back buffer. Texture is the fully rendered scene. On Lost Device:
    // Release the target surface
    SAFE_RELEASE(m_Surface);
    // Release the original back buffer
    SAFE_RELEASE(m_OldBackBuffer);
    // Release the scene texture;
    SAFE_RELEASE(m_SceneTexture);


On Reset Device:
    // Create the texture to write to.
    m_pDevice->CreateTexture(640, 480, 0, D3DUSAGE_RENDERTARGET, D3DFMT_X8R8G8B8, D3DPOOL_DEFAULT, &m_SceneTexture, NULL);

    // Grab the surface level of the texture.
    m_SceneTexture->GetSurfaceLevel(0, &m_Surface);


The OldBackBuffer variable is released every frame:
    // Begin Scene
    m_pDevice->GetRenderTarget(0, &m_OldBackBuffer);

    m_pDevice->SetRenderTarget( 0, m_Surface);

    ...

    // End Scene, restore old back buffer.
    m_pDevice->SetRenderTarget(0, m_OldBackBuffer );

    SAFE_RELEASE(m_OldBackBuffer);


It's a fairly simple class so I'm really stumped as to how I am now dealing with Reset/Lost device properly. EDIT: My problem was that Reset device is called before a scene begins and my resources were being created twice. I removed my resource creation code from my constructor and all seems to be well now. [Edited by - ChaosPhoenix on May 8, 2007 11:49:03 AM]

Share this post


Link to post
Share on other sites

This topic is 3873 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this