예제 #1
0
        private void Execute(NvGpuVmm Vmm, NvGpuPBEntry PBEntry)
        {
            int Control = PBEntry.Arguments[0];

            bool SrcLinear = ((Control >> 7) & 1) != 0;
            bool DstLinear = ((Control >> 8) & 1) != 0;

            long SrcAddress = MakeInt64From2xInt32(NvGpuEngineDmaReg.SrcAddress);
            long DstAddress = MakeInt64From2xInt32(NvGpuEngineDmaReg.DstAddress);

            int SrcPitch = ReadRegister(NvGpuEngineDmaReg.SrcPitch);
            int DstPitch = ReadRegister(NvGpuEngineDmaReg.DstPitch);

            int DstBlkDim = ReadRegister(NvGpuEngineDmaReg.DstBlkDim);
            int DstSizeX  = ReadRegister(NvGpuEngineDmaReg.DstSizeX);
            int DstSizeY  = ReadRegister(NvGpuEngineDmaReg.DstSizeY);
            int DstSizeZ  = ReadRegister(NvGpuEngineDmaReg.DstSizeZ);
            int DstPosXY  = ReadRegister(NvGpuEngineDmaReg.DstPosXY);
            int DstPosZ   = ReadRegister(NvGpuEngineDmaReg.DstPosZ);

            int SrcBlkDim = ReadRegister(NvGpuEngineDmaReg.SrcBlkDim);
            int SrcSizeX  = ReadRegister(NvGpuEngineDmaReg.SrcSizeX);
            int SrcSizeY  = ReadRegister(NvGpuEngineDmaReg.SrcSizeY);
            int SrcSizeZ  = ReadRegister(NvGpuEngineDmaReg.SrcSizeZ);
            int SrcPosXY  = ReadRegister(NvGpuEngineDmaReg.SrcPosXY);
            int SrcPosZ   = ReadRegister(NvGpuEngineDmaReg.SrcPosZ);

            int DstPosX = (DstPosXY >> 0) & 0xffff;
            int DstPosY = (DstPosXY >> 16) & 0xffff;

            int SrcPosX = (SrcPosXY >> 0) & 0xffff;
            int SrcPosY = (SrcPosXY >> 16) & 0xffff;

            int SrcBlockHeight = 1 << ((SrcBlkDim >> 4) & 0xf);
            int DstBlockHeight = 1 << ((DstBlkDim >> 4) & 0xf);

            ISwizzle SrcSwizzle;

            if (SrcLinear)
            {
                SrcSwizzle = new LinearSwizzle(SrcPitch, 1);
            }
            else
            {
                SrcSwizzle = new BlockLinearSwizzle(SrcSizeX, 1, SrcBlockHeight);
            }

            ISwizzle DstSwizzle;

            if (DstLinear)
            {
                DstSwizzle = new LinearSwizzle(DstPitch, 1);
            }
            else
            {
                DstSwizzle = new BlockLinearSwizzle(DstSizeX, 1, DstBlockHeight);
            }

            for (int Y = 0; Y < DstSizeY; Y++)
            {
                for (int X = 0; X < DstSizeX; X++)
                {
                    long SrcOffset = SrcAddress + (uint)SrcSwizzle.GetSwizzleOffset(X, Y);
                    long DstOffset = DstAddress + (uint)DstSwizzle.GetSwizzleOffset(X, Y);

                    Vmm.WriteByte(DstOffset, Vmm.ReadByte(SrcOffset));
                }
            }
        }
예제 #2
0
        private void Execute(NvGpuVmm Vmm, NvGpuPBEntry PBEntry)
        {
            //TODO: Some registers and copy modes are still not implemented.
            int Control = PBEntry.Arguments[0];

            bool SrcLinear = ((Control >> 7) & 1) != 0;
            bool DstLinear = ((Control >> 8) & 1) != 0;
            bool Copy2d    = ((Control >> 9) & 1) != 0;

            long SrcAddress = MakeInt64From2xInt32(NvGpuEngineM2mfReg.SrcAddress);
            long DstAddress = MakeInt64From2xInt32(NvGpuEngineM2mfReg.DstAddress);

            int SrcPitch = ReadRegister(NvGpuEngineM2mfReg.SrcPitch);
            int DstPitch = ReadRegister(NvGpuEngineM2mfReg.DstPitch);

            int XCount = ReadRegister(NvGpuEngineM2mfReg.XCount);
            int YCount = ReadRegister(NvGpuEngineM2mfReg.YCount);

            int Swizzle = ReadRegister(NvGpuEngineM2mfReg.Swizzle);

            int DstBlkDim = ReadRegister(NvGpuEngineM2mfReg.DstBlkDim);
            int DstSizeX  = ReadRegister(NvGpuEngineM2mfReg.DstSizeX);
            int DstSizeY  = ReadRegister(NvGpuEngineM2mfReg.DstSizeY);
            int DstSizeZ  = ReadRegister(NvGpuEngineM2mfReg.DstSizeZ);
            int DstPosXY  = ReadRegister(NvGpuEngineM2mfReg.DstPosXY);
            int DstPosZ   = ReadRegister(NvGpuEngineM2mfReg.DstPosZ);

            int SrcBlkDim = ReadRegister(NvGpuEngineM2mfReg.SrcBlkDim);
            int SrcSizeX  = ReadRegister(NvGpuEngineM2mfReg.SrcSizeX);
            int SrcSizeY  = ReadRegister(NvGpuEngineM2mfReg.SrcSizeY);
            int SrcSizeZ  = ReadRegister(NvGpuEngineM2mfReg.SrcSizeZ);
            int SrcPosXY  = ReadRegister(NvGpuEngineM2mfReg.SrcPosXY);
            int SrcPosZ   = ReadRegister(NvGpuEngineM2mfReg.SrcPosZ);

            int SrcCpp = ((Swizzle >> 20) & 7) + 1;
            int DstCpp = ((Swizzle >> 24) & 7) + 1;

            int DstPosX = (DstPosXY >> 0) & 0xffff;
            int DstPosY = (DstPosXY >> 16) & 0xffff;

            int SrcPosX = (SrcPosXY >> 0) & 0xffff;
            int SrcPosY = (SrcPosXY >> 16) & 0xffff;

            int SrcBlockHeight = 1 << ((SrcBlkDim >> 4) & 0xf);
            int DstBlockHeight = 1 << ((DstBlkDim >> 4) & 0xf);

            long SrcPA = Vmm.GetPhysicalAddress(SrcAddress);
            long DstPA = Vmm.GetPhysicalAddress(DstAddress);

            if (Copy2d)
            {
                if (SrcLinear)
                {
                    SrcPosX = SrcPosY = SrcPosZ = 0;
                }

                if (DstLinear)
                {
                    DstPosX = DstPosY = DstPosZ = 0;
                }

                if (SrcLinear && DstLinear)
                {
                    for (int Y = 0; Y < YCount; Y++)
                    {
                        int SrcOffset = (SrcPosY + Y) * SrcPitch + SrcPosX * SrcCpp;
                        int DstOffset = (DstPosY + Y) * DstPitch + DstPosX * DstCpp;

                        long Src = SrcPA + (uint)SrcOffset;
                        long Dst = DstPA + (uint)DstOffset;

                        Vmm.Memory.CopyBytes(Src, Dst, XCount * SrcCpp);
                    }
                }
                else
                {
                    ISwizzle SrcSwizzle;

                    if (SrcLinear)
                    {
                        SrcSwizzle = new LinearSwizzle(SrcPitch, SrcCpp);
                    }
                    else
                    {
                        SrcSwizzle = new BlockLinearSwizzle(SrcSizeX, SrcCpp, SrcBlockHeight);
                    }

                    ISwizzle DstSwizzle;

                    if (DstLinear)
                    {
                        DstSwizzle = new LinearSwizzle(DstPitch, DstCpp);
                    }
                    else
                    {
                        DstSwizzle = new BlockLinearSwizzle(DstSizeX, DstCpp, DstBlockHeight);
                    }

                    for (int Y = 0; Y < YCount; Y++)
                    {
                        for (int X = 0; X < XCount; X++)
                        {
                            int SrcOffset = SrcSwizzle.GetSwizzleOffset(SrcPosX + X, SrcPosY + Y);
                            int DstOffset = DstSwizzle.GetSwizzleOffset(DstPosX + X, DstPosY + Y);

                            long Src = SrcPA + (uint)SrcOffset;
                            long Dst = DstPA + (uint)DstOffset;

                            Vmm.Memory.CopyBytes(Src, Dst, SrcCpp);
                        }
                    }
                }
            }
            else
            {
                Vmm.Memory.CopyBytes(SrcPA, DstPA, XCount);
            }
        }