Exemple #1
0
        public override void Begin()
        {
            if (_commandBufferBegun)
            {
                throw new VeldridException(
                          "CommandList must be in its initial state, or End() must have been called, for Begin() to be valid to call.");
            }
            if (_commandBufferEnded)
            {
                _commandBufferEnded = false;
                _cb = GetNextCommandBuffer();
                if (_currentStagingInfo != null)
                {
                    RecycleStagingInfo(_currentStagingInfo);
                }
            }

            _currentStagingInfo = GetStagingResourceInfo();

            VkCommandBufferBeginInfo beginInfo = VkCommandBufferBeginInfo.New();

            beginInfo.flags = VkCommandBufferUsageFlags.OneTimeSubmit;
            vkBeginCommandBuffer(_cb, ref beginInfo);
            _commandBufferBegun = true;

            ClearCachedState();
            _currentFramebuffer      = null;
            _currentGraphicsPipeline = null;
            Util.ClearArray(_currentGraphicsResourceSets);
            Util.ClearArray(_scissorRects);

            _currentComputePipeline = null;
            Util.ClearArray(_currentComputeResourceSets);
        }
Exemple #2
0
 public override void SetPipeline(Pipeline pipeline)
 {
     if (_currentPipeline != pipeline)
     {
         VkPipeline vkPipeline = Util.AssertSubtype <Pipeline, VkPipeline>(pipeline);
         Util.EnsureArraySize(ref _currentResourceSets, vkPipeline.ResourceSetCount);
         Util.ClearArray(_currentResourceSets); // TODO: Cache this information per-pipeline rather than wiping it.
         Util.EnsureArraySize(ref _resourceSetsChanged, vkPipeline.ResourceSetCount);
         vkCmdBindPipeline(_cb, VkPipelineBindPoint.Graphics, vkPipeline.DevicePipeline);
         _currentPipeline = vkPipeline;
     }
 }
Exemple #3
0
 protected override void SetPipelineCore(Pipeline pipeline)
 {
     if (!pipeline.IsComputePipeline && _currentGraphicsPipeline != pipeline)
     {
         VkPipeline vkPipeline = Util.AssertSubtype <Pipeline, VkPipeline>(pipeline);
         Util.EnsureArrayMinimumSize(ref _currentGraphicsResourceSets, vkPipeline.ResourceSetCount);
         Util.ClearArray(_currentGraphicsResourceSets);
         Util.EnsureArrayMinimumSize(ref _graphicsResourceSetsChanged, vkPipeline.ResourceSetCount);
         vkCmdBindPipeline(_cb, VkPipelineBindPoint.Graphics, vkPipeline.DevicePipeline);
         _currentGraphicsPipeline = vkPipeline;
     }
     else if (pipeline.IsComputePipeline && _currentComputePipeline != pipeline)
     {
         VkPipeline vkPipeline = Util.AssertSubtype <Pipeline, VkPipeline>(pipeline);
         Util.EnsureArrayMinimumSize(ref _currentComputeResourceSets, vkPipeline.ResourceSetCount);
         Util.ClearArray(_currentComputeResourceSets);
         Util.EnsureArrayMinimumSize(ref _computeResourceSetsChanged, vkPipeline.ResourceSetCount);
         vkCmdBindPipeline(_cb, VkPipelineBindPoint.Compute, vkPipeline.DevicePipeline);
         _currentComputePipeline = vkPipeline;
     }
 }
Exemple #4
0
        public override void Begin()
        {
            if (_commandBufferBegun)
            {
                throw new VeldridException(
                          "CommandList must be in its initial state, or End() must have been called, for Begin() to be valid to call.");
            }
            if (_commandBufferEnded)
            {
                _commandBufferEnded = false;
                vkResetCommandPool(_gd.Device, _pool, VkCommandPoolResetFlags.None);
            }

            VkCommandBufferBeginInfo beginInfo = VkCommandBufferBeginInfo.New();

            vkBeginCommandBuffer(_cb, ref beginInfo);
            _commandBufferBegun = true;

            ClearCachedState();
            _currentFramebuffer      = null;
            _currentGraphicsPipeline = null;
            Util.ClearArray(_currentGraphicsResourceSets);
            Util.ClearArray(_scissorRects);

            _currentComputePipeline = null;
            Util.ClearArray(_currentComputeResourceSets);

            _referencedResources.Clear();

            foreach (VkBuffer vkBuffer in _usedStagingBuffers)
            {
                _availableStagingBuffers.Add(vkBuffer);
            }

            _usedStagingBuffers.Clear();
        }