예제 #1
0
        public static GalTextureSampler MakeSampler(NvGpu Gpu, NvGpuVmm Vmm, long TscPosition)
        {
            int[] Tsc = ReadWords(Vmm, TscPosition, 8);

            GalTextureWrap AddressU = (GalTextureWrap)((Tsc[0] >> 0) & 7);
            GalTextureWrap AddressV = (GalTextureWrap)((Tsc[0] >> 3) & 7);
            GalTextureWrap AddressP = (GalTextureWrap)((Tsc[0] >> 6) & 7);

            GalTextureFilter    MagFilter = (GalTextureFilter)((Tsc[1] >> 0) & 3);
            GalTextureFilter    MinFilter = (GalTextureFilter)((Tsc[1] >> 4) & 3);
            GalTextureMipFilter MipFilter = (GalTextureMipFilter)((Tsc[1] >> 6) & 3);

            GalColorF BorderColor = new GalColorF(
                BitConverter.Int32BitsToSingle(Tsc[4]),
                BitConverter.Int32BitsToSingle(Tsc[5]),
                BitConverter.Int32BitsToSingle(Tsc[6]),
                BitConverter.Int32BitsToSingle(Tsc[7]));

            return(new GalTextureSampler(
                       AddressU,
                       AddressV,
                       AddressP,
                       MinFilter,
                       MagFilter,
                       MipFilter,
                       BorderColor));
        }
예제 #2
0
        public Switch(IGalRenderer Renderer, IAalOutput AudioOut)
        {
            if (Renderer == null)
            {
                throw new ArgumentNullException(nameof(Renderer));
            }

            if (AudioOut == null)
            {
                throw new ArgumentNullException(nameof(AudioOut));
            }

            this.AudioOut = AudioOut;

            Log = new Logger();

            Gpu = new NvGpu(Renderer);

            VFs = new VirtualFileSystem();

            Os = new Horizon(this);

            Settings = new SystemSettings();

            Statistics = new PerformanceStatistics();

            Hid = new Hid(Log);

            Os.HidSharedMem.MemoryMapped   += Hid.ShMemMap;
            Os.HidSharedMem.MemoryUnmapped += Hid.ShMemUnmap;
        }
예제 #3
0
        public Switch(IGalRenderer Renderer, IAalOutput AudioOut)
        {
            if (Renderer == null)
            {
                throw new ArgumentNullException(nameof(Renderer));
            }

            if (AudioOut == null)
            {
                throw new ArgumentNullException(nameof(AudioOut));
            }

            this.AudioOut = AudioOut;

            Log = new Logger();

            Memory = new DeviceMemory();

            Gpu = new NvGpu(Renderer);

            FileSystem = new VirtualFileSystem();

            System = new Horizon(this);

            Statistics = new PerformanceStatistics();

            Hid = new Hid(this, System.HidSharedMem.PA);
        }
예제 #4
0
        public Switch(IGalRenderer Renderer, IAalOutput AudioOut)
        {
            if (Renderer == null)
            {
                throw new ArgumentNullException(nameof(Renderer));
            }

            if (AudioOut == null)
            {
                throw new ArgumentNullException(nameof(AudioOut));
            }

            this.AudioOut = AudioOut;

            Memory = new DeviceMemory();

            Gpu = new NvGpu(Renderer);

            FileSystem = new VirtualFileSystem();

            System = new Horizon(this);

            Statistics = new PerformanceStatistics();

            Hid = new Hid(this, System.HidBaseAddress);

            VsyncEvent = new AutoResetEvent(true);
        }
예제 #5
0
        public VideoDecoder(NvGpu gpu)
        {
            _gpu = gpu;

            _h264Decoder = new H264Decoder();
            _vp9Decoder  = new Vp9Decoder();
        }
예제 #6
0
        public NvGpuEngine3d(NvGpu Gpu)
        {
            this.Gpu = Gpu;

            Registers = new int[0xe00];

            Methods = new Dictionary <int, NvGpuMethod>();

            void AddMethod(int Meth, int Count, int Stride, NvGpuMethod Method)
            {
                while (Count-- > 0)
                {
                    Methods.Add(Meth, Method);

                    Meth += Stride;
                }
            }

            AddMethod(0x585, 1, 1, VertexEndGl);
            AddMethod(0x674, 1, 1, ClearBuffers);
            AddMethod(0x6c3, 1, 1, QueryControl);
            AddMethod(0x8e4, 16, 1, CbData);
            AddMethod(0x904, 5, 8, CbBind);

            ConstBuffers = new ConstBuffer[6][];

            for (int Index = 0; Index < ConstBuffers.Length; Index++)
            {
                ConstBuffers[Index] = new ConstBuffer[18];
            }

            FrameBuffers = new HashSet <long>();
        }
예제 #7
0
        public static GalTextureSampler MakeSampler(NvGpu gpu, NvGpuVmm vmm, long tscPosition)
        {
            int[] tsc = ReadWords(vmm, tscPosition, 8);

            GalTextureWrap addressU = (GalTextureWrap)((tsc[0] >> 0) & 7);
            GalTextureWrap addressV = (GalTextureWrap)((tsc[0] >> 3) & 7);
            GalTextureWrap addressP = (GalTextureWrap)((tsc[0] >> 6) & 7);

            bool depthCompare = ((tsc[0] >> 9) & 1) == 1;

            DepthCompareFunc depthCompareFunc = (DepthCompareFunc)((tsc[0] >> 10) & 7);

            GalTextureFilter    magFilter = (GalTextureFilter)((tsc[1] >> 0) & 3);
            GalTextureFilter    minFilter = (GalTextureFilter)((tsc[1] >> 4) & 3);
            GalTextureMipFilter mipFilter = (GalTextureMipFilter)((tsc[1] >> 6) & 3);

            GalColorF borderColor = new GalColorF(
                BitConverter.Int32BitsToSingle(tsc[4]),
                BitConverter.Int32BitsToSingle(tsc[5]),
                BitConverter.Int32BitsToSingle(tsc[6]),
                BitConverter.Int32BitsToSingle(tsc[7]));

            return(new GalTextureSampler(
                       addressU,
                       addressV,
                       addressP,
                       minFilter,
                       magFilter,
                       mipFilter,
                       borderColor,
                       depthCompare,
                       depthCompareFunc));
        }
예제 #8
0
        public VideoDecoder(NvGpu Gpu)
        {
            this.Gpu = Gpu;

            H264Decoder = new H264Decoder();
            Vp9Decoder  = new Vp9Decoder();
        }
예제 #9
0
 public NvHostChannelDeviceFile(ServiceCtx context) : base(context)
 {
     _gpu           = context.Device.Gpu;
     _memory        = context.Memory;
     _timeout       = 3000;
     _submitTimeout = 0;
     _timeslice     = 0;
 }
예제 #10
0
        public NvGpuFifo(NvGpu Gpu)
        {
            this.Gpu = Gpu;

            SubChannels = new NvGpuEngine[8];

            Macros = new CachedMacro[MacrosCount];

            Mme = new int[MmeWords];
        }
예제 #11
0
        public NvGpuFifo(NvGpu gpu)
        {
            _gpu = gpu;

            _subChannels = new NvGpuEngine[8];

            _macros = new CachedMacro[MacrosCount];

            _mme = new int[MmeWords];
        }
예제 #12
0
        public NvGpuEngine3d(NvGpu gpu)
        {
            _gpu = gpu;

            Registers = new int[0xe00];

            _methods = new Dictionary <int, NvGpuMethod>();

            void AddMethod(int meth, int count, int stride, NvGpuMethod method)
            {
                while (count-- > 0)
                {
                    _methods.Add(meth, method);

                    meth += stride;
                }
            }

            AddMethod(0x585, 1, 1, VertexEndGl);
            AddMethod(0x674, 1, 1, ClearBuffers);
            AddMethod(0x6c3, 1, 1, QueryControl);
            AddMethod(0x8e4, 16, 1, CbData);
            AddMethod(0x904, 5, 8, CbBind);

            _constBuffers = new ConstBuffer[6][];

            for (int index = 0; index < _constBuffers.Length; index++)
            {
                _constBuffers[index] = new ConstBuffer[18];
            }

            // Ensure that all components are enabled by default.
            // FIXME: Is this correct?
            WriteRegister(NvGpuEngine3dReg.ColorMaskN, 0x1111);

            WriteRegister(NvGpuEngine3dReg.FrameBufferSrgb, 1);

            WriteRegister(NvGpuEngine3dReg.FrontFace, (int)GalFrontFace.Cw);

            for (int index = 0; index < GalPipelineState.RenderTargetsCount; index++)
            {
                WriteRegister(NvGpuEngine3dReg.IBlendNEquationRgb + index * 8, (int)GalBlendEquation.FuncAdd);
                WriteRegister(NvGpuEngine3dReg.IBlendNFuncSrcRgb + index * 8, (int)GalBlendFactor.One);
                WriteRegister(NvGpuEngine3dReg.IBlendNFuncDstRgb + index * 8, (int)GalBlendFactor.Zero);
                WriteRegister(NvGpuEngine3dReg.IBlendNEquationAlpha + index * 8, (int)GalBlendEquation.FuncAdd);
                WriteRegister(NvGpuEngine3dReg.IBlendNFuncSrcAlpha + index * 8, (int)GalBlendFactor.One);
                WriteRegister(NvGpuEngine3dReg.IBlendNFuncDstAlpha + index * 8, (int)GalBlendFactor.Zero);
            }
        }
예제 #13
0
        public List <NvGpu> GetGpus()
        {
            List <NvGpu> results = new List <NvGpu>();

            try {
                if (NvmlInit())
                {
                    _nvmlDevices.Clear();
                    uint deviceCount = 0;
                    var  r           = NvmlNativeMethods.nvmlDeviceGetCount(ref deviceCount);
                    CheckResult(r, () => $"{nameof(NvmlNativeMethods.nvmlDeviceGetCount)} {r.ToString()}");
                    for (int i = 0; i < deviceCount; i++)
                    {
                        NvGpu gpu = new NvGpu {
                            GpuIndex = i
                        };
                        nvmlDevice nvmlDevice = new nvmlDevice();
                        r = NvmlNativeMethods.nvmlDeviceGetHandleByIndex((uint)i, ref nvmlDevice);
                        _nvmlDevices.Add(nvmlDevice);
                        CheckResult(r, () => $"{nameof(NvmlNativeMethods.nvmlDeviceGetHandleByIndex)}({((uint)i).ToString()}) {r.ToString()}");
                        r = NvmlNativeMethods.nvmlDeviceGetName(nvmlDevice, out string name);
                        CheckResult(r, () => $"{nameof(NvmlNativeMethods.nvmlDeviceGetName)} {r.ToString()}");
                        nvmlMemory memory = new nvmlMemory();
                        r = NvmlNativeMethods.nvmlDeviceGetMemoryInfo(nvmlDevice, ref memory);
                        CheckResult(r, () => $"{nameof(NvmlNativeMethods.nvmlDeviceGetMemoryInfo)} {r.ToString()}");
                        // short gpu name
                        if (!string.IsNullOrEmpty(name))
                        {
                            name = name.Replace("GeForce GTX ", string.Empty);
                            name = name.Replace("GeForce ", string.Empty);
                        }
                        nvmlPciInfo pci = new nvmlPciInfo();
                        r = NvmlNativeMethods.nvmlDeviceGetPciInfo(nvmlDevice, ref pci);
                        CheckResult(r, () => $"{nameof(NvmlNativeMethods.nvmlDeviceGetPciInfo)} {r.ToString()}");
                        gpu.Name        = name;
                        gpu.BusId       = (int)pci.bus;
                        gpu.TotalMemory = memory.total;
                        results.Add(gpu);
                    }
                }
            }
            catch {
            }

            return(results);
        }
예제 #14
0
        public NvGpuEngineM2mf(NvGpu gpu)
        {
            _gpu = gpu;

            Registers = new int[0x1d6];

            _methods = new Dictionary <int, NvGpuMethod>();

            void AddMethod(int meth, int count, int stride, NvGpuMethod method)
            {
                while (count-- > 0)
                {
                    _methods.Add(meth, method);

                    meth += stride;
                }
            }

            AddMethod(0xc0, 1, 1, Execute);
        }
예제 #15
0
        public NvGpuEngine2d(NvGpu Gpu)
        {
            this.Gpu = Gpu;

            Registers = new int[0xe00];

            Methods = new Dictionary <int, NvGpuMethod>();

            void AddMethod(int Meth, int Count, int Stride, NvGpuMethod Method)
            {
                while (Count-- > 0)
                {
                    Methods.Add(Meth, Method);

                    Meth += Stride;
                }
            }

            AddMethod(0xb5, 1, 1, TextureCopy);
        }
예제 #16
0
        public NvGpuEngineM2mf(NvGpu Gpu)
        {
            this.Gpu = Gpu;

            Registers = new int[0x1d6];

            Methods = new Dictionary <int, NvGpuMethod>();

            void AddMethod(int Meth, int Count, int Stride, NvGpuMethod Method)
            {
                while (Count-- > 0)
                {
                    Methods.Add(Meth, Method);

                    Meth += Stride;
                }
            }

            AddMethod(0xc0, 1, 1, Execute);
        }
예제 #17
0
        public NvGpuEngine2d(NvGpu Gpu)
        {
            this.Gpu = Gpu;

            Registers = new int[0x238];
        }
예제 #18
0
 public VideoImageComposer(NvGpu gpu)
 {
     _gpu = gpu;
 }
예제 #19
0
 public VideoImageComposer(NvGpu Gpu)
 {
     this.Gpu = Gpu;
 }
예제 #20
0
        public NvGpuEngine2d(NvGpu gpu)
        {
            _gpu = gpu;

            Registers = new int[0x238];
        }