1 / 16

ShaderX3 6.1 An Extensible Direct3D Resource Management System

ShaderX3 6.1 An Extensible Direct3D Resource Management System. Shader study 2007.7.25 이동 현. But Why?. 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.

noe
Download Presentation

ShaderX3 6.1 An Extensible Direct3D Resource Management System

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. ShaderX3 6.1 An Extensible Direct3D Resource Management System Shader study 2007.7.25 이동현

  2. But Why? • 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. Solution • 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. But When? • 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. But When? • 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. But How? • 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. SXResource Reset device before m_pD3DDevice->Reset Detach Device or Re-Create Device Reset device after m_pD3DDevice->Reset or Created( Re- ) device

  8. But Where? “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. But Where? • 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 call’s return value, and resetting the device upon failure.

  10. But Where?

  11. But What? • 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. Benefits • 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. Managing Resources • 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. Resource Management Best Practices D3DSDK Document 참고 하세요

  15. Video memory Local video memory Non-local video memory

More Related