{"id":708,"date":"2022-04-04T16:48:15","date_gmt":"2022-04-04T08:48:15","guid":{"rendered":"https:\/\/dcupqiu.club\/?p=708"},"modified":"2022-04-05T18:20:59","modified_gmt":"2022-04-05T10:20:59","slug":"%e4%b8%89%e5%a4%a9%e9%80%9f%e6%88%90vulkan3","status":"publish","type":"post","link":"https:\/\/dcupqiu.club\/?p=708","title":{"rendered":"\u4e09\u5929\u901f\u6210Vulkan(3)-Physical devices logical devices and queue familie"},"content":{"rendered":"\n<p>\u5728\u521b\u5efa\u5b8c\u6210Vulkan\u540e\uff0c\u6211\u4eec\u9700\u8981\u5728\u8bbe\u5907\u4e0a\u5bfb\u627e\u4e00\u4e2a\u652f\u6301\u6240\u9700\u7279\u6027\u7684\u7269\u7406\u8bbe\u5907\uff0c\u6216\u8005\u540c\u65f6\u8c03\u7528\u591a\u4e2a\u8bbe\u5907\u3002\u9009\u4e2d \u7269\u7406\u8bbe\u5907\u5c06\u88ab\u5b58\u50a8\u5230 VkPhysicalDevice \u7684\u53e5\u67c4\u4e2d\uff0c\u5e76\u79f0\u4e3a\u4e00\u4e2a\u65b0\u7684\u9700\u8981\u7ba1\u7406\u7684\u6210\u5458\u7c7b\uff0c\u8be5\u5bf9\u8c61\u7684\u9500\u6bc1\u65e0\u9700\u6211\u4eec\u624b\u52a8\u8fdb\u884c\u7ba1\u7406\u3002\u67e5\u627e\u53ef\u9009\u7684Devices\u7684\u8fc7\u7a0b\u4e0eExtensions\u7684\u8fc7\u7a0b\u7c7b\u4f3c\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"cpp\" class=\"language-cpp\">VkPhysicalDevice physicalDevice = VK_NULL_HANDLE;\n\n    void pickPhysicalDevice() {\n        uint32_t deviceCount = 0;\n        vkEnumeratePhysicalDevices(instance, &amp;deviceCount, nullptr);\n\n        if (deviceCount == 0) {\n            throw std::runtime_error(\"failed to find GPUs with Vulkan support\");\n        }\n\n        std::vector&lt;VkPhysicalDevice&gt; devices(deviceCount);\n        vkEnumeratePhysicalDevices(instance, &amp;deviceCount, devices.data());\n\n        for (const auto &amp;device: devices) {\n            if (isDeviceSuitable(device)) {\n                physicalDevice = device;\n                break;\n            }\n        }\n\n\n        if (physicalDevice == VK_NULL_HANDLE) {\n            throw std::runtime_error(\"Failed to find a suitable GPU\");\n        }\n    }<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Device\u5bf9\u8c61\u7684suitability\u68c0\u67e5<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"cpp\" class=\"language-cpp\">    bool isDeviceSuitable(VkPhysicalDevice device) {\n\n        VkPhysicalDeviceProperties  deviceProperties;\n        vkGetPhysicalDeviceProperties(device, &amp;deviceProperties);\n\n        VkPhysicalDeviceFeatures deviceFeatures;\n        vkGetPhysicalDeviceFeatures(device, &amp;deviceFeatures);\n\n        return deviceProperties.deviceType == VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU &amp;&amp; deviceFeatures.geometryShader;\n    }\n\n    void pickPhysicalDevice() {\n        uint32_t deviceCount = 0;\n        vkEnumeratePhysicalDevices(instance, &amp;deviceCount, nullptr);\n\n        if (deviceCount == 0) {\n            throw std::runtime_error(\"failed to find GPUs with Vulkan support\");\n        }\n\n        std::vector&lt;VkPhysicalDevice&gt; devices(deviceCount);\n        vkEnumeratePhysicalDevices(instance, &amp;deviceCount, devices.data());\n\n        for (const auto &amp;device: devices) {\n            if (isDeviceSuitable(device)) {\n                physicalDevice = device;\n                break;\n            }\n        }\n\n\n        if (physicalDevice == VK_NULL_HANDLE) {\n            throw std::runtime_error(\"Failed to find a suitable GPU\");\n        }\n\n        VkPhysicalDeviceProperties  deviceProperties;\n        vkGetPhysicalDeviceProperties(physicalDevice, &amp;deviceProperties);\n\n        std::cout &lt;&lt; \"Selected GPU: \" &lt;&lt; deviceProperties.deviceName &lt;&lt; std::endl;\n    }<\/code><\/pre>\n\n\n\n<p>\u53ef\u4ee5\u6839\u636e\u5404\u4e2aDevice\u62e5\u6709\u7684\u7279\u6027\u9009\u62e9\u6700\u5408\u9002\u7684\u90a3\u4e2aDevice\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Queue familie<\/h2>\n\n\n\n<p>\u5728Vulkan\u4e2d\uff0c\u4ece\u4e0d\u540c\u7684queue families\u4e2d\u884d\u751f\u51fa\u4e86\u4e0d\u540c\u79cd\u7c7b\u7684queues\u5e76\u4e14\u4e0d\u540c\u5bb6\u65cf\u7684queues\u53ea\u4f1a\u5141\u8bb8\u4e00\u4e2a\u5b50\u7c7b\u7684\u547d\u4ee4\u3002\u4f8b\u5982\u6709\u4e9bqueue family\u53ea\u5141\u8bb8\u5904\u7406compute commands\uff0c\u800c\u6709\u4e9b\u53ea\u80fd\u6267\u884cmemory transfer related commands\u3002<br>\u6211\u4eec\u9700\u8981\u68c0\u67e5\u90a3\u4e9bqueue familes\u662f\u80fd\u591f\u88ab\u8bbe\u5907\u652f\u6301\u7684\uff0c\u4ee5\u53ca\u54ea\u4e9b\u6307\u4ee4\u662f\u6211\u4eec\u9700\u8981\u7528\u5230\u7684\u3002\u56e0\u6b64\uff0c\u6211\u4eec\u53ef\u4ee5\u521b\u5efa\u4e00\u4e2a\u65b0\u7684function &#8216;findQueueFamilies&#8217; \u6765\u67e5\u627e\u90a3\u4e9b\u6211\u4eec\u9700\u8981\u7528\u5230\u7684queue families\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5728\u521b\u5efa\u5b8c\u6210Vulkan\u540e\uff0c\u6211\u4eec\u9700\u8981\u5728\u8bbe\u5907\u4e0a\u5bfb\u627e\u4e00\u4e2a&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[15,11],"tags":[],"class_list":["post-708","post","type-post","status-publish","format-standard","hentry","category-vulkan","category-programer-language"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v18.5.1 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u4e09\u5929\u901f\u6210Vulkan(3)-Physical devices logical devices and queue familie - \u79cb\u5586\u306eSite<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/dcupqiu.club\/?p=708\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u4e09\u5929\u901f\u6210Vulkan(3)-Physical devices logical devices and queue familie - \u79cb\u5586\u306eSite\" \/>\n<meta property=\"og:description\" content=\"\u5728\u521b\u5efa\u5b8c\u6210Vulkan\u540e\uff0c\u6211\u4eec\u9700\u8981\u5728\u8bbe\u5907\u4e0a\u5bfb\u627e\u4e00\u4e2a...\" \/>\n<meta property=\"og:url\" content=\"https:\/\/dcupqiu.club\/?p=708\" \/>\n<meta property=\"og:site_name\" content=\"\u79cb\u5586\u306eSite\" \/>\n<meta property=\"article:published_time\" content=\"2022-04-04T08:48:15+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-04-05T10:20:59+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"\u79cb\u5586\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebSite\",\"@id\":\"https:\/\/dcupqiu.club\/#website\",\"url\":\"https:\/\/dcupqiu.club\/\",\"name\":\"\u79cb\u5586\u306eSite\",\"description\":\"WwwwwW\",\"publisher\":{\"@id\":\"https:\/\/dcupqiu.club\/#\/schema\/person\/33f847360b49873a92e0a1461d4d6a20\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/dcupqiu.club\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/dcupqiu.club\/?p=708#webpage\",\"url\":\"https:\/\/dcupqiu.club\/?p=708\",\"name\":\"\u4e09\u5929\u901f\u6210Vulkan(3)-Physical devices logical devices and queue familie - \u79cb\u5586\u306eSite\",\"isPartOf\":{\"@id\":\"https:\/\/dcupqiu.club\/#website\"},\"datePublished\":\"2022-04-04T08:48:15+00:00\",\"dateModified\":\"2022-04-05T10:20:59+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/dcupqiu.club\/?p=708#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/dcupqiu.club\/?p=708\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/dcupqiu.club\/?p=708#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/dcupqiu.club\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u4e09\u5929\u901f\u6210Vulkan(3)-Physical devices logical devices and queue familie\"}]},{\"@type\":\"Article\",\"@id\":\"https:\/\/dcupqiu.club\/?p=708#article\",\"isPartOf\":{\"@id\":\"https:\/\/dcupqiu.club\/?p=708#webpage\"},\"author\":{\"@id\":\"https:\/\/dcupqiu.club\/#\/schema\/person\/33f847360b49873a92e0a1461d4d6a20\"},\"headline\":\"\u4e09\u5929\u901f\u6210Vulkan(3)-Physical devices logical devices and queue familie\",\"datePublished\":\"2022-04-04T08:48:15+00:00\",\"dateModified\":\"2022-04-05T10:20:59+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/dcupqiu.club\/?p=708#webpage\"},\"wordCount\":37,\"publisher\":{\"@id\":\"https:\/\/dcupqiu.club\/#\/schema\/person\/33f847360b49873a92e0a1461d4d6a20\"},\"articleSection\":[\"Vulkan\",\"\u7a0b\u5e8f\u8bed\u8a00\u5b66\u4e60\"],\"inLanguage\":\"zh-Hans\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\/\/dcupqiu.club\/#\/schema\/person\/33f847360b49873a92e0a1461d4d6a20\",\"name\":\"\u79cb\u5586\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/dcupqiu.club\/#personlogo\",\"inLanguage\":\"zh-Hans\",\"url\":\"https:\/\/dcupqiu.club\/wp-content\/uploads\/\/2022\/04\/ww.png\",\"contentUrl\":\"https:\/\/dcupqiu.club\/wp-content\/uploads\/\/2022\/04\/ww.png\",\"width\":920,\"height\":700,\"caption\":\"\u79cb\u5586\"},\"logo\":{\"@id\":\"https:\/\/dcupqiu.club\/#personlogo\"},\"sameAs\":[\"http:\/\/dcupqiu.club\"],\"url\":\"https:\/\/dcupqiu.club\/?author=1\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\u4e09\u5929\u901f\u6210Vulkan(3)-Physical devices logical devices and queue familie - \u79cb\u5586\u306eSite","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/dcupqiu.club\/?p=708","og_locale":"zh_CN","og_type":"article","og_title":"\u4e09\u5929\u901f\u6210Vulkan(3)-Physical devices logical devices and queue familie - \u79cb\u5586\u306eSite","og_description":"\u5728\u521b\u5efa\u5b8c\u6210Vulkan\u540e\uff0c\u6211\u4eec\u9700\u8981\u5728\u8bbe\u5907\u4e0a\u5bfb\u627e\u4e00\u4e2a...","og_url":"https:\/\/dcupqiu.club\/?p=708","og_site_name":"\u79cb\u5586\u306eSite","article_published_time":"2022-04-04T08:48:15+00:00","article_modified_time":"2022-04-05T10:20:59+00:00","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"\u79cb\u5586","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"1 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebSite","@id":"https:\/\/dcupqiu.club\/#website","url":"https:\/\/dcupqiu.club\/","name":"\u79cb\u5586\u306eSite","description":"WwwwwW","publisher":{"@id":"https:\/\/dcupqiu.club\/#\/schema\/person\/33f847360b49873a92e0a1461d4d6a20"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/dcupqiu.club\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"WebPage","@id":"https:\/\/dcupqiu.club\/?p=708#webpage","url":"https:\/\/dcupqiu.club\/?p=708","name":"\u4e09\u5929\u901f\u6210Vulkan(3)-Physical devices logical devices and queue familie - \u79cb\u5586\u306eSite","isPartOf":{"@id":"https:\/\/dcupqiu.club\/#website"},"datePublished":"2022-04-04T08:48:15+00:00","dateModified":"2022-04-05T10:20:59+00:00","breadcrumb":{"@id":"https:\/\/dcupqiu.club\/?p=708#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/dcupqiu.club\/?p=708"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/dcupqiu.club\/?p=708#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/dcupqiu.club\/"},{"@type":"ListItem","position":2,"name":"\u4e09\u5929\u901f\u6210Vulkan(3)-Physical devices logical devices and queue familie"}]},{"@type":"Article","@id":"https:\/\/dcupqiu.club\/?p=708#article","isPartOf":{"@id":"https:\/\/dcupqiu.club\/?p=708#webpage"},"author":{"@id":"https:\/\/dcupqiu.club\/#\/schema\/person\/33f847360b49873a92e0a1461d4d6a20"},"headline":"\u4e09\u5929\u901f\u6210Vulkan(3)-Physical devices logical devices and queue familie","datePublished":"2022-04-04T08:48:15+00:00","dateModified":"2022-04-05T10:20:59+00:00","mainEntityOfPage":{"@id":"https:\/\/dcupqiu.club\/?p=708#webpage"},"wordCount":37,"publisher":{"@id":"https:\/\/dcupqiu.club\/#\/schema\/person\/33f847360b49873a92e0a1461d4d6a20"},"articleSection":["Vulkan","\u7a0b\u5e8f\u8bed\u8a00\u5b66\u4e60"],"inLanguage":"zh-Hans"},{"@type":["Person","Organization"],"@id":"https:\/\/dcupqiu.club\/#\/schema\/person\/33f847360b49873a92e0a1461d4d6a20","name":"\u79cb\u5586","image":{"@type":"ImageObject","@id":"https:\/\/dcupqiu.club\/#personlogo","inLanguage":"zh-Hans","url":"https:\/\/dcupqiu.club\/wp-content\/uploads\/\/2022\/04\/ww.png","contentUrl":"https:\/\/dcupqiu.club\/wp-content\/uploads\/\/2022\/04\/ww.png","width":920,"height":700,"caption":"\u79cb\u5586"},"logo":{"@id":"https:\/\/dcupqiu.club\/#personlogo"},"sameAs":["http:\/\/dcupqiu.club"],"url":"https:\/\/dcupqiu.club\/?author=1"}]}},"_links":{"self":[{"href":"https:\/\/dcupqiu.club\/index.php?rest_route=\/wp\/v2\/posts\/708","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dcupqiu.club\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dcupqiu.club\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dcupqiu.club\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dcupqiu.club\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=708"}],"version-history":[{"count":96,"href":"https:\/\/dcupqiu.club\/index.php?rest_route=\/wp\/v2\/posts\/708\/revisions"}],"predecessor-version":[{"id":1030,"href":"https:\/\/dcupqiu.club\/index.php?rest_route=\/wp\/v2\/posts\/708\/revisions\/1030"}],"wp:attachment":[{"href":"https:\/\/dcupqiu.club\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=708"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dcupqiu.club\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=708"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dcupqiu.club\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=708"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}