public void CopyTo(ITexture destination, Extents2D srcRegion, Extents2D dstRegion, bool linearFilter) { ThreadedTexture dest = (ThreadedTexture)destination; if (_renderer.IsGpuThread()) { _renderer.New <TextureCopyToScaledCommand>().Set(Ref(this), Ref(dest), srcRegion, dstRegion, linearFilter); _renderer.QueueCommand(); } else { // Scaled copy can happen on another thread for a res scale flush. ThreadedHelpers.SpinUntilNonNull(ref Base); ThreadedHelpers.SpinUntilNonNull(ref dest.Base); Base.CopyTo(dest.Base, srcRegion, dstRegion, linearFilter); } }
/// <summary> /// Helper method for copying our Texture2DArray texture to the given target, with scaling. /// This creates temporary views for each array layer on both textures, copying each one at a time. /// </summary> /// <param name="target">The texture array to copy to</param> private void CopyArrayScaled(ITexture target) { TextureInfo viewInfo = new TextureInfo( Info.Address, Info.Width, Info.Height, 1, Info.Levels, Info.SamplesInX, Info.SamplesInY, Info.Stride, Info.IsLinear, Info.GobBlocksInY, Info.GobBlocksInZ, Info.GobBlocksInTileX, Target.Texture2D, Info.FormatInfo, Info.DepthStencilMode, Info.SwizzleR, Info.SwizzleG, Info.SwizzleB, Info.SwizzleA); TextureCreateInfo createInfo = TextureManager.GetCreateInfo(viewInfo, _context.Capabilities, ScaleFactor); for (int i = 0; i < Info.DepthOrLayers; i++) { ITexture from = HostTexture.CreateView(createInfo, i, 0); ITexture to = target.CreateView(createInfo, i, 0); from.CopyTo(to, new Extents2D(0, 0, from.Width, from.Height), new Extents2D(0, 0, to.Width, to.Height), true); from.Release(); to.Release(); } }