Results 1 to 8 of 8

Thread: RenderTarget lost...

  1. #1
    Legendary Member NecroDOME's Avatar
    Join Date
    Mar 2004
    Location
    The Netherlands, Eindhoven
    Posts
    1,059

    RenderTarget lost...

    Hello,

    I have created a RenderTarget, but when the device is lost, I need to reset the device. This wil cause to release all data in D3DPOOL_DEFAULT, where my render target is created...

    I use this for lightmapping, so what can I do to prevent that I "lose" the texture ?

    (I don't want to save it to a file...)

    Thnxz in advance
    NecroSOFT - End of line -

  2. #2

    RenderTarget lost...

    err.. Nothing...

    You can try to get RT data by IDirect3DDevice9.GetRenderTargetData function, but it's slow. Also you can try to use D3DXLoadSurfaceFromSurface function (but I doubt it will be speedier).
    There are only 10 types of people in this world; those who understand binary and those who don't.

  3. #3
    Legendary Member NecroDOME's Avatar
    Join Date
    Mar 2004
    Location
    The Netherlands, Eindhoven
    Posts
    1,059

    RenderTarget lost...

    Ill give it a try...

    Thnxz
    NecroSOFT - End of line -

  4. #4
    Legendary Member NecroDOME's Avatar
    Join Date
    Mar 2004
    Location
    The Netherlands, Eindhoven
    Posts
    1,059

    RenderTarget lost...

    Well.... i'm still trying to free the texture from the video memory:

    Texture := nil;
    FreeAndNil( Texture );

    I get the same result every time :|

    So is there a function to release everything from the D3DPOOL_DEFAULT ?
    NecroSOFT - End of line -

  5. #5

    RenderTarget lost...

    I don't get it...
    Correct way: "Texture := nil;"
    But next you say you are getting, what..?

    So is there a function to release everything from the D3DPOOL_DEFAULT ?
    You are responsible for allocationg and releasing any resource in DEFAULT pool in Direct3D. So be careful when creating and releasing resources. The only way to free resource is to release all references to it.
    There are only 10 types of people in this world; those who understand binary and those who don't.

  6. #6

    RenderTarget lost...

    I use this for lightmapping, so what can I do to prevent that I "lose" the texture ?
    How do you use created RenderTarget?
    1) You update it once at the beginning, and then use it later.
    2) You update it every frame.

    In the first case, just copy data form RT to some D3DPOOL_MANAGED texture, and destroy RT.

    In the second case, you have to destroy RT texture before Reset-ing your device, and recreate it after Reset.

    Code:
    Texture := nil; 
    FreeAndNil( Texture );
    Code:
    Texture := nil;
    will do the job

    Best regards...
    blog: http://alexionne.blogspot.com/

  7. #7
    Legendary Member NecroDOME's Avatar
    Join Date
    Mar 2004
    Location
    The Netherlands, Eindhoven
    Posts
    1,059

    RenderTarget lost...

    Thnxz for the repleys,

    I have created an empy project to see what i was doing wrong. It worked prerfectly, so there's a little bug in my own code smewhere...

    [Edit] I have succesfully removed the bug

    @alexondr

    Lightmaps are created when I load the map or when I call the function Create Lightmaps in my editor ...so I create them once...
    NecroSOFT - End of line -

  8. #8

    RenderTarget lost...

    You can do the following

    1) Create RenderTarget in D3DPOOL_DEFAULT
    2) Render LightMap
    3) Create temporary texture in D3DPOOL_SYSTEMMEM
    4) Use GetRenderTargetData to copy data from D3DPOOL_DEFAULT to D3DPOOL_SYSTEMMEM
    5) Destroy RenderTarget
    6) Create ordinary texture in D3DPOOL_MANAGED
    7) Use UpdateTexture to copy data from D3DPOOL_SYSTEMMEM to D3DPOOL_MANAGED
    Destroy temporary texture
    9) Use managed texture, and forget about device reset!

    The first thing: I haven't tried all of this, but it should work
    The only drawback of this approach is that it's slow. But since it's slow once, if that isn't problem for you...
    blog: http://alexionne.blogspot.com/

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •