private void RecycleCommandListResources(CompiledCommandList commandList, long fenceValue) { // Set fence on staging textures foreach (var stagingResource in commandList.StagingResources) { stagingResource.StagingFenceValue = fenceValue; } StagingResourceLists.Release(commandList.StagingResources); commandList.StagingResources.Clear(); // Recycle resources foreach (var heap in commandList.SrvHeaps) { SrvHeaps.RecycleObject(fenceValue, heap); } commandList.SrvHeaps.Clear(); DescriptorHeapLists.Release(commandList.SrvHeaps); foreach (var heap in commandList.SamplerHeaps) { SamplerHeaps.RecycleObject(fenceValue, heap); } commandList.SamplerHeaps.Clear(); DescriptorHeapLists.Release(commandList.SamplerHeaps); commandList.Builder.NativeCommandLists.Enqueue(commandList.NativeCommandList); CommandAllocators.RecycleObject(fenceValue, commandList.NativeCommandAllocator); }
internal long ExecuteCommandListInternal(CompiledCommandList commandList) { var fenceValue = NextFenceValue++; // Submit and signal fence NativeCommandQueue.ExecuteCommandList(commandList.NativeCommandList); NativeCommandQueue.Signal(nativeFence, fenceValue); // Recycle resources RecycleCommandListResources(commandList, fenceValue); return(fenceValue); }
internal unsafe long ExecuteCommandListInternal(CompiledCommandList commandList) { //if (nativeUploadBuffer != SharpVulkan.Buffer.Null) //{ // NativeDevice.UnmapMemory(nativeUploadBufferMemory); // TemporaryResources.Enqueue(new BufferInfo(NextFenceValue, nativeUploadBuffer, nativeUploadBufferMemory)); // nativeUploadBuffer = SharpVulkan.Buffer.Null; // nativeUploadBufferMemory = DeviceMemory.Null; //} var fenceValue = NextFenceValue++; // Create new fence var fenceCreateInfo = new FenceCreateInfo { StructureType = StructureType.FenceCreateInfo }; var fence = nativeDevice.CreateFence(ref fenceCreateInfo); nativeFences.Enqueue(new KeyValuePair <long, Fence>(fenceValue, fence)); // Collect resources RecycleCommandListResources(commandList, fenceValue); // Submit commands var nativeCommandBufferCopy = commandList.NativeCommandBuffer; var pipelineStageFlags = PipelineStageFlags.BottomOfPipe; var presentSemaphoreCopy = presentSemaphore; var submitInfo = new SubmitInfo { StructureType = StructureType.SubmitInfo, CommandBufferCount = 1, CommandBuffers = new IntPtr(&nativeCommandBufferCopy), WaitSemaphoreCount = presentSemaphore != Semaphore.Null ? 1U : 0U, WaitSemaphores = new IntPtr(&presentSemaphoreCopy), WaitDstStageMask = new IntPtr(&pipelineStageFlags), }; NativeCommandQueue.Submit(1, &submitInfo, fence); presentSemaphore = Semaphore.Null; nativeResourceCollector.Release(); graphicsResourceLinkCollector.Release(); return(fenceValue); }
/// <summary> /// Closes the command list for recording and returns an executable token. /// </summary> /// <returns>The executable command list.</returns> public CompiledCommandList Close() { currentCommandList.NativeCommandList.Close(); // Staging resources not updated anymore foreach (var stagingResource in currentCommandList.StagingResources) { stagingResource.StagingBuilder = null; } // Recycle heaps ResetSrvHeap(false); ResetSamplerHeap(false); var result = currentCommandList; currentCommandList = default(CompiledCommandList); return(result); }
private void RecycleCommandListResources(CompiledCommandList commandList, long fenceValue) { // Set fence on staging textures foreach (var stagingResource in commandList.StagingResources) { stagingResource.StagingFenceValue = fenceValue; } StagingResourceLists.Release(commandList.StagingResources); commandList.StagingResources.Clear(); // Recycle all resources foreach (var descriptorPool in commandList.DescriptorPools) { DescriptorPools.RecycleObject(fenceValue, descriptorPool); } DescriptorPoolLists.Release(commandList.DescriptorPools); commandList.DescriptorPools.Clear(); commandList.Builder.CommandBufferPool.RecycleObject(fenceValue, commandList.NativeCommandBuffer); }
/// <summary> /// Executes a deferred command list. /// </summary> /// <param name="commandList">The deferred command list.</param> public void ExecuteCommandList(CompiledCommandList commandList) { throw new NotImplementedException(); }
/// <summary> /// Executes a deferred command list. /// </summary> /// <param name="commandList">The deferred command list.</param> public void ExecuteCommandList(CompiledCommandList commandList) { ExecuteCommandListInternal(commandList); }
/// <summary> /// Executes multiple deferred command lists. /// </summary> /// <param name="commandLists">The deferred command lists.</param> public void ExecuteCommandLists(int count, CompiledCommandList[] commandLists) { throw new NotImplementedException(); }