/// <inheritdoc/> protected internal override bool OnRecreate() { // Dependency: wait for underlying texture to be recreated first if (Texture.LifetimeState != GraphicsResourceLifetimeState.Active) { return(false); } base.OnRecreate(); _nativeDeviceChild = Texture.NativeDeviceChild; NativeRenderTargetView = Texture.GetRenderTargetView(ViewType, ArraySlice, MipLevel); return(true); }
/// <summary> /// Create a RenderTarget from a texture. /// </summary> /// <param name="device">The device.</param> /// <param name="texture">The texture.</param> /// <param name="viewType">The view type.</param> /// <param name="arraySlice">The index of the array slice.</param> /// <param name="mipSlice">The index of the mip slice.</param> /// <param name="viewFormat">The pixel format.</param> internal RenderTarget(GraphicsDevice device, Texture texture, ViewType viewType, int arraySlice, int mipSlice, PixelFormat viewFormat = PixelFormat.None) : base(device) { _nativeDeviceChild = texture.NativeDeviceChild; Description = texture.Description; NativeRenderTargetView = texture.GetRenderTargetView(viewType, arraySlice, mipSlice); Width = Math.Max(1, Description.Width >> mipSlice); Height = Math.Max(1, Description.Height >> mipSlice); ViewType = viewType; ArraySlice = arraySlice; MipLevel = mipSlice; ViewFormat = viewFormat == PixelFormat.None ? Description.Format : viewFormat; Texture = texture; Texture.AddReferenceInternal(); }