public void TestCreationWithInitialData()
        {
            // Define variables and constants
            const uint TEXTURE_WIDTH  = 1 << 6;
            const uint TEXTURE_HEIGHT = 1 << 4;
            const uint TEXTURE_DEPTH  = 1 << 3;
            Texture3DBuilder <TexelFormat.RGBA8UInt> texBuilder = TextureFactory.NewTexture3D <TexelFormat.RGBA8UInt>()
                                                                  .WithUsage(ResourceUsage.StagingRead)
                                                                  .WithPermittedBindings(GPUBindings.None)
                                                                  .WithWidth(TEXTURE_WIDTH)
                                                                  .WithHeight(TEXTURE_HEIGHT)
                                                                  .WithDepth(TEXTURE_DEPTH);

            TexelFormat.RGBA8UInt[]           initialDataA = new TexelFormat.RGBA8UInt[TEXTURE_WIDTH * TEXTURE_HEIGHT * TEXTURE_DEPTH];
            TexelFormat.RGBA8UInt[]           initialDataB = new TexelFormat.RGBA8UInt[TextureUtils.GetSizeTexels(true, TEXTURE_WIDTH, TEXTURE_HEIGHT, TEXTURE_DEPTH)];
            Texture3D <TexelFormat.RGBA8UInt> testTextureA, testTextureB;

            TexelArray3D <TexelFormat.RGBA8UInt> texAData;

            TexelArray3D <TexelFormat.RGBA8UInt>[] texBData = new TexelArray3D <TexelFormat.RGBA8UInt> [TextureUtils.GetNumMips(TEXTURE_WIDTH, TEXTURE_HEIGHT, TEXTURE_DEPTH)];

            // Set up context
            for (uint i = 0; i < initialDataA.Length; ++i)
            {
                initialDataA[i].R = (byte)i;
                initialDataA[i].G = (byte)(i * 2);
                initialDataA[i].B = (byte)(i * 3);
                initialDataA[i].A = (byte)(i * 4);
            }
            testTextureA = texBuilder.WithInitialData(initialDataA).Create();

            uint mipWidth   = TEXTURE_WIDTH;
            uint mipHeight  = TEXTURE_HEIGHT;
            uint mipDepth   = TEXTURE_DEPTH;
            uint texelIndex = 0U;

            while (mipWidth > 1U || mipHeight > 1U || mipDepth > 1U)
            {
                for (uint w = 0; w < mipDepth; ++w)
                {
                    for (uint v = 0; v < mipHeight; ++v)
                    {
                        for (uint u = 0; u < mipWidth; ++u, ++texelIndex)
                        {
                            initialDataB[texelIndex].R = (byte)(u + mipWidth + v + mipHeight + w + mipDepth);
                            initialDataB[texelIndex].G = (byte)(u + mipWidth + v + mipHeight + w + mipDepth * 2);
                            initialDataB[texelIndex].B = (byte)(u + mipWidth + v + mipHeight + w + mipDepth * 3);
                            initialDataB[texelIndex].A = (byte)(u + mipWidth + v + mipHeight + w + mipDepth * 4);
                        }
                    }
                }
                mipWidth  = Math.Max(1U, mipWidth >> 1);
                mipHeight = Math.Max(1U, mipHeight >> 1);
                mipDepth  = Math.Max(1U, mipDepth >> 1);
            }
            initialDataB[initialDataB.Length - 1] = new TexelFormat.RGBA8UInt {
                R = 3, G = 4, B = 5, A = 6
            };
            testTextureB = texBuilder.WithMipAllocation(true).WithInitialData(initialDataB).Create();

            // Execute
            texAData = testTextureA.Read(0U);
            for (uint i = 0; i < texBData.Length; ++i)
            {
                texBData[i] = testTextureB.Read(i);
            }

            // Assert outcome
            for (uint i = 0; i < texAData.Width; ++i)
            {
                Assert.AreEqual((byte)i, initialDataA[i].R);
                Assert.AreEqual((byte)(i * 2), initialDataA[i].G);
                Assert.AreEqual((byte)(i * 3), initialDataA[i].B);
                Assert.AreEqual((byte)(i * 4), initialDataA[i].A);
            }

            for (uint mipIndex = 0U; mipIndex < testTextureB.NumMips; ++mipIndex)
            {
                for (uint w = 0; w < testTextureB.MipDepth(mipIndex); ++w)
                {
                    for (uint v = 0; v < testTextureB.MipHeight(mipIndex); ++v)
                    {
                        for (uint u = 0; u < testTextureB.MipWidth(mipIndex); ++u)
                        {
                            Assert.AreEqual((byte)(u + testTextureB.MipWidth(mipIndex) + v + testTextureB.MipHeight(mipIndex) + w + testTextureB.MipDepth(mipIndex)), texBData[mipIndex][u, v, w].R);
                            Assert.AreEqual((byte)(u + testTextureB.MipWidth(mipIndex) + v + testTextureB.MipHeight(mipIndex) + w + testTextureB.MipDepth(mipIndex) * 2), texBData[mipIndex][u, v, w].G);
                            Assert.AreEqual((byte)(u + testTextureB.MipWidth(mipIndex) + v + testTextureB.MipHeight(mipIndex) + w + testTextureB.MipDepth(mipIndex) * 3), texBData[mipIndex][u, v, w].B);
                            Assert.AreEqual((byte)(u + testTextureB.MipWidth(mipIndex) + v + testTextureB.MipHeight(mipIndex) + w + testTextureB.MipDepth(mipIndex) * 4), texBData[mipIndex][u, v, w].A);
                        }
                    }
                }
            }

            testTextureA.Dispose();
            testTextureB.Dispose();
        }
        public void TestCreationWithInitialData()
        {
            // Define variables and constants
            const uint TEXTURE_WIDTH = 1 << 6;
            Texture1DBuilder <TexelFormat.RGBA8UInt> texBuilder = TextureFactory.NewTexture1D <TexelFormat.RGBA8UInt>()
                                                                  .WithUsage(ResourceUsage.StagingRead)
                                                                  .WithPermittedBindings(GPUBindings.None)
                                                                  .WithWidth(TEXTURE_WIDTH);

            TexelFormat.RGBA8UInt[]           initialDataA = new TexelFormat.RGBA8UInt[TEXTURE_WIDTH];
            TexelFormat.RGBA8UInt[]           initialDataB = new TexelFormat.RGBA8UInt[(TEXTURE_WIDTH << 1) - 1];
            Texture1D <TexelFormat.RGBA8UInt> testTextureA, testTextureB;

            TexelArray1D <TexelFormat.RGBA8UInt> texAData;

            TexelArray1D <TexelFormat.RGBA8UInt>[] texBData = new TexelArray1D <TexelFormat.RGBA8UInt> [TextureUtils.GetNumMips(TEXTURE_WIDTH)];

            // Set up context
            for (uint i = 0; i < initialDataA.Length; ++i)
            {
                initialDataA[i].R = (byte)i;
                initialDataA[i].G = (byte)(i * 2);
                initialDataA[i].B = (byte)(i * 3);
                initialDataA[i].A = (byte)(i * 4);
            }
            testTextureA = texBuilder.WithInitialData(initialDataA).Create();

            uint mipWidth   = TEXTURE_WIDTH;
            uint texelIndex = 0U;

            while (mipWidth > 0)
            {
                for (uint i = 0; i < mipWidth; ++i, ++texelIndex)
                {
                    initialDataB[texelIndex].R = (byte)(i + mipWidth);
                    initialDataB[texelIndex].G = (byte)(i * 2 + mipWidth);
                    initialDataB[texelIndex].B = (byte)(i * 3 + mipWidth);
                    initialDataB[texelIndex].A = (byte)(i * 4 + mipWidth);
                }
                mipWidth >>= 1;
            }
            testTextureB = texBuilder.WithMipAllocation(true).WithInitialData(initialDataB).Create();



            // Execute
            texAData = testTextureA.Read(0U);
            for (uint i = 0; i < texBData.Length; ++i)
            {
                texBData[i] = testTextureB.Read(i);
            }

            // Assert outcome
            for (uint i = 0; i < texAData.Width; ++i)
            {
                Assert.AreEqual((byte)i, initialDataA[i].R);
                Assert.AreEqual((byte)(i * 2), initialDataA[i].G);
                Assert.AreEqual((byte)(i * 3), initialDataA[i].B);
                Assert.AreEqual((byte)(i * 4), initialDataA[i].A);
            }

            mipWidth   = TEXTURE_WIDTH;
            texelIndex = 0U;
            while (mipWidth > 0)
            {
                for (uint i = 0; i < mipWidth; ++i, ++texelIndex)
                {
                    Assert.AreEqual((byte)(i + mipWidth), initialDataB[texelIndex].R);
                    Assert.AreEqual((byte)(i * 2 + mipWidth), initialDataB[texelIndex].G);
                    Assert.AreEqual((byte)(i * 3 + mipWidth), initialDataB[texelIndex].B);
                    Assert.AreEqual((byte)(i * 4 + mipWidth), initialDataB[texelIndex].A);
                }
                mipWidth >>= 1;
            }

            testTextureA.Dispose();
            testTextureB.Dispose();
        }