Exemple #1
0
        private void PushData(NvGpuVmm vmm, GpuMethodCall methCall)
        {
            if (_buffer == null)
            {
                return;
            }

            Profile.Begin(Profiles.GPU.EngineP2mf.PushData);

            for (int shift = 0; shift < 32 && _copyOffset < _copySize; shift += 8, _copyOffset++)
            {
                _buffer[_copyOffset] = (byte)(methCall.Argument >> shift);
            }

            if (methCall.IsLastCall)
            {
                if (_copyLinear)
                {
                    vmm.WriteBytes(_copyAddress, _buffer);
                }
                else
                {
                    BlockLinearSwizzle swizzle = new BlockLinearSwizzle(
                        _copyWidth,
                        _copyHeight, 1,
                        _copyGobBlockHeight, 1, 1);

                    int srcOffset = 0;

                    for (int y = _copyStartY; y < _copyHeight && srcOffset < _copySize; y++)
                    {
                        for (int x = _copyStartX; x < _copyWidth && srcOffset < _copySize; x++)
                        {
                            int dstOffset = swizzle.GetSwizzleOffset(x, y, 0);

                            vmm.WriteByte(_copyAddress + dstOffset, _buffer[srcOffset++]);
                        }
                    }
                }

                _buffer = null;
            }

            Profile.End(Profiles.GPU.EngineP2mf.PushData);
        }
Exemple #2
0
        public static bool CopyTexture(
            NvGpuVmm Vmm,
            GalImage SrcImage,
            GalImage DstImage,
            long SrcAddress,
            long DstAddress,
            int SrcX,
            int SrcY,
            int DstX,
            int DstY,
            int Width,
            int Height)
        {
            ISwizzle SrcSwizzle = TextureHelper.GetSwizzle(SrcImage);
            ISwizzle DstSwizzle = TextureHelper.GetSwizzle(DstImage);

            ImageDescriptor Desc = GetImageDescriptor(SrcImage.Format);

            if (GetImageDescriptor(DstImage.Format).BytesPerPixel != Desc.BytesPerPixel)
            {
                return(false);
            }

            int BytesPerPixel = Desc.BytesPerPixel;

            for (int Y = 0; Y < Height; Y++)
            {
                for (int X = 0; X < Width; X++)
                {
                    long SrcOffset = (uint)SrcSwizzle.GetSwizzleOffset(SrcX + X, SrcY + Y);
                    long DstOffset = (uint)DstSwizzle.GetSwizzleOffset(DstX + X, DstY + Y);

                    byte[] Texel = Vmm.ReadBytes(SrcAddress + SrcOffset, BytesPerPixel);

                    Vmm.WriteBytes(DstAddress + DstOffset, Texel);
                }
            }

            return(true);
        }
Exemple #3
0
        // TODO: Support non 2D
        public static bool CopyTexture(
            NvGpuVmm vmm,
            GalImage srcImage,
            GalImage dstImage,
            long srcAddress,
            long dstAddress,
            int srcX,
            int srcY,
            int dstX,
            int dstY,
            int width,
            int height)
        {
            ISwizzle srcSwizzle = TextureHelper.GetSwizzle(srcImage);
            ISwizzle dstSwizzle = TextureHelper.GetSwizzle(dstImage);

            ImageDescriptor desc = GetImageDescriptor(srcImage.Format);

            if (GetImageDescriptor(dstImage.Format).BytesPerPixel != desc.BytesPerPixel)
            {
                return(false);
            }

            int bytesPerPixel = desc.BytesPerPixel;

            for (int y = 0; y < height; y++)
            {
                for (int x = 0; x < width; x++)
                {
                    long srcOffset = (uint)srcSwizzle.GetSwizzleOffset(srcX + x, srcY + y, 0);
                    long dstOffset = (uint)dstSwizzle.GetSwizzleOffset(dstX + x, dstY + y, 0);

                    byte[] texel = vmm.ReadBytes(srcAddress + srcOffset, bytesPerPixel);

                    vmm.WriteBytes(dstAddress + dstOffset, texel);
                }
            }

            return(true);
        }
        private void PushData(NvGpuVmm Vmm, GpuMethodCall MethCall)
        {
            if (Buffer == null)
            {
                return;
            }

            for (int Shift = 0; Shift < 32 && CopyOffset < CopySize; Shift += 8, CopyOffset++)
            {
                Buffer[CopyOffset] = (byte)(MethCall.Argument >> Shift);
            }

            if (MethCall.IsLastCall)
            {
                if (CopyLinear)
                {
                    Vmm.WriteBytes(CopyAddress, Buffer);
                }
                else
                {
                    BlockLinearSwizzle Swizzle = new BlockLinearSwizzle(CopyWidth, 1, CopyGobBlockHeight);

                    int SrcOffset = 0;

                    for (int Y = CopyStartY; Y < CopyHeight && SrcOffset < CopySize; Y++)
                    {
                        for (int X = CopyStartX; X < CopyWidth && SrcOffset < CopySize; X++)
                        {
                            int DstOffset = Swizzle.GetSwizzleOffset(X, Y);

                            Vmm.WriteByte(CopyAddress + DstOffset, Buffer[SrcOffset++]);
                        }
                    }
                }

                Buffer = null;
            }
        }