Ejemplo n.º 1
0
        private void CreateCommandPool()
        {
            VkCommandPoolCreateInfo cmdPoolInfo = VkCommandPoolCreateInfo.New();

            cmdPoolInfo.queueFamilyIndex = Swapchain.QueueNodeIndex;
            cmdPoolInfo.flags            = VkCommandPoolCreateFlags.ResetCommandBuffer;
            Util.CheckResult(vkCreateCommandPool(device, &cmdPoolInfo, null, out _cmdPool));
        }
Ejemplo n.º 2
0
        void CreateCommandPool()
        {
            var info = new VkCommandPoolCreateInfo();

            info.queueFamilyIndex = graphicsIndex;

            commandPool = new VkCommandPool(device, info);
        }
Ejemplo n.º 3
0
        private void CreatePerFrameCommandPool()
        {
            VkCommandPoolCreateInfo commandPoolCI = VkCommandPoolCreateInfo.New();

            commandPoolCI.flags            = VkCommandPoolCreateFlags.ResetCommandBuffer | VkCommandPoolCreateFlags.Transient;
            commandPoolCI.queueFamilyIndex = _graphicsQueueIndex;
            vkCreateCommandPool(_device, ref commandPoolCI, null, out _perFrameCommandPool);
        }
Ejemplo n.º 4
0
        public void Build(int device_index, CommandQueueKind queue)
        {
            if (!locked)
            {
                unsafe
                {
                    var devInfo = GraphicsDevice.GetDeviceInfo(device_index);
                    queueFamily = queue switch
                    {
                        CommandQueueKind.Graphics => devInfo.GraphicsFamily,
                        CommandQueueKind.Compute => devInfo.ComputeFamily,
                        CommandQueueKind.Transfer => devInfo.TransferFamily,
                        CommandQueueKind.Present => devInfo.PresentFamily,
                        _ => throw new Exception("Unknown command queue type.")
                    };
                    queueFam = queue switch
                    {
                        CommandQueueKind.Graphics => devInfo.GraphicsQueue,
                        CommandQueueKind.Compute => devInfo.ComputeQueue,
                        CommandQueueKind.Transfer => devInfo.TransferQueue,
                        CommandQueueKind.Present => devInfo.PresentQueue,
                        _ => throw new Exception("Unknown command queue type.")
                    };

                    var poolInfo = new VkCommandPoolCreateInfo()
                    {
                        sType            = VkStructureType.StructureTypeCommandPoolCreateInfo,
                        queueFamilyIndex = queueFamily,
                        flags            = Transient ? VkCommandPoolCreateFlags.CommandPoolCreateTransientBit : VkCommandPoolCreateFlags.CommandPoolCreateResetCommandBufferBit,
                    };

                    IntPtr commandPoolPtr_l = IntPtr.Zero;
                    if (vkCreateCommandPool(devInfo.Device, poolInfo.Pointer(), null, &commandPoolPtr_l) != VkResult.Success)
                    {
                        throw new Exception("Failed to create command pool.");
                    }
                    hndl  = commandPoolPtr_l;
                    devID = device_index;

                    if (GraphicsDevice.EnableValidation && Name != null)
                    {
                        var objName = new VkDebugUtilsObjectNameInfoEXT()
                        {
                            sType        = VkStructureType.StructureTypeDebugUtilsObjectNameInfoExt,
                            pObjectName  = Name,
                            objectType   = VkObjectType.ObjectTypeCommandPool,
                            objectHandle = (ulong)hndl
                        };
                        GraphicsDevice.SetDebugUtilsObjectNameEXT(GraphicsDevice.GetDeviceInfo(devID).Device, objName.Pointer());
                    }
                }
                locked = true;
            }
            else
            {
                throw new Exception("CommandPool is locked.");
            }
        }
Ejemplo n.º 5
0
        void CreateCommandPool()
        {
            var info = new VkCommandPoolCreateInfo();

            info.sType            = CSGL.Vulkan.VkStructureType.CommandPoolCreateInfo;
            info.queueFamilyIndex = graphicsIndex;

            var result = VK.CreateCommandPool(device, ref info, alloc, out commandPool);
        }
Ejemplo n.º 6
0
        void CreateCommandPool()
        {
            var info = new VkCommandPoolCreateInfo();

            info.queueFamilyIndex = graphicsIndex;
            info.flags            = VkCommandPoolCreateFlags.ResetCommandBufferBit;

            commandPool = new VkCommandPool(device, info);
        }
Ejemplo n.º 7
0
        private void Vkctrl_VulkanInitialized(object sender, SharpVulkanWpf.VulkanEventArgs args)
        {
            var device = args.Device;
            var commandPoolCreateInfo = new VkCommandPoolCreateInfo()
            {
                queueFamilyIndex = args.GraphicsQueueIndex,
                flags            = VkCommandPoolCreateFlags.VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT,
            };

            VulkanAPI.vkCreateCommandPool(device, ref commandPoolCreateInfo, out m_commandPool);

            var allocateInfo = new VkCommandBufferAllocateInfo()
            {
                commandBufferCount = 1,
                commandPool        = m_commandPool,
            };

            VulkanAPI.vkAllocateCommandBuffers(device, ref allocateInfo, out m_commandBuffers);

            // 頂点入力情報の構築.
            m_vertexInputState = CreateVertexInputState();
            // プリミティブの情報 トライアングルリストでデータが生成されている.
            m_inputAssemblyState = new VkPipelineInputAssemblyStateCreateInfo()
            {
                topology = VkPrimitiveTopology.VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST
            };
            // シェーダーステージ情報の構築.
            m_shaderStages = new VkPipelineShaderStageCreateInfo[2]
            {
                SampleHelpers.CreateShader(device, "resource/simpleVS.spv", VkShaderStageFlagBits.VK_SHADER_STAGE_VERTEX_BIT),
                SampleHelpers.CreateShader(device, "resource/simpleFS.spv", VkShaderStageFlagBits.VK_SHADER_STAGE_FRAGMENT_BIT),
            };
            // ラスタライザーステートの構築.
            m_rasterizationState = new VkPipelineRasterizationStateCreateInfo();
            // デプスステンシルステートの構築.
            m_depthStencilState = new VkPipelineDepthStencilStateCreateInfo();
            // カラーブレンドステートの構築.
            m_colorBlendState = new VkPipelineColorBlendStateCreateInfo();
            var colorBlendAttachment = new VkPipelineColorBlendAttachmentState();

            m_colorBlendState.attachments = new[] { colorBlendAttachment };

            // マルチサンプルステートの構築.
            m_multisampleState = new VkPipelineMultisampleStateCreateInfo();

            // パイプラインレイアウトの構築.
            m_pipelineLayout = CreatePipelineLayout(device);

            // ビューポートステートの構築.
            m_viewportState = CreateViewportState();

            // グラフィックスパイプラインを構築.
            m_graphicsPipeline = CreateGraphicsPipeline(device, vkctrl.GetControlRenderPass());

            // 頂点バッファの作成.
            CreateVertexBuffer(device, args.PhysicalDevice);
        }
Ejemplo n.º 8
0
        public static VkResult vkCreateCommandPool(VkDevice device, uint queueFamilyIndex, out VkCommandPool commandPool)
        {
            VkCommandPoolCreateInfo createInfo = new VkCommandPoolCreateInfo
            {
                sType            = VkStructureType.CommandPoolCreateInfo,
                queueFamilyIndex = queueFamilyIndex
            };

            return(vkCreateCommandPool(device, &createInfo, null, out commandPool));
        }
Ejemplo n.º 9
0
 public override void Activate()
 {
     if (state != ActivableState.Activated)
     {
         VkCommandPoolCreateInfo infos = VkCommandPoolCreateInfo.New();
         infos.queueFamilyIndex = QFamIndex;
         Utils.CheckResult(vkCreateCommandPool(Dev.VkDev, ref infos, IntPtr.Zero, out handle));
     }
     base.Activate();
 }
Ejemplo n.º 10
0
        private void CreateGraphicsCommandPool()
        {
            VkCommandPoolCreateInfo commandPoolCI = VkCommandPoolCreateInfo.New();

            commandPoolCI.flags            = VkCommandPoolCreateFlags.ResetCommandBuffer;
            commandPoolCI.queueFamilyIndex = _graphicsQueueIndex;
            VkResult result = vkCreateCommandPool(_device, ref commandPoolCI, null, out _graphicsCommandPool);

            CheckResult(result);
        }
Ejemplo n.º 11
0
        private void CreateCommandPool()
        {
            var queueFamilyIndices = FindQueueFamilies(physicalDevice, surface).Value;
            var poolInfo           = new VkCommandPoolCreateInfo
            {
                QueueFamilyIndex = queueFamilyIndices.GraphicsFamily,
                Flags            = VkCommandPoolCreateFlags.None
            };

            commandPool = device.CreateCommandPool(poolInfo, null).Object;
        }
Ejemplo n.º 12
0
        private VkCommandPool CreateCommandPool(
            uint queueFamilyIndex,
            VkCommandPoolCreateFlags createFlags = VkCommandPoolCreateFlags.ResetCommandBuffer)
        {
            VkCommandPoolCreateInfo cmdPoolInfo = VkCommandPoolCreateInfo.New();

            cmdPoolInfo.queueFamilyIndex = queueFamilyIndex;
            cmdPoolInfo.flags            = createFlags;
            Util.CheckResult(vkCreateCommandPool(LogicalDevice, &cmdPoolInfo, null, out VkCommandPool cmdPool));
            return(cmdPool);
        }
Ejemplo n.º 13
0
        public unsafe CommandBufferPool(GraphicsDevice graphicsDevice) : base(graphicsDevice)
        {
            var commandPoolCreateInfo = new VkCommandPoolCreateInfo
            {
                sType            = VkStructureType.CommandPoolCreateInfo,
                queueFamilyIndex = 0, //device.NativeCommandQueue.FamilyIndex
                flags            = VkCommandPoolCreateFlags.ResetCommandBuffer
            };

            vkCreateCommandPool(graphicsDevice.NativeDevice, &commandPoolCreateInfo, null, out commandPool);
        }
Ejemplo n.º 14
0
        public VkResourceFactory(VkRenderContext rc)
        {
            RenderContext   = rc;
            _device         = rc.Device;
            _physicalDevice = rc.PhysicalDevice;

            VkCommandPoolCreateInfo commandPoolCI = VkCommandPoolCreateInfo.New();

            commandPoolCI.flags            = VkCommandPoolCreateFlags.None;
            commandPoolCI.queueFamilyIndex = rc.GraphicsQueueIndex;
        }
Ejemplo n.º 15
0
        private void CreateCommandPool()
        {
            VkCommandPoolCreateInfo cmdPoolInfo = new VkCommandPoolCreateInfo();

            cmdPoolInfo.sType            = CommandPoolCreateInfo;
            cmdPoolInfo.queueFamilyIndex = Swapchain.QueueNodeIndex;
            cmdPoolInfo.flags            = VkCommandPoolCreateFlagBits.ResetCommandBuffer;
            VkCommandPool pool;

            vkCreateCommandPool(device, &cmdPoolInfo, null, &pool);
            this._cmdPool = pool;
        }
Ejemplo n.º 16
0
        public static VkCommandPool CreateCommandPool(uint queueFamilyIndex, VkCommandPoolCreateFlags createFlags = VkCommandPoolCreateFlags.ResetCommandBuffer)
        {
            VkCommandPoolCreateInfo cmdPoolInfo = new VkCommandPoolCreateInfo
            {
                sType = VkStructureType.CommandPoolCreateInfo
            };

            cmdPoolInfo.queueFamilyIndex = queueFamilyIndex;
            cmdPoolInfo.flags            = createFlags;
            VulkanUtil.CheckResult(vkCreateCommandPool(device, &cmdPoolInfo, null, out VkCommandPool cmdPool));
            return(cmdPool);
        }
Ejemplo n.º 17
0
            public SharedCommandPool(VkGraphicsDevice gd, bool isCached)
            {
                _gd      = gd;
                IsCached = isCached;

                VkCommandPoolCreateInfo commandPoolCI = VkCommandPoolCreateInfo.New();

                commandPoolCI.flags            = VkCommandPoolCreateFlags.Transient;
                commandPoolCI.queueFamilyIndex = _gd.GraphicsQueueIndex;
                VkResult result = vkCreateCommandPool(_gd.Device, ref commandPoolCI, null, out _pool);

                CheckResult(result);
            }
Ejemplo n.º 18
0
        public VkCommandList(VkGraphicsDevice gd, ref CommandListDescription description)
            : base(ref description, gd.Features)
        {
            _gd = gd;
            VkCommandPoolCreateInfo poolCI = VkCommandPoolCreateInfo.New();

            poolCI.flags            = VkCommandPoolCreateFlags.ResetCommandBuffer;
            poolCI.queueFamilyIndex = gd.GraphicsQueueIndex;
            VkResult result = vkCreateCommandPool(_gd.Device, ref poolCI, null, out _pool);

            CheckResult(result);

            _cb = GetNextCommandBuffer();
        }
Ejemplo n.º 19
0
        private VkCommandPool CreateCommandPool(
            uint queueFamilyIndex,
            VkCommandPoolCreateFlagBits createFlags = VkCommandPoolCreateFlagBits.ResetCommandBuffer)
        {
            VkCommandPoolCreateInfo cmdPoolInfo = new VkCommandPoolCreateInfo();

            cmdPoolInfo.sType            = CommandPoolCreateInfo;
            cmdPoolInfo.queueFamilyIndex = queueFamilyIndex;
            cmdPoolInfo.flags            = createFlags;
            VkCommandPool cmdPool;

            vkCreateCommandPool(LogicalDevice, &cmdPoolInfo, null, &cmdPool);
            return(cmdPool);
        }
Ejemplo n.º 20
0
        private VkCommandPool CreateVulkanCommandPool()
        {
            VkCommandPool vulkanCommandPool;

            var commandPoolCreateInfo = new VkCommandPoolCreateInfo {
                sType            = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO,
                flags            = (uint)VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT,
                queueFamilyIndex = VulkanGraphicsDevice.VulkanCommandQueueFamilyIndex,
            };

            ThrowExternalExceptionIfNotSuccess(nameof(vkCreateCommandPool), vkCreateCommandPool(VulkanGraphicsDevice.VulkanDevice, &commandPoolCreateInfo, pAllocator: null, (ulong *)&vulkanCommandPool));

            return(vulkanCommandPool);
        }
Ejemplo n.º 21
0
        private VkCommandPool CreateCommandPool(uint queueFamilyIndex)
        {
            VkCommandPoolCreateInfo createInfo = new VkCommandPoolCreateInfo()
            {
                sType            = VkStructureType.CommandPoolCreateInfo,
                queueFamilyIndex = queueFamilyIndex,
                flags            = 0,
                pNext            = null,
            };

            vkCreateCommandPool(Device, &createInfo, null, out VkCommandPool commandPool);

            return(commandPool);
        }
Ejemplo n.º 22
0
        internal VkCommandPool CreateCommandPool()
        {
            VkCommandPoolCreateInfo poolInfo = new VkCommandPoolCreateInfo()
            {
                sType            = VkStructureType.CommandPoolCreateInfo,
                queueFamilyIndex = GraphicsFamily,
                flags            = 0,
                pNext            = null,
            };

            vkCreateCommandPool(Device, &poolInfo, null, out var commandPool);

            return(commandPool);
        }
Ejemplo n.º 23
0
        public CommandPool(GraphicsDevice device, Swapchain swapchain)
        {
            this.device = device;

            VkCommandPoolCreateInfo cmdPoolInfo = VkCommandPoolCreateInfo.New();

            cmdPoolInfo.queueFamilyIndex = swapchain.vkSwapchain.QueueNodeIndex;
            cmdPoolInfo.flags            =
                VkCommandPoolCreateFlags.ResetCommandBuffer
                | VkCommandPoolCreateFlags.Transient;
            Util.CheckResult(vkCreateCommandPool(device.device, &cmdPoolInfo, null, out vkCmdPool));

            AllocateBuffers(VkCommandBufferLevel.Primary, 2);
            AllocateBuffers(VkCommandBufferLevel.Secondary, 2);
        }
Ejemplo n.º 24
0
 public CommandPool(Device dev, uint queueFamily, VkCommandPoolCreateFlag flags = 0)
 {
     Device = dev;
     unsafe
     {
         var info = new VkCommandPoolCreateInfo()
         {
             SType            = VkStructureType.CommandPoolCreateInfo,
             PNext            = IntPtr.Zero,
             Flags            = flags,
             QueueFamilyIndex = queueFamily
         };
         Handle = dev.Handle.CreateCommandPool(&info, Instance.AllocationCallbacks);
     }
 }
Ejemplo n.º 25
0
        private void createCommandPool()
        {
            QueueFamilyIndices queueFamilyIndices = findQueueFamilies(physicalDevice);

            VkCommandPoolCreateInfo poolInfo = new VkCommandPoolCreateInfo();

            poolInfo.sType            = VkStructureType.VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO;
            poolInfo.queueFamilyIndex = queueFamilyIndices.graphicsFamily;

            VkResult result = Vulkan.vkCreateCommandPool(device, poolInfo, null, out commandPool);

            if (result != VkResult.VK_SUCCESS)
            {
                throw Program.Throw("failed to create command pool!", result);
            }
        }
        private void CreateCommandPool()
        {
            QueueFamilyIndices queueFamilyIndices = this.FindQueueFamilies(this.physicalDevice);

            VkCommandPoolCreateInfo poolInfo = new VkCommandPoolCreateInfo()
            {
                sType            = VkStructureType.VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO,
                queueFamilyIndex = queueFamilyIndices.graphicsFamily.Value,
                flags            = 0, // Optional,
            };

            fixed(VkCommandPool *commandPoolPtr = &this.commandPool)
            {
                Helpers.CheckErrors(VulkanNative.vkCreateCommandPool(device, &poolInfo, null, commandPoolPtr));
            }
        }
Ejemplo n.º 27
0
        private void CreateCommandPool()
        {
            var indices = new QueueFamilyIndices(vkPhysicalDevice, vkSurface);

            var poolInfo = new VkCommandPoolCreateInfo()
            {
                sType            = VkStructureType.VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO,
                queueFamilyIndex = (uint)indices.GraphicsFamily,
                flags            = 0,
            };

            VkCommandPool newCommandPool;
            var           result = VulkanNative.vkCreateCommandPool(vkDevice, &poolInfo, null, &newCommandPool);

            vkCommandPool = newCommandPool;
            Helpers.CheckErrors(result);
        }
Ejemplo n.º 28
0
        void CreateCommandPool(CommandPoolCreateInfo mInfo)
        {
            VkCommandPoolCreateInfo info = new VkCommandPoolCreateInfo();

            info.sType            = VkStructureType.CommandPoolCreateInfo;
            info.flags            = mInfo.flags;
            info.queueFamilyIndex = mInfo.queueFamilyIndex;

            var result = Device.Commands.createCommandPool(Device.Native, ref info, Device.Instance.AllocationCallbacks, out commandPool);

            if (result != VkResult.Success)
            {
                throw new CommandPoolException(string.Format("Error creating command pool: {0}", result));
            }

            Flags = mInfo.flags;
        }
        private void Vkctrl_VulkanInitialized(object sender, SharpVulkanWpf.VulkanEventArgs args)
        {
            var device = args.Device;
            var commandPoolCreateInfo = new VkCommandPoolCreateInfo()
            {
                queueFamilyIndex = args.GraphicsQueueIndex,
                flags            = VkCommandPoolCreateFlags.VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT,
            };

            VulkanAPI.vkCreateCommandPool(device, ref commandPoolCreateInfo, out m_commandPool);

            var allocateInfo = new VkCommandBufferAllocateInfo()
            {
                commandBufferCount = 1,
                commandPool        = m_commandPool,
            };

            VulkanAPI.vkAllocateCommandBuffers(device, ref allocateInfo, out m_commandBuffers);
        }
Ejemplo n.º 30
0
        public VkCommandList(VkGraphicsDevice gd, ref CommandListDescription description)
            : base(ref description)
        {
            _gd = gd;
            VkCommandPoolCreateInfo poolCI = VkCommandPoolCreateInfo.New();

            poolCI.queueFamilyIndex = gd.GraphicsQueueIndex;
            VkResult result = vkCreateCommandPool(_gd.Device, ref poolCI, null, out _pool);

            CheckResult(result);

            VkCommandBufferAllocateInfo cbAI = VkCommandBufferAllocateInfo.New();

            cbAI.commandPool        = _pool;
            cbAI.commandBufferCount = 1;
            cbAI.level = VkCommandBufferLevel.Primary;
            result     = vkAllocateCommandBuffers(gd.Device, ref cbAI, out _cb);
            CheckResult(result);
        }