From 9ad7a3cd708f191d292f81a849a8c3eb96f2a9da Mon Sep 17 00:00:00 2001 From: HuYingzhuo Date: Fri, 19 Apr 2019 13:43:50 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0GetDeviceQueue=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=EF=BC=8C=EF=BC=8C=EF=BC=8C=EF=BC=8C=E4=BC=9A=E5=B4=A9?= =?UTF-8?q?=E6=BA=83(=E5=8E=9F=E5=9B=A0=E6=9C=AA=E7=9F=A5)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- example/Vulkan/CMakeLists.txt | 2 ++ example/Vulkan/VKDeviceAttribute.h | 3 +++ example/Vulkan/VKDeviceCreater.cpp | 12 ++++++++++++ 3 files changed, 17 insertions(+) diff --git a/example/Vulkan/CMakeLists.txt b/example/Vulkan/CMakeLists.txt index 93b0c440..429e50ee 100644 --- a/example/Vulkan/CMakeLists.txt +++ b/example/Vulkan/CMakeLists.txt @@ -23,6 +23,7 @@ SET(VULKAN_TEST_SOURCE_FILES main.cpp VKPipeline.cpp VKSemaphore.cpp VKFramebuffer.cpp + VKFence.cpp ) SET(VULKAN_TEST_HEADER_FILES VK.h @@ -42,6 +43,7 @@ SET(VULKAN_TEST_HEADER_FILES VK.h VKSemaphore.h VKPipeline.h VKFramebuffer.h + VKFence.h Window.h) SET(SHADER_FILES shader_compile.bat diff --git a/example/Vulkan/VKDeviceAttribute.h b/example/Vulkan/VKDeviceAttribute.h index 5667209a..29efde34 100644 --- a/example/Vulkan/VKDeviceAttribute.h +++ b/example/Vulkan/VKDeviceAttribute.h @@ -20,6 +20,9 @@ struct DeviceAttribute uint32_t graphics_family =ERROR_FAMILY_INDEX; uint32_t present_family =ERROR_FAMILY_INDEX; + VkQueue graphics_queue =nullptr; + VkQueue present_queue =nullptr; + List family_properties; List supports_present; diff --git a/example/Vulkan/VKDeviceCreater.cpp b/example/Vulkan/VKDeviceCreater.cpp index 0ed7f53f..b8f68091 100644 --- a/example/Vulkan/VKDeviceCreater.cpp +++ b/example/Vulkan/VKDeviceCreater.cpp @@ -64,6 +64,16 @@ namespace return nullptr; } + void GetDeviceQueue(DeviceAttribute *attr) + { + vkGetDeviceQueue(attr->device,attr->graphics_family,0,&attr->graphics_queue); + + if(attr->graphics_family==attr->present_family) + attr->present_queue=attr->graphics_queue; + else + vkGetDeviceQueue(attr->device,attr->present_family,0,&attr->present_queue); + } + VkCommandPool CreateCommandPool(VkDevice device,uint32_t graphics_family) { VkCommandPoolCreateInfo cmd_pool_info={}; @@ -327,6 +337,8 @@ Device *CreateRenderDevice(VkInstance inst,const PhysicalDevice *physical_device if(!rdc->device) return(nullptr); + GetDeviceQueue(rdc.attr); + rdc->cmd_pool=CreateCommandPool(rdc->device,rdc->graphics_family); if(!rdc->cmd_pool)