コード例 #1
0
        private void Send(NvGpuVmm Vmm, int Value)
        {
            NvGpuPBEntry PBEntry = new NvGpuPBEntry(MethAddr, 0, Value);

            Engine.CallMethod(Vmm, PBEntry);

            MethAddr += MethIncr;
        }
コード例 #2
0
        private void WriteRegister(NvGpuPBEntry PBEntry)
        {
            int ArgsCount = PBEntry.Arguments.Count;

            if (ArgsCount > 0)
            {
                Registers[PBEntry.Method] = PBEntry.Arguments[ArgsCount - 1];
            }
        }
コード例 #3
0
 public void CallMethod(NvGpuVmm Vmm, NvGpuPBEntry PBEntry)
 {
     if (Methods.TryGetValue(PBEntry.Method, out NvGpuMethod Method))
     {
         Method(Vmm, PBEntry);
     }
     else
     {
         WriteRegister(PBEntry);
     }
 }
コード例 #4
0
ファイル: NvGpuEngine3d.cs プロジェクト: anouarghali/Ryujinx
        private void VertexEndGl(NvGpuVmm Vmm, NvGpuPBEntry PBEntry)
        {
            SetFrameBuffer(Vmm, 0);

            long[] Tags = UploadShaders(Vmm);

            Gpu.Renderer.BindProgram();

            SetAlphaBlending();

            UploadTextures(Vmm, Tags);
            UploadUniforms(Vmm);
            UploadVertexArrays(Vmm);
        }
コード例 #5
0
ファイル: NvGpuEngine3d.cs プロジェクト: anouarghali/Ryujinx
        private void ClearBuffers(NvGpuVmm Vmm, NvGpuPBEntry PBEntry)
        {
            int Arg0 = PBEntry.Arguments[0];

            int FbIndex = (Arg0 >> 6) & 0xf;

            int Layer = (Arg0 >> 10) & 0x3ff;

            GalClearBufferFlags Flags = (GalClearBufferFlags)(Arg0 & 0x3f);

            SetFrameBuffer(Vmm, 0);

            //TODO: Enable this once the frame buffer problems are fixed.
            //Gpu.Renderer.ClearBuffers(Layer, Flags);
        }
コード例 #6
0
ファイル: NvGpuEngine3d.cs プロジェクト: anouarghali/Ryujinx
        private void CbData(NvGpuVmm Vmm, NvGpuPBEntry PBEntry)
        {
            long Position = MakeInt64From2xInt32(NvGpuEngine3dReg.ConstBufferAddress);

            int Offset = ReadRegister(NvGpuEngine3dReg.ConstBufferOffset);

            foreach (int Arg in PBEntry.Arguments)
            {
                Vmm.WriteInt32(Position + Offset, Arg);

                Offset += 4;
            }

            WriteRegister(NvGpuEngine3dReg.ConstBufferOffset, Offset);
        }
コード例 #7
0
ファイル: NvGpuEngine3d.cs プロジェクト: anouarghali/Ryujinx
        private void CbBind(NvGpuVmm Vmm, NvGpuPBEntry PBEntry)
        {
            int Stage = (PBEntry.Method - 0x904) >> 3;

            int Index = PBEntry.Arguments[0];

            bool Enabled = (Index & 1) != 0;

            Index = (Index >> 4) & 0x1f;

            long Position = MakeInt64From2xInt32(NvGpuEngine3dReg.ConstBufferAddress);

            ConstBuffers[Stage][Index].Position = Position;
            ConstBuffers[Stage][Index].Enabled  = Enabled;

            ConstBuffers[Stage][Index].Size = ReadRegister(NvGpuEngine3dReg.ConstBufferSize);
        }
コード例 #8
0
ファイル: NvGpuEngine3d.cs プロジェクト: anouarghali/Ryujinx
        private void QueryControl(NvGpuVmm Vmm, NvGpuPBEntry PBEntry)
        {
            long Position = MakeInt64From2xInt32(NvGpuEngine3dReg.QueryAddress);

            int Seq  = Registers[(int)NvGpuEngine3dReg.QuerySequence];
            int Ctrl = Registers[(int)NvGpuEngine3dReg.QueryControl];

            int Mode = Ctrl & 3;

            if (Mode == 0)
            {
                //Write mode.
                Vmm.WriteInt32(Position, Seq);
            }

            WriteRegister(PBEntry);
        }
コード例 #9
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));
                }
            }
        }
コード例 #10
0
        private void TextureCopy(NvGpuVmm Vmm, NvGpuPBEntry PBEntry)
        {
            CopyOperation Operation = (CopyOperation)ReadRegister(NvGpuEngine2dReg.CopyOperation);

            bool SrcLinear = ReadRegister(NvGpuEngine2dReg.SrcLinear) != 0;
            int  SrcWidth  = ReadRegister(NvGpuEngine2dReg.SrcWidth);
            int  SrcHeight = ReadRegister(NvGpuEngine2dReg.SrcHeight);

            bool DstLinear = ReadRegister(NvGpuEngine2dReg.DstLinear) != 0;
            int  DstWidth  = ReadRegister(NvGpuEngine2dReg.DstWidth);
            int  DstHeight = ReadRegister(NvGpuEngine2dReg.DstHeight);
            int  DstPitch  = ReadRegister(NvGpuEngine2dReg.DstPitch);
            int  DstBlkDim = ReadRegister(NvGpuEngine2dReg.DstBlockDimensions);

            TextureSwizzle DstSwizzle = DstLinear
                ? TextureSwizzle.Pitch
                : TextureSwizzle.BlockLinear;

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

            long Tag = Vmm.GetPhysicalAddress(MakeInt64From2xInt32(NvGpuEngine2dReg.SrcAddress));

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

            bool IsFbTexture = Gpu.Engine3d.IsFrameBufferPosition(Tag);

            if (IsFbTexture && DstLinear)
            {
                DstSwizzle = TextureSwizzle.BlockLinear;
            }

            Texture DstTexture = new Texture(
                DstAddress,
                DstWidth,
                DstHeight,
                DstBlockHeight,
                DstBlockHeight,
                DstSwizzle,
                GalTextureFormat.A8B8G8R8);

            if (IsFbTexture)
            {
                //TODO: Change this when the correct frame buffer resolution is used.
                //Currently, the frame buffer size is hardcoded to 1280x720.
                SrcWidth  = 1280;
                SrcHeight = 720;

                Gpu.Renderer.GetFrameBufferData(Tag, (byte[] Buffer) =>
                {
                    CopyTexture(
                        Vmm,
                        DstTexture,
                        Buffer,
                        SrcWidth,
                        SrcHeight);
                });
            }
            else
            {
                long Size = SrcWidth * SrcHeight * 4;

                byte[] Buffer = Vmm.ReadBytes(SrcAddress, Size);

                CopyTexture(
                    Vmm,
                    DstTexture,
                    Buffer,
                    SrcWidth,
                    SrcHeight);
            }
        }