Ejemplo n.º 1
0
        public void CreateCommandPool()
        {
            var createInfo = new CommandPoolCreateInfo(0);

            using (Device.CreateCommandPool(createInfo)) { }
            using (Device.CreateCommandPool(createInfo, CustomAllocator)) { }
        }
Ejemplo n.º 2
0
        public unsafe CommandBufferPool(Vk api, Device device, Queue queue, object queueLock, uint queueFamilyIndex, bool isLight = false)
        {
            _api       = api;
            _device    = device;
            _queue     = queue;
            _queueLock = queueLock;
            _owner     = Thread.CurrentThread;

            var commandPoolCreateInfo = new CommandPoolCreateInfo()
            {
                SType            = StructureType.CommandPoolCreateInfo,
                QueueFamilyIndex = queueFamilyIndex,
                Flags            = CommandPoolCreateFlags.CommandPoolCreateTransientBit |
                                   CommandPoolCreateFlags.CommandPoolCreateResetCommandBufferBit
            };

            api.CreateCommandPool(device, commandPoolCreateInfo, null, out _pool).ThrowOnError();

            // We need at least 2 command buffers to get texture data in some cases.
            _totalCommandBuffers     = isLight ? 2 : MaxCommandBuffers;
            _totalCommandBuffersMask = _totalCommandBuffers - 1;

            _commandBuffers = new ReservedCommandBuffer[_totalCommandBuffers];

            _queuedIndexes    = new int[_totalCommandBuffers];
            _queuedIndexesPtr = 0;
            _queuedCount      = 0;

            for (int i = 0; i < _totalCommandBuffers; i++)
            {
                _commandBuffers[i].Initialize(api, device, _pool);
                WaitAndDecrementRef(i);
            }
        }
Ejemplo n.º 3
0
            void InitCommandBuffers()
            {
                CommandPoolCreateInfo poolCreateInfo = new CommandPoolCreateInfo
                {
                    QueueFamilyIndex = 0,
                    Flags            = CommandPoolCreateFlags.ResetCommandBuffer,
                };

                mainCmdPool = device.CreateCommandPool(poolCreateInfo);

                CommandBufferAllocateInfo bufferAllocInfo = new CommandBufferAllocateInfo
                {
                    CommandBufferCount = 1,
                    CommandPool        = mainCmdPool,
                    Level = CommandBufferLevel.Primary,
                };

                mainCmd = device.AllocateCommandBuffers(bufferAllocInfo)[0];

                cleanupStack.Push(() => {
                    device.FreeCommandBuffer(mainCmdPool, mainCmd);
                    mainCmd = null;
                    device.DestroyCommandPool(mainCmdPool);
                    mainCmdPool = null;
                });
            }
Ejemplo n.º 4
0
        public unsafe CommandBufferPool(Vk api, Device device, Queue queue, uint queueFamilyIndex, bool isLight = false)
        {
            _api    = api;
            _device = device;
            _queue  = queue;
            _owner  = Thread.CurrentThread;

            var commandPoolCreateInfo = new CommandPoolCreateInfo()
            {
                SType            = StructureType.CommandPoolCreateInfo,
                QueueFamilyIndex = queueFamilyIndex,
                Flags            = CommandPoolCreateFlags.CommandPoolCreateTransientBit |
                                   CommandPoolCreateFlags.CommandPoolCreateResetCommandBufferBit
            };

            api.CreateCommandPool(device, commandPoolCreateInfo, null, out _pool).ThrowOnError();

            _totalCommandBuffers     = isLight ? 1 : MaxCommandBuffers;
            _totalCommandBuffersMask = _totalCommandBuffers - 1;

            _commandBuffers = new ReservedCommandBuffer[_totalCommandBuffers];

            for (int i = 0; i < _totalCommandBuffers; i++)
            {
                _commandBuffers[i].Initialize(api, device, _pool);
            }
        }
Ejemplo n.º 5
0
        protected CommandPool CreateCommandPool(uint queueFamily)
        {
            var commandPoolCreateInfo = new CommandPoolCreateInfo(queueFamily);

            commandPoolCreateInfo.Flags = CommandPoolCreateFlags.ResetCommandBuffer;
            return(device.CreateCommandPool(commandPoolCreateInfo));
        }
Ejemplo n.º 6
0
        protected virtual void CreateCommandBuffer()
        {
            // Command pool
            var commandPoolCreateInfo = new CommandPoolCreateInfo
            {
                StructureType    = StructureType.CommandPoolCreateInfo,
                QueueFamilyIndex = 0,
                Flags            = CommandPoolCreateFlags.ResetCommandBuffer
            };

            commandPool = device.CreateCommandPool(ref commandPoolCreateInfo);

            // Command buffer
            var commandBufferAllocationInfo = new CommandBufferAllocateInfo
            {
                StructureType      = StructureType.CommandBufferAllocateInfo,
                Level              = CommandBufferLevel.Primary,
                CommandPool        = commandPool,
                CommandBufferCount = 1
            };
            CommandBuffer commandBuffer;

            device.AllocateCommandBuffers(ref commandBufferAllocationInfo, &commandBuffer);
            this.commandBuffer = commandBuffer;
        }
Ejemplo n.º 7
0
        public bool SetQueueName(string qName,
                                 int famIndex, int qIndex, CommandPoolCreateFlags poolFlags)
        {
            if (mQueueNames.ContainsKey(qName))
            {
                Misc.SafeInvoke(eErrorSpam, "Queue name already in use: " + qName + " in SetQueueName()");
                return(false);
            }

            int physIndex = mPhysicals.IndexOf(mLogical.Parent);

            if (famIndex < 0 || famIndex >= mDeviceQueueFamProps[physIndex].Length)
            {
                Misc.SafeInvoke(eErrorSpam, "Bad queue family index: " + famIndex + " in SetQueueName()");
                return(false);
            }

            if (qIndex < 0 || qIndex >= mQueueLimits[physIndex][qIndex])
            {
                Misc.SafeInvoke(eErrorSpam, "Bad queue index: " + qIndex + " in SetQueueName()");
                return(false);
            }

            Queue q = mLogical.GetQueue(famIndex, qIndex);

            mQueueNames.Add(qName, q);

            //make a command pool for this queue
            CommandPoolCreateInfo cpci = new CommandPoolCreateInfo(
                famIndex, poolFlags);

            mCommandPools.Add(qName, mLogical.CreateCommandPool(cpci));

            return(true);
        }
Ejemplo n.º 8
0
        CommandBuffer [] CreateCommandBuffers(Image [] images, Framebuffer [] framebuffers, RenderPass renderPass, SurfaceCapabilitiesKhr surfaceCapabilities)
        {
            var createPoolInfo = new CommandPoolCreateInfo {
                Flags = CommandPoolCreateFlags.ResetCommandBuffer
            };
            var commandPool = device.CreateCommandPool(createPoolInfo);
            var commandBufferAllocateInfo = new CommandBufferAllocateInfo {
                Level              = CommandBufferLevel.Primary,
                CommandPool        = commandPool,
                CommandBufferCount = (uint)images.Length
            };
            var buffers = device.AllocateCommandBuffers(commandBufferAllocateInfo);

            for (int i = 0; i < images.Length; i++)
            {
                var commandBufferBeginInfo = new CommandBufferBeginInfo();
                buffers [i].Begin(commandBufferBeginInfo);
                var renderPassBeginInfo = new RenderPassBeginInfo {
                    Framebuffer = framebuffers [i],
                    RenderPass  = renderPass,
                    ClearValues = new ClearValue [] { new ClearValue {
                                                          Color = new ClearColorValue(new float [] { 0.9f, 0.7f, 0.0f, 1.0f })
                                                      } },
                    RenderArea = new Rect2D {
                        Extent = surfaceCapabilities.CurrentExtent
                    }
                };
                buffers [i].CmdBeginRenderPass(renderPassBeginInfo, SubpassContents.Inline);
                buffers [i].CmdEndRenderPass();
                buffers [i].End();
            }
            return(buffers);
        }
Ejemplo n.º 9
0
        void CreateCommandBuffer()
        {
            /*
             * We are getting closer to the end. In order to send commands to the device(GPU),
             * we must first record commands into a command buffer.
             * To allocate a command buffer, we must first create a command pool. So let us do that.
             */
            CommandPoolCreateInfo commandPoolCreateInfo = new CommandPoolCreateInfo()
            {
                Flags = 0,
                // the queue family of this command pool. All command buffers allocated from this command pool,
                // must be submitted to queues of this family ONLY.
                QueueFamilyIndex = computeQueueFamilyIndex
            };

            commandPool = device.CreateCommandPool(commandPoolCreateInfo);

            /*
             * Now allocate a command buffer from the command pool.
             */
            CommandBufferAllocateInfo commandBufferAllocateInfo = new CommandBufferAllocateInfo()
            {
                //commandBufferAllocateInfo.commandPool = commandPool; // specify the command pool to allocate from.
                // if the command buffer is primary, it can be directly submitted to queues.
                // A secondary buffer has to be called from some primary command buffer, and cannot be directly
                // submitted to a queue. To keep things simple, we use a primary command buffer.
                Level = CommandBufferLevel.Primary, // VK_COMMAND_BUFFER_LEVEL_PRIMARY;
                CommandBufferCount = 1              // allocate a single command buffer.
            };

            commandBuffers = commandPool.AllocateBuffers(commandBufferAllocateInfo); // allocate command buffer.

            /*
             * Now we shall start recording commands into the newly allocated command buffer.
             */
            CommandBufferBeginInfo beginInfo = new CommandBufferBeginInfo()
            {
                Flags = CommandBufferUsages.OneTimeSubmit// VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; // the buffer is only submitted and used once in this application.
            };

            commandBuffers[0].Begin(beginInfo); // start recording commands.

            /*
             * We need to bind a pipeline, AND a descriptor set before we dispatch.
             * The validation layer will NOT give warnings if you forget these, so be very careful not to forget them.
             */
            commandBuffers[0].CmdBindPipeline(PipelineBindPoint.Compute, pipelines[0]);                                     // VK_PIPELINE_BIND_POINT_COMPUTE, pipeline);
            commandBuffers[0].CmdBindDescriptorSets(PipelineBindPoint.Compute, pipelineLayout, 0, new[] { descriptorSet }); // VK_PIPELINE_BIND_POINT_COMPUTE, pipelineLayout, 0, 1, &descriptorSet, 0, NULL);

            /*
             * Calling vkCmdDispatch basically starts the compute pipeline, and executes the compute shader.
             * The number of workgroups is specified in the arguments.
             * If you are already familiar with compute shaders from OpenGL, this should be nothing new to you.
             */
            commandBuffers[0].CmdDispatch((int)Math.Ceiling((double)(WIDTH / WORKGROUP_SIZE)), (int)Math.Ceiling((double)(HEIGHT / WORKGROUP_SIZE)), 1);

            commandBuffers[0].End(); // end recording commands.
        }
Ejemplo n.º 10
0
        protected void CreateCommandPool()
        {
            var poolInfo = new CommandPoolCreateInfo
            {
                QueueFamilyIndex = (uint)data.queueFamilyIndices.GraphicsFamily
            };

            commandPool = device.CreateCommandPool(poolInfo);
        }
Ejemplo n.º 11
0
        public PrimaryCommandBufferPool(Device vulkanDevice, uint FamilyIndex, int commandBufferCount)
        {
            this.LogicalDevice = vulkanDevice;
            var createPoolInfo = new CommandPoolCreateInfo {
                Flags = CommandPoolCreateFlags.ResetCommandBuffer, QueueFamilyIndex = FamilyIndex
            };

            this.CommandPool = LogicalDevice.CreateCommandPool(createPoolInfo);
            AllocateBuffers(commandBufferCount);
        }
Ejemplo n.º 12
0
        public unsafe CommandBufferPool(GraphicsDevice graphicsDevice) : base(graphicsDevice)
        {
            var commandPoolCreateInfo = new CommandPoolCreateInfo
            {
                StructureType    = StructureType.CommandPoolCreateInfo,
                QueueFamilyIndex = 0, //device.NativeCommandQueue.FamilyIndex
                Flags            = CommandPoolCreateFlags.ResetCommandBuffer
            };

            commandPool = graphicsDevice.NativeDevice.CreateCommandPool(ref commandPoolCreateInfo);
        }
        private void CreateCommandPool()
        {
            var indices = new QueueFamilyIndices(vkPhysicalDevice, vkSurface);

            var poolInfo = new CommandPoolCreateInfo()
            {
                QueueFamilyIndex = (uint)indices.GraphicsFamily,
                Flags            = 0,
            };

            vkCommandPool = vkDevice.CreateCommandPool(poolInfo);
        }
Ejemplo n.º 14
0
        public unsafe CommandPool(Api api, uint queueFamilyIndex, bool allowReset)
        {
            _api = api;

            var poolInfo = new CommandPoolCreateInfo();

            poolInfo.SType            = StructureType.CommandPoolCreateInfo;
            poolInfo.QueueFamilyIndex = queueFamilyIndex;
            poolInfo.Flags            = allowReset ? CommandPoolCreateFlags.CommandPoolCreateResetCommandBufferBit : 0;

            Util.Verify(_api.Vk.CreateCommandPool(_api.Device.VkDevice, poolInfo, null, out _vkCommandPool), $"{nameof(CommandPool)}: Unable to create a command pool");
        }
Ejemplo n.º 15
0
        void CreateCommandPool(uint queue_family_index, out CommandPool pool)
        {
            var cmd_pool_create_info = new CommandPoolCreateInfo
            {
                sType            = StructureType.CommandPoolCreateInfo,      // VkStructureType                sType
                pNext            = IntPtr.Zero,                              // const void                    *pNext
                flags            = 0,                                        // VkCommandPoolCreateFlagBits       flags
                queueFamilyIndex = queue_family_index                        // uint32_t                       queueFamilyIndex
            };

            vk.CreateCommandPool(GetDevice, ref cmd_pool_create_info, (AllocationCallbacks *)0, out pool).CheckError();
        }
Ejemplo n.º 16
0
        CommandPool CreateCommandPool(uint queueFamily)
        {
            // Command pools are opaque objects that command buffer memory is allocated from, and
            // which allow the implementation to amortize the cost of resource creation across multiple
            // command buffers. Command pools are application-synchronized, meaning that a command pool
            // must not be used concurrently in multiple threads. That includes use via recording
            // commands on any command buffers allocated from the pool, as well as operations that
            // allocate, free, and reset command buffers or the pool itself.

            var commandPoolCreateInfo = new CommandPoolCreateInfo(queueFamily);

            commandPoolCreateInfo.Flags = CommandPoolCreateFlags.ResetCommandBuffer;
            return(device.CreateCommandPool(commandPoolCreateInfo));
        }
        private CommandPool CreateCommandPool()
        {
            var poolCreateInfo = new CommandPoolCreateInfo(
                flags: CommandPoolCreateFlags.CommandPoolCreateResetCommandBufferBit,
                queueFamilyIndex: this.QueueIndices.GraphicsFamily.Value);

            CommandPool pool;
            var         res = VkApi.CreateCommandPool(this.Device, &poolCreateInfo, null, &pool);

            if (res != Result.Success)
            {
                throw new VMASharp.VulkanResultException("Command Pool Creation Failed!", res);
            }

            return(pool);
        }
Ejemplo n.º 18
0
        CommandPool GetPool(QueueFlags type)
        {
            CommandPool pool;

            if (pools.TryGetValue(type, out pool))
            {
                return(pool);
            }
            CommandPoolCreateInfo info = new CommandPoolCreateInfo
            {
                QueueFamilyIndex = GetQueue(type).queueFamilyIndex,
                Flags            = (uint)CommandPoolCreateFlags.ResetCommandBuffer,
            };

            pool = Device.CreateCommandPool(info, null);
            pools.Add(type, pool);
            return(pool);
        }
Ejemplo n.º 19
0
        CommandBuffer [] CreateCommandBuffers(Image [] images, Framebuffer [] framebuffers, Pipeline pipeline, Buffer vertexBuffer, Buffer indexBuffer, uint indexLength)
        {
            var createPoolInfo = new CommandPoolCreateInfo {
                Flags = CommandPoolCreateFlags.ResetCommandBuffer
            };
            var commandPool = device.CreateCommandPool(createPoolInfo);
            var commandBufferAllocateInfo = new CommandBufferAllocateInfo {
                Level              = CommandBufferLevel.Primary,
                CommandPool        = commandPool,
                CommandBufferCount = (uint)images.Length
            };
            var buffers = device.AllocateCommandBuffers(commandBufferAllocateInfo);
            var commandBufferBeginInfo = new CommandBufferBeginInfo();

            for (int i = 0; i < images.Length; i++)
            {
                buffers [i].Begin(commandBufferBeginInfo);
                var renderPassBeginInfo = new RenderPassBeginInfo {
                    Framebuffer = framebuffers [i],
                    RenderPass  = renderPass,
                    ClearValues = new ClearValue [] { new ClearValue {
                                                          Color = new ClearColorValue(new float [] { 0.9f, 0.87f, 0.75f, 1.0f })
                                                      } },
                    RenderArea = new Rect2D {
                        Extent = surfaceCapabilities.CurrentExtent
                    }
                };
                buffers [i].CmdBeginRenderPass(renderPassBeginInfo, SubpassContents.Inline);
                buffers [i].CmdBindDescriptorSets(PipelineBindPoint.Graphics, pipelineLayout, 0, descriptorSets, null);
                buffers [i].CmdBindPipeline(PipelineBindPoint.Graphics, pipeline);
                buffers [i].CmdBindVertexBuffers(0, new Buffer [] { vertexBuffer }, new DeviceSize [] { 0 });
                buffers [i].CmdBindIndexBuffer(indexBuffer, 0, IndexType.Uint16);
                buffers [i].CmdDrawIndexed(indexLength, 1, 0, 0, 0);
                buffers [i].CmdEndRenderPass();
                buffers [i].End();
            }

            return(buffers);
        }
Ejemplo n.º 20
0
        public unsafe Frame(uint graphicsQueueFamily, Device device, Vk vk)
        {
            _device = device;
            _vk     = vk;

            FenceCreateInfo     fenceCreateInfo     = VkInit.FenceCreateInfo(true);
            SemaphoreCreateInfo semaphoreCreateInfo = VkInit.SemaphoreCreateInfo();

            VkUtil.AssertVulkan(vk.CreateFence(_device, fenceCreateInfo, null, out Fence renderFence));
            VkUtil.AssertVulkan(vk.CreateSemaphore(_device, semaphoreCreateInfo, null, out Semaphore renderSemaphore));
            VkUtil.AssertVulkan(vk.CreateSemaphore(_device, semaphoreCreateInfo, null, out Semaphore presentSemaphore));
            RenderSemaphore  = renderSemaphore;
            PresentSemaphore = presentSemaphore;
            RenderFence      = renderFence;

            CommandPoolCreateInfo commandPoolCreateInfo = VkInit.CommandPoolCreateInfo(graphicsQueueFamily, 0);

            VkUtil.AssertVulkan(_vk.CreateCommandPool(_device, commandPoolCreateInfo, null, out _commandPool));

            CreateCommandBuffers();

            _commandBufferIndex = 0;
        }
Ejemplo n.º 21
0
        static void CreateCommandBuffer()
        {
            // Command pool
            var commandPoolCreateInfo = new CommandPoolCreateInfo
            {
                QueueFamilyIndex = 0,
                Flags            = (uint)CommandPoolCreateFlags.ResetCommandBuffer,
            };

            commandPool = device.CreateCommandPool(commandPoolCreateInfo, null);
            Console.WriteLine("[ OK ] Command Pool");

            // Command Buffer
            var commandBufferAllocationInfo = new CommandBufferAllocateInfo
            {
                Level              = CommandBufferLevel.Primary,
                CommandPool        = commandPool,
                CommandBufferCount = 1,
            };

            commandBuffer = device.AllocateCommandBuffers(commandBufferAllocationInfo);
            Console.WriteLine("[ OK ] Command Buffer");
        }
Ejemplo n.º 22
0
 public unsafe CommandPool CreateCommandPool(ref CommandPoolCreateInfo createInfo, AllocationCallbacks* allocator = null)
 {
     CommandPool commandPool;
     fixed (CommandPoolCreateInfo* __createInfo__ = &createInfo)
     {
         vkCreateCommandPool(this, __createInfo__, allocator, &commandPool).CheckError();
     }
     return commandPool;
 }
Ejemplo n.º 23
0
        protected virtual void CreateCommandBuffer()
        {
            // Command pool
            var commandPoolCreateInfo = new CommandPoolCreateInfo
            {
                StructureType = StructureType.CommandPoolCreateInfo,
                QueueFamilyIndex = 0,
                Flags = CommandPoolCreateFlags.ResetCommandBuffer
            };
            commandPool = device.CreateCommandPool(ref commandPoolCreateInfo);

            // Command buffer
            var commandBufferAllocationInfo = new CommandBufferAllocateInfo
            {
                StructureType = StructureType.CommandBufferAllocateInfo,
                Level = CommandBufferLevel.Primary,
                CommandPool = commandPool,
                CommandBufferCount = 1
            };
            CommandBuffer commandBuffer;
            device.AllocateCommandBuffers(ref commandBufferAllocationInfo, &commandBuffer);
            this.commandBuffer = commandBuffer;
        }
Ejemplo n.º 24
0
        /// <summary>
        ///     Initializes the specified device.
        /// </summary>
        /// <param name="graphicsProfiles">The graphics profiles.</param>
        /// <param name="deviceCreationFlags">The device creation flags.</param>
        /// <param name="windowHandle">The window handle.</param>
        private unsafe void InitializePlatformDevice(GraphicsProfile[] graphicsProfiles, DeviceCreationFlags deviceCreationFlags, object windowHandle)
        {
            if (nativeDevice != Device.Null)
            {
                // Destroy previous device
                ReleaseDevice();
            }

            rendererName = Adapter.Description;

            PhysicalDeviceProperties physicalDeviceProperties;

            NativePhysicalDevice.GetProperties(out physicalDeviceProperties);
            ConstantBufferDataPlacementAlignment = (int)physicalDeviceProperties.Limits.MinUniformBufferOffsetAlignment;

            RequestedProfile = graphicsProfiles.Last();

            var queueProperties = NativePhysicalDevice.QueueFamilyProperties;

            // Command lists are thread-safe and execute deferred
            IsDeferred = true;

            // TODO VULKAN
            // Create Vulkan device based on profile
            uint queuePriorities = 0;
            var  queueCreateInfo = new DeviceQueueCreateInfo
            {
                StructureType    = StructureType.DeviceQueueCreateInfo,
                QueueFamilyIndex = 0,
                QueueCount       = 1,
                QueuePriorities  = new IntPtr(&queuePriorities)
            };

            var enabledFeature = new PhysicalDeviceFeatures
            {
                FillModeNonSolid   = true,
                ShaderClipDistance = true,
                ShaderCullDistance = true,
                SamplerAnisotropy  = true,
                DepthClamp         = true,
            };

            var extensionProperties     = NativePhysicalDevice.GetDeviceExtensionProperties();
            var availableExtensionNames = new List <string>();
            var desiredExtensionNames   = new List <string>();

            for (int index = 0; index < extensionProperties.Length; index++)
            {
                var namePointer = new IntPtr(Interop.Fixed(ref extensionProperties[index].ExtensionName));
                var name        = Marshal.PtrToStringAnsi(namePointer);
                availableExtensionNames.Add(name);
            }

            desiredExtensionNames.Add("VK_KHR_swapchain");
            if (!availableExtensionNames.Contains("VK_KHR_swapchain"))
            {
                throw new InvalidOperationException();
            }

            if (availableExtensionNames.Contains("VK_EXT_debug_marker") && IsDebugMode)
            {
                desiredExtensionNames.Add("VK_EXT_debug_marker");
                IsProfilingSupported = true;
            }

            var enabledExtensionNames = desiredExtensionNames.Select(Marshal.StringToHGlobalAnsi).ToArray();

            try
            {
                var deviceCreateInfo = new DeviceCreateInfo
                {
                    StructureType         = StructureType.DeviceCreateInfo,
                    QueueCreateInfoCount  = 1,
                    QueueCreateInfos      = new IntPtr(&queueCreateInfo),
                    EnabledExtensionCount = (uint)enabledExtensionNames.Length,
                    EnabledExtensionNames = enabledExtensionNames.Length > 0 ? new IntPtr(Interop.Fixed(enabledExtensionNames)) : IntPtr.Zero,
                    EnabledFeatures       = new IntPtr(&enabledFeature)
                };

                nativeDevice = NativePhysicalDevice.CreateDevice(ref deviceCreateInfo);
            }
            finally
            {
                foreach (var enabledExtensionName in enabledExtensionNames)
                {
                    Marshal.FreeHGlobal(enabledExtensionName);
                }
            }

            NativeCommandQueue = nativeDevice.GetQueue(0, 0);

            //// Prepare copy command list (start it closed, so that every new use start with a Reset)
            var commandPoolCreateInfo = new CommandPoolCreateInfo
            {
                StructureType    = StructureType.CommandPoolCreateInfo,
                QueueFamilyIndex = 0, //device.NativeCommandQueue.FamilyIndex
                Flags            = CommandPoolCreateFlags.ResetCommandBuffer
            };

            NativeCopyCommandPool = NativeDevice.CreateCommandPool(ref commandPoolCreateInfo);

            var commandBufferAllocationInfo = new CommandBufferAllocateInfo
            {
                StructureType      = StructureType.CommandBufferAllocateInfo,
                Level              = CommandBufferLevel.Primary,
                CommandPool        = NativeCopyCommandPool,
                CommandBufferCount = 1
            };
            CommandBuffer nativeCommandBuffer;

            NativeDevice.AllocateCommandBuffers(ref commandBufferAllocationInfo, &nativeCommandBuffer);
            NativeCopyCommandBuffer = nativeCommandBuffer;

            DescriptorPools = new HeapPool(this);

            nativeResourceCollector       = new NativeResourceCollector(this);
            graphicsResourceLinkCollector = new GraphicsResourceLinkCollector(this);

            EmptyTexelBuffer = Buffer.Typed.New(this, 1, PixelFormat.R32G32B32A32_Float);
        }
Ejemplo n.º 25
0
 internal static unsafe extern Result vkCreateCommandPool(Device device, CommandPoolCreateInfo* createInfo, AllocationCallbacks* allocator, CommandPool* commandPool);