public static void NameD3D12Object(ID3D12RootSignature *pObject, string name)
 {
     fixed(char *pName = name)
     {
         pObject->SetName(pName);
     }
 }
Exemple #2
0
        public ComputePipelineStateDesc
        (
            ID3D12RootSignature *pRootSignature = null,
            ShaderBytecode?cS             = null,
            uint?nodeMask                 = null,
            CachedPipelineState?cachedPSO = null,
            PipelineStateFlags?flags      = null
        ) : this()
        {
            if (pRootSignature is not null)
            {
                PRootSignature = pRootSignature;
            }

            if (cS is not null)
            {
                CS = cS.Value;
            }

            if (nodeMask is not null)
            {
                NodeMask = nodeMask.Value;
            }

            if (cachedPSO is not null)
            {
                CachedPSO = cachedPSO.Value;
            }

            if (flags is not null)
            {
                Flags = flags.Value;
            }
        }
    public static ID3D12RootSignature *GetLatestD3D12RootSignature(ID3D12RootSignature *d3d12RootSignature, out uint d3d12RootSignatureVersion)
    {
        ID3D12RootSignature *result;

        d3d12RootSignatureVersion = 0;
        result = d3d12RootSignature;

        return(result);
    }
Exemple #4
0
 public LocalRootSignature
 (
     ID3D12RootSignature *pLocalRootSignature = null
 ) : this()
 {
     if (pLocalRootSignature is not null)
     {
         PLocalRootSignature = pLocalRootSignature;
     }
 }
 public GlobalRootSignature
 (
     ID3D12RootSignature *pGlobalRootSignature = null
 ) : this()
 {
     if (pGlobalRootSignature is not null)
     {
         PGlobalRootSignature = pGlobalRootSignature;
     }
 }
Exemple #6
0
 public void SetGraphicsRootSignature(ID3D12RootSignature *pRootSignature)
 {
     ((delegate * unmanaged <ID3D12GraphicsCommandList2 *, ID3D12RootSignature *, void>)(lpVtbl[30]))((ID3D12GraphicsCommandList2 *)Unsafe.AsPointer(ref this), pRootSignature);
 }
Exemple #7
0
 public void SetGraphicsRootSignature([NativeTypeName("ID3D12RootSignature *")] ID3D12RootSignature *pRootSignature)
 {
     ((delegate * stdcall <ID3D12GraphicsCommandList4 *, ID3D12RootSignature *, void>)(lpVtbl[30]))((ID3D12GraphicsCommandList4 *)Unsafe.AsPointer(ref this), pRootSignature);
 }
Exemple #8
0
 public void SetComputeRootSignature([NativeTypeName("ID3D12RootSignature *")] ID3D12RootSignature *pRootSignature)
 {
     ((delegate * unmanaged <ID3D12GraphicsCommandList1 *, ID3D12RootSignature *, void>)(lpVtbl[29]))((ID3D12GraphicsCommandList1 *)Unsafe.AsPointer(ref this), pRootSignature);
 }
Exemple #9
0
 /// <summary>
 /// Creates a new <see cref="PipelineData"/> instance with the specified parameters.
 /// </summary>
 /// <param name="d3D12RootSignature">The <see cref="ID3D12RootSignature"/> value for the current shader.</param>
 /// <param name="d3D12PipelineState">The compiled pipeline state to reuse for the current shader.</param>
 public PipelineData(ID3D12RootSignature *d3D12RootSignature, ID3D12PipelineState *d3D12PipelineState)
 {
     this.d3D12RootSignature = new ComPtr <ID3D12RootSignature>(d3D12RootSignature);
     this.d3D12PipelineState = new ComPtr <ID3D12PipelineState>(d3D12PipelineState);
 }
Exemple #10
0
        protected override void Dispose(bool isDisposing)
        {
            var swapChain = _swapChain;

            if (swapChain != null)
            {
                _swapChain = null;
                _          = swapChain->Release();
            }

            var device = _device;

            if (device != null)
            {
                _device = null;
                _       = device->Release();
            }

            for (var index = 0; index < FrameCount; index++)
            {
                var renderTarget = _renderTargets[index];

                if (renderTarget != null)
                {
                    _renderTargets[index] = null;
                    _ = renderTarget->Release();
                }
            }

            var commandAllocator = _commandAllocator;

            if (commandAllocator != null)
            {
                _commandAllocator = null;
                _ = commandAllocator->Release();
            }

            var bundleAllocator = _bundleAllocator;

            if (bundleAllocator != null)
            {
                _bundleAllocator = null;
                _ = bundleAllocator->Release();
            }

            var commandQueue = _commandQueue;

            if (commandQueue != null)
            {
                _commandQueue = null;
                _             = commandQueue->Release();
            }

            var rootSignature = _rootSignature;

            if (rootSignature != null)
            {
                _rootSignature = null;
                _ = rootSignature->Release();
            }

            var rtvHeap = _rtvHeap;

            if (rtvHeap != null)
            {
                _rtvHeap = null;
                _        = rtvHeap->Release();
            }

            var pipelineState = _pipelineState;

            if (pipelineState != null)
            {
                _pipelineState = null;
                _ = pipelineState->Release();
            }

            var commandList = _commandList;

            if (commandList != null)
            {
                _commandList = null;
                _            = commandList->Release();
            }

            var bundle = _bundle;

            if (bundle != null)
            {
                _bundle = null;
                _       = bundle->Release();
            }

            var vertexBuffer = _vertexBuffer;

            if (vertexBuffer != null)
            {
                _vertexBuffer = null;
                _             = vertexBuffer->Release();
            }

            var fence = _fence;

            if (fence != null)
            {
                _fence = null;
                _      = fence->Release();
            }

            base.Dispose(isDisposing);
        }
Exemple #11
0
        protected override void DestroyDeviceDependentResources()
        {
            DestroyAssets();

            DestroyGraphicsCommandLists();
            DestroyPipelineState();
            DestroyRootSignature();

            DestroyFenceEvent();
            DestroyFence();

            DestroyCommandAllocators();

            DestroyDescriptorHeaps();

            DestroyCommandQueue();
            DestroyD3DDevice();
            DestroyDxgiAdapter();
            DestroyDxgiFactory();

            void DestroyCommandAllocators()
            {
                for (var i = 0; i < _commandAllocators.Length; i++)
                {
                    var commandAllocator = _commandAllocators[i];

                    if (commandAllocator != null)
                    {
                        _commandAllocators[i] = null;
                        _ = commandAllocator->Release();
                    }
                }
            }

            void DestroyCommandQueue()
            {
                var commandQueue = _commandQueue;

                if (commandQueue != null)
                {
                    _commandQueue = null;
                    _             = commandQueue->Release();
                }
            }

            void DestroyD3DDevice()
            {
                var d3dDevice = _d3dDevice;

                if (d3dDevice != null)
                {
                    _d3dDevice = null;
                    _          = d3dDevice->Release();
                }
            }

            void DestroyDxgiAdapter()
            {
                var dxgiAdapter = _dxgiAdapter;

                if (dxgiAdapter != null)
                {
                    _dxgiAdapter = null;
                    _            = dxgiAdapter->Release();
                }
            }

            void DestroyDxgiFactory()
            {
                var dxgiFactory = _dxgiFactory;

                if (dxgiFactory != null)
                {
                    _dxgiFactory = null;
                    _            = dxgiFactory->Release();
                }
            }

            void DestroyFence()
            {
                var fence = _fence;

                if (fence != null)
                {
                    _fence = null;
                    _      = fence->Release();
                }
            }

            void DestroyFenceEvent()
            {
                var fenceEvent = _fenceEvent;

                if (fenceEvent != IntPtr.Zero)
                {
                    _fenceEvent = IntPtr.Zero;
                    _           = CloseHandle(_fenceEvent);
                }
            }

            void DestroyGraphicsCommandLists()
            {
                for (var i = 0; i < _graphicsCommandLists.Length; i++)
                {
                    var graphicsCommandList = _graphicsCommandLists[i];

                    if (graphicsCommandList != null)
                    {
                        _graphicsCommandLists[i] = null;
                        _ = graphicsCommandList->Release();
                    }
                }
            }

            void DestroyPipelineState()
            {
                var pipelineState = _pipelineState;

                if (pipelineState != null)
                {
                    _pipelineState = null;
                    _ = pipelineState->Release();
                }
            }

            void DestroyRootSignature()
            {
                var rootSignature = _rootSignature;

                if (rootSignature != null)
                {
                    _rootSignature = null;
                    _ = rootSignature->Release();
                }
            }
        }
        public GraphicsPipelineStateDesc
        (
            ID3D12RootSignature *pRootSignature = null,
            ShaderBytecode?vS             = null,
            ShaderBytecode?pS             = null,
            ShaderBytecode?dS             = null,
            ShaderBytecode?hS             = null,
            ShaderBytecode?gS             = null,
            StreamOutputDesc?streamOutput = null,
            BlendDesc?blendState          = null,
            uint?sampleMask = null,
            RasterizerDesc?rasterizerState              = null,
            DepthStencilDesc?depthStencilState          = null,
            InputLayoutDesc?inputLayout                 = null,
            IndexBufferStripCutValue?iBStripCutValue    = null,
            PrimitiveTopologyType?primitiveTopologyType = null,
            uint?numRenderTargets               = null,
            Silk.NET.DXGI.Format?dSVFormat      = null,
            Silk.NET.DXGI.SampleDesc?sampleDesc = null,
            uint?nodeMask = null,
            CachedPipelineState?cachedPSO = null,
            PipelineStateFlags?flags      = null
        ) : this()
        {
            if (pRootSignature is not null)
            {
                PRootSignature = pRootSignature;
            }

            if (vS is not null)
            {
                VS = vS.Value;
            }

            if (pS is not null)
            {
                PS = pS.Value;
            }

            if (dS is not null)
            {
                DS = dS.Value;
            }

            if (hS is not null)
            {
                HS = hS.Value;
            }

            if (gS is not null)
            {
                GS = gS.Value;
            }

            if (streamOutput is not null)
            {
                StreamOutput = streamOutput.Value;
            }

            if (blendState is not null)
            {
                BlendState = blendState.Value;
            }

            if (sampleMask is not null)
            {
                SampleMask = sampleMask.Value;
            }

            if (rasterizerState is not null)
            {
                RasterizerState = rasterizerState.Value;
            }

            if (depthStencilState is not null)
            {
                DepthStencilState = depthStencilState.Value;
            }

            if (inputLayout is not null)
            {
                InputLayout = inputLayout.Value;
            }

            if (iBStripCutValue is not null)
            {
                IBStripCutValue = iBStripCutValue.Value;
            }

            if (primitiveTopologyType is not null)
            {
                PrimitiveTopologyType = primitiveTopologyType.Value;
            }

            if (numRenderTargets is not null)
            {
                NumRenderTargets = numRenderTargets.Value;
            }

            if (dSVFormat is not null)
            {
                DSVFormat = dSVFormat.Value;
            }

            if (sampleDesc is not null)
            {
                SampleDesc = sampleDesc.Value;
            }

            if (nodeMask is not null)
            {
                NodeMask = nodeMask.Value;
            }

            if (cachedPSO is not null)
            {
                CachedPSO = cachedPSO.Value;
            }

            if (flags is not null)
            {
                Flags = flags.Value;
            }
        }
Exemple #13
0
 public void RootSignatureCb(ID3D12RootSignature *param0)
 {
     ((delegate * unmanaged <ID3DX12PipelineParserCallbacks *, ID3D12RootSignature *, void>)(lpVtbl[2]))((ID3DX12PipelineParserCallbacks *)Unsafe.AsPointer(ref this), param0);
 }
 public void SetComputeRootSignature(ID3D12RootSignature *pRootSignature)
 {
     ((delegate * unmanaged[Stdcall] < ID3D12GraphicsCommandList *, ID3D12RootSignature *, void >)(lpVtbl[29]))((ID3D12GraphicsCommandList *)Unsafe.AsPointer(ref this), pRootSignature);
 }
Exemple #15
0
 public int CreateCommandSignature([NativeTypeName("const D3D12_COMMAND_SIGNATURE_DESC *")] D3D12_COMMAND_SIGNATURE_DESC *pDesc, [NativeTypeName("ID3D12RootSignature *")] ID3D12RootSignature *pRootSignature, [NativeTypeName("const IID &")] Guid *riid, [NativeTypeName("void **")] void **ppvCommandSignature)
 {
     return(((delegate * unmanaged <ID3D12Device *, D3D12_COMMAND_SIGNATURE_DESC *, ID3D12RootSignature *, Guid *, void **, int>)(lpVtbl[41]))((ID3D12Device *)Unsafe.AsPointer(ref this), pDesc, pRootSignature, riid, ppvCommandSignature));
 }
Exemple #16
0
        protected override void CreateDeviceDependentResources()
        {
            _dxgiFactory  = CreateDxgiFactory();
            _dxgiAdapter  = GetDxgiAdapter();
            _d3dDevice    = CreateD3DDevice();
            _commandQueue = CreateCommandQueue();

            CreateDescriptorHeaps();

            for (int i = 0; i < FrameCount; i++)
            {
                _commandAllocators[i] = CreateCommandAllocator();
            }

            _fence       = CreateFence();
            _fenceValues = CreateFenceValues();
            _fenceEvent  = CreateFenceEvent();

            _rootSignature        = CreateRootSignature();
            _pipelineState        = CreatePipelineState();
            _graphicsCommandLists = CreateGraphicsCommandLists();

            ThrowIfFailed(nameof(ID3D12CommandAllocator.Reset), CommandAllocator->Reset());
            ThrowIfFailed(nameof(ID3D12GraphicsCommandList.Reset), GraphicsCommandList->Reset(CommandAllocator, PipelineState));

            CreateAssets();

            ID3D12CommandAllocator *CreateCommandAllocator()
            {
                ID3D12CommandAllocator *commandAllocator;

                var iid = IID_ID3D12CommandAllocator;

                ThrowIfFailed(nameof(ID3D12Device.CreateCommandAllocator), D3DDevice->CreateCommandAllocator(D3D12_COMMAND_LIST_TYPE_DIRECT, &iid, (void **)&commandAllocator));

                return(commandAllocator);
            }

            ID3D12CommandQueue *CreateCommandQueue()
            {
                var queueDesc = new D3D12_COMMAND_QUEUE_DESC();

                ID3D12CommandQueue *commandQueue;

                var iid = IID_ID3D12CommandQueue;

                ThrowIfFailed(nameof(ID3D12Device.CreateCommandQueue), D3DDevice->CreateCommandQueue(&queueDesc, &iid, (void **)&commandQueue));

                return(commandQueue);
            }

            ID3D12Device *CreateD3DDevice()
            {
                ID3D12Device *d3dDevice;

                var iid = IID_ID3D12Device;

                ThrowIfFailed(nameof(D3D12CreateDevice), D3D12CreateDevice((IUnknown *)_dxgiAdapter, D3D_FEATURE_LEVEL_11_0, &iid, (void **)&d3dDevice));

                return(d3dDevice);
            }

            IDXGIFactory4 *CreateDxgiFactory()
            {
                var dxgiFactoryFlags = TryEnableDebugLayer() ? DXGI_CREATE_FACTORY_DEBUG : 0u;

                IDXGIFactory4 *dxgiFactory;

                var iid = IID_IDXGIFactory4;

                ThrowIfFailed(nameof(CreateDXGIFactory2), CreateDXGIFactory2(dxgiFactoryFlags, &iid, (void **)&dxgiFactory));

                return(dxgiFactory);
            }

            ID3D12Fence *CreateFence()
            {
                ID3D12Fence *fence;

                var iid = IID_ID3D12Fence;

                ThrowIfFailed(nameof(ID3D12Device.CreateFence), D3DDevice->CreateFence(InitialValue: 0, D3D12_FENCE_FLAG_NONE, &iid, (void **)&fence));

                return(fence);
            }

            IntPtr CreateFenceEvent()
            {
                var fenceEvent = CreateEventW(lpEventAttributes: null, bManualReset: FALSE, bInitialState: FALSE, lpName: null);

                if (fenceEvent == IntPtr.Zero)
                {
                    var hr = Marshal.GetHRForLastWin32Error();
                    Marshal.ThrowExceptionForHR(hr);
                }

                return(fenceEvent);
            }

            ulong[] CreateFenceValues()
            {
                var fenceValues = new ulong[FrameCount];

                fenceValues[0] = 1;
                return(fenceValues);
            }

            ID3D12GraphicsCommandList *[] CreateGraphicsCommandLists()
            {
                var graphicsCommandLists = new ID3D12GraphicsCommandList *[FrameCount];

                for (uint i = 0u; i < FrameCount; i++)
                {
                    ID3D12GraphicsCommandList *graphicsCommandList;

                    var iid = IID_ID3D12GraphicsCommandList;
                    ThrowIfFailed(nameof(ID3D12Device.CreateCommandList), D3DDevice->CreateCommandList(nodeMask: 0, D3D12_COMMAND_LIST_TYPE_DIRECT, _commandAllocators[i], PipelineState, &iid, (void **)&graphicsCommandList));

                    ThrowIfFailed(nameof(ID3D12GraphicsCommandList.Close), graphicsCommandList->Close());
                    graphicsCommandLists[i] = graphicsCommandList;
                }

                return(graphicsCommandLists);
            }

            IDXGIAdapter1 *GetDxgiAdapter()
            {
                if (UseWarpDevice)
                {
                    IDXGIAdapter1 *adapter;

                    var iid = IID_IDXGIAdapter;
                    ThrowIfFailed(nameof(IDXGIFactory4.EnumWarpAdapter), _dxgiFactory->EnumWarpAdapter(&iid, (void **)&adapter));

                    return(adapter);
                }
                else
                {
                    return(GetHardwareAdapter((IDXGIFactory1 *)_dxgiFactory));
                }
            }

            bool TryEnableDebugLayer()
            {
#if DEBUG
                // Enable the debug layer (requires the Graphics Tools "optional feature").
                // NOTE: Enabling the debug layer after device creation will invalidate the active device.

                using ComPtr <ID3D12Debug> debugController = null;
                var iid = IID_ID3D12Debug;

                if (SUCCEEDED(D3D12GetDebugInterface(&iid, (void **)&debugController)))
                {
                    debugController.Get()->EnableDebugLayer();
                    return(true);
                }
#endif

                return(false);
            }
        }
        protected override void CreateDeviceDependentResources()
        {
            _dxgiFactory = CreateDxgiFactory();
            _dxgiAdapter = GetDxgiAdapter();
            _d3dDevice   = CreateD3DDevice();
            StartInfoPump();
            _commandQueue = CreateCommandQueue();

            CreateDescriptorHeaps();

            for (int i = 0; i < FrameCount; i++)
            {
                _commandAllocators[i] = CreateCommandAllocator();
            }

            _fence       = CreateFence();
            _fenceValues = CreateFenceValues();
            _fenceEvent  = CreateFenceEvent();

            _rootSignature        = CreateRootSignature();
            _pipelineState        = CreatePipelineState();
            _graphicsCommandLists = CreateGraphicsCommandLists();

            SilkMarshal.ThrowHResult(CommandAllocator->Reset());
            SilkMarshal.ThrowHResult(GraphicsCommandList->Reset(CommandAllocator, PipelineState));

            CreateAssets();

            ID3D12CommandAllocator *CreateCommandAllocator()
            {
                ID3D12CommandAllocator *commandAllocator;

                var iid = ID3D12CommandAllocator.Guid;

                SilkMarshal.ThrowHResult
                (
                    D3DDevice->CreateCommandAllocator
                        (CommandListType.CommandListTypeDirect, &iid, (void **)&commandAllocator)
                );

                return(commandAllocator);
            }

            ID3D12CommandQueue *CreateCommandQueue()
            {
                var queueDesc = new CommandQueueDesc();

                ID3D12CommandQueue *commandQueue;

                var iid = ID3D12CommandQueue.Guid;

                SilkMarshal.ThrowHResult(D3DDevice->CreateCommandQueue(&queueDesc, &iid, (void **)&commandQueue));

                return(commandQueue);
            }

            ID3D12Device *CreateD3DDevice()
            {
                ID3D12Device *d3dDevice;

                var iid = ID3D12Device.Guid;

                SilkMarshal.ThrowHResult
                (
                    D3D12.CreateDevice
                        ((IUnknown *)_dxgiAdapter, D3DFeatureLevel.D3DFeatureLevel110, &iid, (void **)&d3dDevice)
                );

                return(d3dDevice);
            }

            IDXGIFactory4 *CreateDxgiFactory()
            {
                var dxgiFactoryFlags = TryEnableDebugLayer() ? 0x01 : 0u;

                IDXGIFactory4 *dxgiFactory;

                var iid = IDXGIFactory4.Guid;

                SilkMarshal.ThrowHResult(Dxgi.CreateDXGIFactory2(dxgiFactoryFlags, &iid, (void **)&dxgiFactory));

                return(dxgiFactory);
            }

            ID3D12Fence *CreateFence()
            {
                ID3D12Fence *fence;

                var iid = ID3D12Fence.Guid;

                SilkMarshal.ThrowHResult
                    (D3DDevice->CreateFence(InitialValue: 0, FenceFlags.FenceFlagNone, &iid, (void **)&fence));

                return(fence);
            }

            IntPtr CreateFenceEvent()
            {
                var fenceEvent = SilkMarshal.CreateWindowsEvent(null, false, false, null);

                if (fenceEvent == IntPtr.Zero)
                {
                    var hr = Marshal.GetHRForLastWin32Error();
                    Marshal.ThrowExceptionForHR(hr);
                }

                return(fenceEvent);
            }

            ulong[] CreateFenceValues()
            {
                var fenceValues = new ulong[FrameCount];

                fenceValues[0] = 1;
                return(fenceValues);
            }

            ID3D12GraphicsCommandList *[] CreateGraphicsCommandLists()
            {
                var graphicsCommandLists = new ID3D12GraphicsCommandList *[FrameCount];

                for (uint i = 0u; i < FrameCount; i++)
                {
                    ID3D12GraphicsCommandList *graphicsCommandList;

                    var iid = ID3D12GraphicsCommandList.Guid;
                    SilkMarshal.ThrowHResult
                    (
                        D3DDevice->CreateCommandList
                        (
                            nodeMask: 0, CommandListType.CommandListTypeDirect, _commandAllocators[i], PipelineState,
                            &iid, (void **)&graphicsCommandList
                        )
                    );

                    SilkMarshal.ThrowHResult(graphicsCommandList->Close());
                    graphicsCommandLists[i] = graphicsCommandList;
                }

                return(graphicsCommandLists);
            }

            IDXGIAdapter1 *GetDxgiAdapter()
            {
                if (UseWarpDevice)
                {
                    IDXGIAdapter1 *adapter;

                    var iid = IDXGIAdapter.Guid;
                    SilkMarshal.ThrowHResult(_dxgiFactory->EnumWarpAdapter(&iid, (void **)&adapter));

                    return(adapter);
                }
                else
                {
                    return(GetHardwareAdapter((IDXGIFactory1 *)_dxgiFactory));
                }
            }

            bool TryEnableDebugLayer()
            {
#if DEBUG
                // Enable the debug layer (requires the Graphics Tools "optional feature").
                // NOTE: Enabling the debug layer after device creation will invalidate the active device.

                using ComPtr <ID3D12Debug> debugController = null;
                var iid = ID3D12Debug.Guid;
                var hr  = D3D12.GetDebugInterface(&iid, (void **)&debugController);

                if (HResult.IndicatesSuccess(hr))
                {
                    debugController.Get().EnableDebugLayer();
                    Log.LogInformation("Debug layer enabled");
                    return(_debug = true);
                }
                else
                {
                    Log.LogWarning
                    (
                        Marshal.GetExceptionForHR(hr),
                        $"Failed to enable debug layer, failed with result {hr} (0x{hr:x8})"
                    );
                }
#endif

                return(false);
            }

            void StartInfoPump()
            {
#if DEBUG
                if (!_debug)
                {
                    Log.LogInformation("Skipped creation of info pump due to the debug layer not being enabled.");
                    return;
                }

                var iid = ID3D12InfoQueue.Guid;
                fixed(ID3D12InfoQueue ** @out = &_infoQueue)
                {
                    SilkMarshal.ThrowHResult(D3DDevice->QueryInterface(&iid, (void **)@out));
                }

                _infoPumpCancellationToken = new();
                _infoPump = Task.Run
                            (
                    () =>
                {
                    Log.LogInformation("Info queue pump started");
                    while (!_infoPumpCancellationToken.Token.IsCancellationRequested)
                    {
                        var numMessages = _infoQueue->GetNumStoredMessages();
                        if (numMessages == 0)
                        {
                            continue;
                        }

                        for (var i = 0ul; i < numMessages; i++)
                        {
                            nuint msgByteLength;
                            SilkMarshal.ThrowHResult(_infoQueue->GetMessageA(i, null, &msgByteLength));
                            using var memory = GlobalMemory.Allocate((int)msgByteLength);
                            SilkMarshal.ThrowHResult
                            (
                                _infoQueue->GetMessageA(i, memory.AsPtr <Message>(), &msgByteLength)
                            );

                            ref var msg   = ref memory.AsRef <Message>();
                            var descBytes = new Span <byte>(msg.PDescription, (int)msg.DescriptionByteLength);
                            var desc      = Encoding.UTF8.GetString(descBytes[..^ 1]);
                            var eid       = new EventId((int)msg.ID, msg.ID.ToString()["MessageID".Length..]);