public void TestSubresIndex() { // Define variables and constants Texture1D <TexelFormat.RGBA32UInt> texture = TextureFactory.NewTexture1D <TexelFormat.RGBA32UInt>() .WithWidth(1 << 5) .WithMipAllocation(true) .WithUsage(ResourceUsage.Write); // Set up context // Execute Assert.AreEqual(texture.GetSubresourceIndex(0U), 0U); Assert.AreEqual(texture.GetSubresourceIndex(1U), 1U); Assert.AreEqual(texture.GetSubresourceIndex(2U), 2U); #if !DEVELOPMENT && !RELEASE try { texture.GetSubresourceIndex(10000U); Assert.Fail(); } catch (AssuranceFailedException) { } #endif // Assert outcome texture.Dispose(); }
public void CopyTo(Texture1D <TTexel> dest, SubresourceBox srcRegion, uint srcMipIndex = 0U, uint dstMipIndex = 0U, uint destWriteOffsetX = 0U) { Assure.LessThan( srcMipIndex, NumMips, "Can not copy from mip level " + srcMipIndex + ": Only " + NumMips + " present in source texture." ); Assure.LessThan( dstMipIndex, dest.NumMips, "Can not copy to mip level " + dstMipIndex + ": Only " + dest.NumMips + " present in destination texture." ); Assure.LessThan( srcRegion.Left, MipWidth(srcMipIndex), "Buffer overflow: Please ensure you are not attempting to copy from past the end of the source texture." ); Assure.LessThanOrEqualTo( srcRegion.Right, MipWidth(srcMipIndex), "Buffer overflow: Please ensure you are not attempting to copy from past the end of the source texture." ); Assure.LessThanOrEqualTo( srcRegion.Width + destWriteOffsetX, dest.MipWidth(dstMipIndex), "Buffer overflow: Please ensure you are not attempting to copy to past the end of the destination texture." ); base.CopyTo( dest, srcRegion, GetSubresourceIndex(srcMipIndex), dest.GetSubresourceIndex(dstMipIndex), destWriteOffsetX, 0U, 0U ); }