public void LockStrings()
        {
            var sw = Stopwatch.StartNew();

            _dict.FinalizeMapping();

            LogSzr.Debug($"Finalized string mapping of size {_dict.StringCount} in {sw.ElapsedMilliseconds}ms");
            sw.Restart();

            (_stringMapHash, _mappedStringsPackage) = _dict.GeneratePackage();

            LogSzr.Debug($"Wrote string package in {sw.ElapsedMilliseconds}ms size {ByteHelpers.FormatBytes(_mappedStringsPackage.Length)}");
            LogSzr.Debug($"String hash is {ConvertToBase64Url(_stringMapHash)}");
        }
Exemplo n.º 2
0
        public unsafe void Execute(IConsoleShell shell, string argStr, string[] args)
        {
            if (!OperatingSystem.IsWindows())
            {
                shell.WriteError("This command is only supported on Windows.");
                return;
            }

            IDXGIFactory1 *dxgiFactory;

            ThrowIfFailed(nameof(CreateDXGIFactory1), CreateDXGIFactory1(__uuidof <IDXGIFactory1>(), (void **)&dxgiFactory));

            uint          idx = 0;
            IDXGIAdapter *adapter;

            while (dxgiFactory->EnumAdapters(idx, &adapter) != DXGI_ERROR_NOT_FOUND)
            {
                DXGI_ADAPTER_DESC2 desc;
                IDXGIAdapter3 *    adapter3;
                adapter->QueryInterface(__uuidof <IDXGIAdapter3>(), (void **)&adapter3);
                adapter->Release();
                ThrowIfFailed("GetDesc", adapter3->GetDesc2(&desc));

                var descString = new ReadOnlySpan <char>(desc.Description, 128).TrimEnd('\0');
                shell.WriteLine(descString.ToString());

                DXGI_QUERY_VIDEO_MEMORY_INFO memInfo;

                adapter3->QueryVideoMemoryInfo(0, DXGI_MEMORY_SEGMENT_GROUP_LOCAL, &memInfo);
                shell.WriteLine($"Usage (local): {ByteHelpers.FormatBytes((long) memInfo.CurrentUsage)}");

                adapter3->QueryVideoMemoryInfo(0, DXGI_MEMORY_SEGMENT_GROUP_NON_LOCAL, &memInfo);
                shell.WriteLine($"Usage (non local): {ByteHelpers.FormatBytes((long) memInfo.CurrentUsage)}");

                idx += 1;

                adapter3->Release();
            }

            dxgiFactory->Release();
        }