Presentation is loading. Please wait.

Presentation is loading. Please wait.

Shader study 2007.7.25. Game and Windows applications can exist together on the desktop. When some event occurs, all video memory resources owned by the.

Similar presentations


Presentation on theme: "Shader study 2007.7.25. Game and Windows applications can exist together on the desktop. When some event occurs, all video memory resources owned by the."— Presentation transcript:

1 Shader study

2 Game and Windows applications can exist together on the desktop. When some event occurs, all video memory resources owned by the game can be lost. Lost video memory need to be restored before they can be used again. Changing from HAL to REF Rasterizer. What the hell…( if your frame rate counter drops from 60FPS to 60SPF!!!) But this is not easy, because your 3d device becomes lost.

3 Disable application and relevant key combos.(Alt-tab…) It gives a negative felling to end-users. You must keep track of each and every Direct3D resource you created in your application. Notifications – use virtual functions to deal with all Direct3D resources. Per-instance basis. So we have to add annoying restoration code for each D3D resource instance. This is not suitable for large scale applications.

4 If a d3d app is minimized, or switched to another app using Alt-Tab. The surfaces that are located in display could be lost. When changing display modes, display memory surfaces will be lost. Device lost scenarios. Full screen display mode -> minimized to different desktop display mode. A power management event( e.g., sleep or standby) Device running in windowed mode. Some process causes desktop display mode to change. Failure of the IDirect3DDevice9::Reset() method. A mysterious internal driver error. This is rare but happens.

5 When device is reset( IDirect3DDevice9::Reset()). Release all resources allocated in D3DPOOL_DEFAULT. When device is recreted. All must be released no matter what pool it is placed in.

6 SXProbe This will be responsible for probing the device to know whether it is lost or not. SXResource This is a base class that will be used to wrap Direct3D resources needed to persist device loss and recreation.

7 Reset device before m_pD3DDevice->Reset Detach Device or Re-Create Device Reset device after m_pD3DDevice->Reset or Created( Re- ) device

8 A lost device must recreate resources (including video memory resources) after it has been reset. If a device is lost, the application queries the device to see if it can be restored to the operational state. If not, the application waits until the device can be restored – [DXSDK02] Attach D3DDevice to SXProbe

9 Place our probe Prior to rendering a scene. For example, just before IDirect3DDevice9::BeginScene(); This is usually better, simply because this way the application can avoid rendering at all if the device is lost and cannot be restored at the moment. Just after calling IDirect3DDevice9::Present. This works by intercepting the calls return value, and resetting the device upon failure.

10

11 All video memory must be released before a device can be reset from a lost state to an operational state. Any swap chains – IDirect3DDevice9::CreateAdditionalSwapChain. Any resources placed in the D3DPOOL_DEFAULT memory class. Need not release resources in the D3DPOOL_MANAGED or D3DPOOL_SYSTEMMEM memory classes. Other state data is automatically destroyed by the transition to an operational state. For device recreate, every Direct3D resources must be released. Static vertex buffer -> placed in video memory Dynamic vertex buffer -> placed in AGP memory.

12 Persistent States In order to guarantee that are always correctly applied to the device no matter if it gets lost/recreated, a class can inherit from SXResource. Memory Approximation If the D3DPOOL_DEFAULT resources, check the backup copy. Rough estimation. Event-based Device State Information An application can inject an information resource Ex) When an application wants to suspend its operation upon device loss. Device Memory Management The Direct3D API recommends all D3DPOOL_DEFAULT resource first, then following them by D3DPOOL_MANAGED ones.

13 Base d3d management algorithm is least-recently- used priority In a single frame, switches to a most-recently-used priority.(between BeginScene and EndScene) D3DPOOL_MANAGED flag Persist through transitions between the lost and operational states of the device. The device can be restored with a call to …::Reset() But if the device must be destroyed and re-created, all resources created using D3DPOOL_MANAGED must be re-created. D3DPOOL_DEFAULT flag Not persist through transitions between the lost and operational states of the device. These resources must be released before calling reset.

14 D3DSDK Document

15 Local video memory Non-local video memory

16


Download ppt "Shader study 2007.7.25. Game and Windows applications can exist together on the desktop. When some event occurs, all video memory resources owned by the."

Similar presentations


Ads by Google