public void CopyUnscaled( ITextureInfo src, ITextureInfo dst, int srcLayer, int dstLayer, int srcLevel, int dstLevel) { TextureCreateInfo srcInfo = src.Info; TextureCreateInfo dstInfo = dst.Info; int srcDepth = srcInfo.GetDepthOrLayers(); int srcLevels = srcInfo.Levels; int dstDepth = dstInfo.GetDepthOrLayers(); int dstLevels = dstInfo.Levels; if (dstInfo.Target == Target.Texture3D) { dstDepth = Math.Max(1, dstDepth >> dstLevel); } int depth = Math.Min(srcDepth, dstDepth); int levels = Math.Min(srcLevels, dstLevels); CopyUnscaled(src, dst, srcLayer, dstLayer, srcLevel, dstLevel, depth, levels); }
public void CopyUnscaled( ITextureInfo src, ITextureInfo dst, int srcLayer, int dstLayer, int srcLevel, int dstLevel, int depth, int levels) { TextureCreateInfo srcInfo = src.Info; TextureCreateInfo dstInfo = dst.Info; int srcHandle = src.Handle; int dstHandle = dst.Handle; int srcWidth = srcInfo.Width; int srcHeight = srcInfo.Height; int dstWidth = dstInfo.Width; int dstHeight = dstInfo.Height; srcWidth = Math.Max(1, srcWidth >> srcLevel); srcHeight = Math.Max(1, srcHeight >> srcLevel); dstWidth = Math.Max(1, dstWidth >> dstLevel); dstHeight = Math.Max(1, dstHeight >> dstLevel); int blockWidth = 1; int blockHeight = 1; bool sizeInBlocks = false; // When copying from a compressed to a non-compressed format, // the non-compressed texture will have the size of the texture // in blocks (not in texels), so we must adjust that size to // match the size in texels of the compressed texture. if (!srcInfo.IsCompressed && dstInfo.IsCompressed) { srcWidth *= dstInfo.BlockWidth; srcHeight *= dstInfo.BlockHeight; blockWidth = dstInfo.BlockWidth; blockHeight = dstInfo.BlockHeight; sizeInBlocks = true; } else if (srcInfo.IsCompressed && !dstInfo.IsCompressed) { dstWidth *= srcInfo.BlockWidth; dstHeight *= srcInfo.BlockHeight; blockWidth = srcInfo.BlockWidth; blockHeight = srcInfo.BlockHeight; } int width = Math.Min(srcWidth, dstWidth); int height = Math.Min(srcHeight, dstHeight); for (int level = 0; level < levels; level++) { // Stop copy if we are already out of the levels range. if (level >= srcInfo.Levels || dstLevel + level >= dstInfo.Levels) { break; } if ((width % blockWidth != 0 || height % blockHeight != 0) && src is TextureView srcView && dst is TextureView dstView) { PboCopy(srcView, dstView, srcLayer, dstLayer, srcLevel + level, dstLevel + level, width, height); }