Example #1
0
        public static DXGIPixelFormat ToDXGI(this DecimaPixelFormat fmt)
        {
            switch (fmt)
            {
            case DecimaPixelFormat.BC1:
                return(DXGIPixelFormat.BC1_UNORM);

            case DecimaPixelFormat.BC2:
                return(DXGIPixelFormat.BC2_UNORM);

            case DecimaPixelFormat.BC3:
                return(DXGIPixelFormat.BC3_UNORM);

            case DecimaPixelFormat.BC4:
                return(DXGIPixelFormat.BC4_UNORM);

            case DecimaPixelFormat.BC5:
                return(DXGIPixelFormat.BC5_UNORM);

            case DecimaPixelFormat.BC7:
                return(DXGIPixelFormat.BC7_UNORM);

            case DecimaPixelFormat.R8G8B8A8:
                return(DXGIPixelFormat.R8G8B8A8_UNORM);

            case DecimaPixelFormat.A8:
                return(DXGIPixelFormat.A8_UNORM);

            default:
                throw new ArgumentOutOfRangeException(nameof(fmt), fmt, default);
            }
        }
Example #2
0
        public TextureBase(Span <byte> data, Span <byte> streamedData, DecimaPixelFormat pixelFormat, int width, int height, int mips, int streamedMips)
        {
            Format = pixelFormat.ToDXGI();
            Width  = width;
            Height = height;
            Mips   = mips;

            var dataMips = MathHelper.Swizzle(data, streamedMips, mips, Format, Width, Height);

            if (streamedData.Length > 0)
            {
                var dataMain     = MathHelper.Swizzle(streamedData, 0, streamedMips, Format, Width, Height);
                var dataCombined = new Span <byte>(new byte[dataMips.Length + dataMain.Length]);
                dataMain.CopyTo(dataCombined);
                dataMips.CopyTo(dataCombined.Slice(dataMain.Length));
                Data = dataCombined.ToArray();
            }
            else
            {
                Data = dataMips.ToArray();
            }
        }