private void CreateStaging()
        {
            if (_staging == null)
            {
                D3D.Texture1DDescription desc = new D3D.Texture1DDescription();
                desc.ArraySize      = 1;
                desc.BindFlags      = D3D.BindFlags.None;
                desc.CpuAccessFlags = D3D.CpuAccessFlags.Write | D3D.CpuAccessFlags.Read;
                desc.Format         = D3D10Helper.ToD3DSurfaceFormat(base.Format);
                desc.Width          = base.Width;
                desc.MipLevels      = _mipCount;
                desc.Usage          = D3D.ResourceUsage.Staging;

                _staging = new D3D.Texture1D(_graphicsDevice, desc);

                //Add to tracker
                _renderer.Resources.AddTrackedObject(_staging.ComPointer, this);
            }
        }
        /// <summary>
        /// Releases unmanaged and - optionally - managed resources
        /// </summary>
        /// <param name="disposing"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param>
        protected override void Dispose(bool disposing)
        {
            if (!IsDisposed)
            {
                //Dispose of managed resources
                if (disposing)
                {
                    if (_shaderResourceView != null)
                    {
                        if (_renderer != null)
                        {
                            _renderer.Resources.RemoveTrackedObject(_shaderResourceView.ComPointer);
                        }
                        _shaderResourceView.Dispose();
                        _shaderResourceView = null;
                    }

                    if (_texture1D != null)
                    {
                        if (_renderer != null)
                        {
                            _renderer.Resources.RemoveTrackedObject(_texture1D.ComPointer);
                        }
                        _texture1D.Dispose();
                        _texture1D = null;
                    }

                    if (_staging != null)
                    {
                        if (_renderer != null)
                        {
                            _renderer.Resources.RemoveTrackedObject(_staging.ComPointer);
                        }
                        _staging.Dispose();
                        _staging = null;
                    }
                }
                base.Dispose(disposing);
            }
        }
        /// <summary>
        /// Creates a new instance of <see cref="D3D10Texture1DImplementation"/>.
        /// </summary>
        /// <param name="renderer">The D3D10 renderer.</param>
        /// <param name="width">The width of the texture.</param>
        /// <param name="genMipMaps">True if mip maps should be generated.</param>
        /// <param name="format">The surface format.</param>
        /// <param name="data">The initial data.</param>
        internal D3D10Texture1DImplementation(D3D10Renderer renderer, int width, bool genMipMaps, SurfaceFormat format, DataBuffer data)
            : base(width, format)
        {
            //Set common properties
            _renderer       = renderer;
            _graphicsDevice = _renderer.GraphicsDevice;

            //Do we want to generate mip maps, and do we have the data to do so? (if not, cancel mip map generation)
            bool canGenMipmaps = (genMipMaps && (data != null));

            D3D.Texture1DDescription descTex = new D3D.Texture1DDescription();
            descTex.ArraySize      = 1;
            descTex.Width          = width;
            descTex.Usage          = _usage = D3D.ResourceUsage.Default;
            descTex.CpuAccessFlags = D3D.CpuAccessFlags.None;
            descTex.Format         = D3D10Helper.ToD3DSurfaceFormat(format);
            descTex.MipLevels      = (genMipMaps) ? 0 : 1;

            //Set mip map generation params
            if (canGenMipmaps)
            {
                descTex.BindFlags   = D3D.BindFlags.ShaderResource | D3D.BindFlags.RenderTarget;
                descTex.OptionFlags = D3D.ResourceOptionFlags.GenerateMipMaps;
            }
            else
            {
                descTex.BindFlags   = D3D.BindFlags.ShaderResource;
                descTex.OptionFlags = D3D.ResourceOptionFlags.None;
            }

            //Create the texture and shader view
            _texture1D          = new D3D.Texture1D(_graphicsDevice, descTex);
            _shaderResourceView = new D3D.ShaderResourceView(_graphicsDevice, _texture1D);

            //Add to tracker
            _renderer.Resources.AddTrackedObject(_texture1D.ComPointer, this);
            _renderer.Resources.AddTrackedObject(_shaderResourceView.ComPointer, this);

            //Set the final mip count
            _mipCount = _texture1D.Description.MipLevels;

            //Now set the initial data if its present
            if (data != null)
            {
                try {
                    this.SetData <byte>(data.ByteDataCopy, 0, 0, width, 0, data.ElementSizeInBytes * data.Length);

                    if (genMipMaps)
                    {
                        _graphicsDevice.GenerateMips(_shaderResourceView);
                    }

                    //Dispose of the staging texture
                    if (_staging != null)
                    {
                        _staging.Dispose();
                        _staging = null;
                    }
                } catch (Exception e) {
                    Dispose();
                    throw new TeslaException("Error setting Texture data.", e);
                }
            }
        }