Ejemplo n.º 1
0
        /// <inheritdoc/>
        protected internal override void OnDestroyed()
        {
            Ready = false;

            GraphicsDevice.RegisterBufferMemoryUsage(-SizeInBytes);

            if (NativeBufferView != VkBufferView.Null)
            {
                GraphicsDevice.Collect(NativeBufferView);
                NativeBufferView = VkBufferView.Null;
            }

            if (NativeBuffer != VkBuffer.Null)
            {
                GraphicsDevice.Collect(NativeBuffer);
                NativeBuffer = VkBuffer.Null;
            }

            if (NativeMemory != VkDeviceMemory.Null)
            {
                if (NativeMemoryOffset.HasValue)
                {
                    VulkanMemoryPool.Free(this, NativeMemoryOffset.Value);
                }
                else
                {
                    GraphicsDevice.Collect(NativeMemory);
                }
                NativeMemory = VkDeviceMemory.Null;
            }

            base.OnDestroyed();
        }
Ejemplo n.º 2
0
        public unsafe void DestroyNow()
        {
            GraphicsDevice.RegisterBufferMemoryUsage(-SizeInBytes);

            if (NativeBufferView != VkBufferView.Null)
            {
                vkDestroyBufferView(GraphicsDevice.NativeDevice, NativeBufferView, null);
                NativeBufferView = VkBufferView.Null;
            }

            if (NativeBuffer != VkBuffer.Null)
            {
                vkDestroyBuffer(GraphicsDevice.NativeDevice, NativeBuffer, null);
                NativeBuffer = VkBuffer.Null;
            }

            if (NativeMemory != VkDeviceMemory.Null)
            {
                if (NativeMemoryOffset.HasValue)
                {
                    VulkanMemoryPool.Free(this, NativeMemoryOffset.Value);
                }
                else
                {
                    vkFreeMemory(GraphicsDevice.NativeDevice, NativeMemory, null);
                }
                NativeMemory = VkDeviceMemory.Null;
            }

            base.OnDestroyed();
        }