DX9 Resize Window

Started by
2 comments, last by Amr0 10 years, 9 months ago

Hi,

I know there are a lot of threads around the internet about that problem. I know that DirectX needs a Device Reset if Backbuffer needs to be resized. But I din't found any good solution to workaround that problem. I have windows application including also some dockingPanels.. so a lot of posibilities where the user can change the size of my directX window (i'm using a panel).

So actually I'm doing something like this to do one Reset:

1. Backup all Textures and Meshes with reading them back in a MemoryStream

2. Destroy all Objects Textures, Buffers, Targets..

3. Do a Device Reset

4. Recreate all Textures and Meshes by reading from MemoryStream

This procedure needs (with a small scene) around 2-3 Seconds on my monster PC.. I have no Idea how its on a small laptop.. This is very bad, because I saw some similar applications (also DX) where the resize seems to needs no time..

So I think there might be some possible solutions:

1. I heard about that the used Pool also defines that DirectX can make a copy on system memory automaticly but I have no Idea how to do this...

2. I was thinking about to create a fullscreen BackBuffer one time, and just render in a ViewPort which has correct Size/Position of my RenderPanel on Screen. But here I have no Idea how to get the output correct on the panel... and this could also reduce performance..

Finally I think this is a biggest problem of DirectX..., because before I was using OpenGL and there is no Problem like this.. Is that maybe fixed in DirectX10 or 11?

Hope somebody can help me..

Advertisement

If you put resources in POOL_MANAGED they will reside on both the GPU and SYS_MEM pools and these resource do not need to be released before a device reset. http://msdn.microsoft.com/en-us/library/windows/desktop/bb172584%28v=vs.85%29.aspx

http://slimdx.mdxinfo.com/latestdocs/Default.aspx?topic=Class+Reference/SlimDX.Direct3D9+Namespace/VolumeDescription+Structure/Pool+Property+

Worked on titles: CMR:DiRT2, DiRT 3, DiRT: Showdown, GRID 2, theHunter, theHunter: Primal, Mad Max, Watch Dogs: Legion

mhh also if I put them on Managed Pool, the textures are away after a Device.Reset.. What I'm doing wrong?

Check this out: Efficient Multiple Windows in Direct3D

Though it's not SlimDX and talks about multiple windows, the same idea can be used with a single resizable window.

Quoting the main idea for those who don't like jumping through links, or if the link dies:

This other approach which is demonstrated in the sample below is rather simple but does the job quite nicely. Here is how it goes. When it's time to render:
pD3DDevice->SetViewport( x=0, y=0, width and height = window's client rectangle );
pD3DDevice->BeginScene();
RenderWindowContents( hWnd );
pD3DDevice->EndScene();
pD3DDevice->Present( destRect = window's clientRect, NULL, hWnd, NULL );
ValidateRect( hWnd, NULL ); // No need for additional win32 painting.

This approach allows the user to freely resize a window without having to reinitialize a swap chain. It uses the observation that a window can not be larger than the desktop, so we render its contents to a rectangle as large as the window's client area in the left top corner of the back buffer, then present that rectangle into the window. This effectively copies the contents of that area into the window, and then the next window can overwrite the back buffer since its contents are no longer needed, regardless of where the windows are.

This topic is closed to new replies.

Advertisement