示例#1
0
        private unsafe static byte[] Read8Bpt4x4(IAMemory Memory, TextureInfo Texture)
        {
            int Width  = (Texture.Width + 3) / 4;
            int Height = (Texture.Height + 3) / 4;

            byte[] Output = new byte[Width * Height * 8];

            ISwizzle Swizzle = TextureHelper.GetSwizzle(Texture, 4, 8);

            (AMemory CpuMem, long Position) = TextureHelper.GetMemoryAndPosition(
                Memory,
                Texture.Position);

            fixed(byte *BuffPtr = Output)
            {
                long OutOffs = 0;

                for (int Y = 0; Y < Height; Y++)
                {
                    for (int X = 0; X < Width; X++)
                    {
                        long Offset = (uint)Swizzle.GetSwizzleOffset(X, Y);

                        long Tile = CpuMem.ReadInt64(Position + Offset);

                        *(long *)(BuffPtr + OutOffs) = Tile;

                        OutOffs += 8;
                    }
                }
            }

            return(Output);
        }
示例#2
0
        private unsafe static byte[] Read16BptCompressedTexture(IAMemory Memory, TextureInfo Texture, int BlockWidth, int BlockHeight)
        {
            int Width  = (Texture.Width + (BlockWidth - 1)) / BlockWidth;
            int Height = (Texture.Height + (BlockHeight - 1)) / BlockHeight;

            byte[] Output = new byte[Width * Height * 16];

            ISwizzle Swizzle = TextureHelper.GetSwizzle(Texture, BlockWidth, 16);

            (AMemory CpuMem, long Position) = TextureHelper.GetMemoryAndPosition(
                Memory,
                Texture.Position);

            fixed(byte *BuffPtr = Output)
            {
                long OutOffs = 0;

                for (int Y = 0; Y < Height; Y++)
                {
                    for (int X = 0; X < Width; X++)
                    {
                        long Offset = (uint)Swizzle.GetSwizzleOffset(X, Y);

                        long Tile0 = CpuMem.ReadInt64(Position + Offset + 0);
                        long Tile1 = CpuMem.ReadInt64(Position + Offset + 8);

                        *(long *)(BuffPtr + OutOffs + 0) = Tile0;
                        *(long *)(BuffPtr + OutOffs + 8) = Tile1;

                        OutOffs += 16;
                    }
                }
            }

            return(Output);
        }
示例#3
0
        private unsafe static byte[] Read16Bpp(IAMemory Memory, TextureInfo Texture)
        {
            int Width  = Texture.Width;
            int Height = Texture.Height;

            byte[] Output = new byte[Width * Height * 16];

            ISwizzle Swizzle = TextureHelper.GetSwizzle(Texture, 1, 16);

            (AMemory CpuMem, long Position) = TextureHelper.GetMemoryAndPosition(
                Memory,
                Texture.Position);

            fixed(byte *BuffPtr = Output)
            {
                long OutOffs = 0;

                for (int Y = 0; Y < Height; Y++)
                {
                    for (int X = 0; X < Width; X++)
                    {
                        long Offset = (uint)Swizzle.GetSwizzleOffset(X, Y);

                        long PxLow  = CpuMem.ReadInt64(Position + Offset + 0);
                        long PxHigh = CpuMem.ReadInt64(Position + Offset + 8);

                        *(long *)(BuffPtr + OutOffs + 0) = PxLow;
                        *(long *)(BuffPtr + OutOffs + 8) = PxHigh;

                        OutOffs += 16;
                    }
                }
            }

            return(Output);
        }