public void TestMipDimensions() { // Define variables and constants const uint ORIGINAL_WIDTH_TX = 1 << 10; Texture1D <TexelFormat.RGBA32UInt> texture = TextureFactory.NewTexture1D <TexelFormat.RGBA32UInt>() .WithWidth(ORIGINAL_WIDTH_TX) .WithMipAllocation(true) .WithUsage(ResourceUsage.Write); // Set up context // Execute for (int i = 0; ORIGINAL_WIDTH_TX >> i > 0; ++i) { Assert.AreEqual(ORIGINAL_WIDTH_TX >> i, texture.MipWidth((uint)i)); } #if !DEVELOPMENT && !RELEASE try { texture.MipWidth(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 ); }