Supposition of GraphicsDevice in XNA 2.0


In XNA2.0, the treatment of a graphics resource becomes easy and the necessity of caring about problems, such as device lost generated on Windows, can generate a graphics resource now easily within Game.LoadContent almost newly added in nothing.
In order that a LoadGraphicsContent method may also maintain compatibility with XNA 1.0, it is called only at once.

Once it generates all graphics resources, such as Texture2D, VertexBuffer, and RenderTarget, on XNA2.0, the instance will be in an always effective state.
Of course, even when it moves between monitors in a window in size change of the case which device lost and device reset generate, for example, a window, the change to a full screen, and a multi-monitor environment, the instance made first can be used satisfactory.

However, the contents of graphics resources which rewrite the contents dynamically, such as RenderTarget and DynamicVertexBuffer, will be canceled on restriction of the driver model of DirectX 9 at the time of device lost.
Usually, since it is generated with the following frame even if the contents are canceled, since many of graphics resources generated dynamically are generated for every frame, it is not necessary to carry out special processing.
Only when using techniques, such as motion blur by drawing in piles the contents of the graphics resource which must hold the contents between frames, for example, the brightness texture for tone mapping used by the HDR rendering, and a front frame, it is necessary to make it the initial value right at the time of device lost.

Conclusion
  • A graphics resource is generated within Game.LoadContent.
  • It is only at the time of a program start that Game.LoadContent is called.
  • DrawableGameComponent.LoadContent is called only at the time of initialization of a component.
  • It became unnecessary to remake the instance of a graphics resource.
  • As for the graphics resource which holds the contents between frames, the contents are canceled at the time of device lost.
    • The instance itself is effective also at the time of device lost, as.
    • SetData<T> etc. is used at the time of a GraphicsDevice.DeviceReset event, and changing into an initial value is only.
Reference
Hinikeni XNA