更新XCBWindow支持新的结构

This commit is contained in:
hyzboy 2019-04-10 23:31:24 +08:00
parent b4ce1b6b50
commit ef52f5e7b8
3 changed files with 16 additions and 15 deletions

View File

@ -1,4 +1,4 @@
#include"RenderSurface.h" #include"RenderSurface.h"
VK_NAMESPACE_BEGIN VK_NAMESPACE_BEGIN
RenderSurface::RenderSurface(Window *w,VkInstance inst,VkPhysicalDevice pd) RenderSurface::RenderSurface(Window *w,VkInstance inst,VkPhysicalDevice pd)
@ -18,7 +18,7 @@ RenderSurface::RenderSurface(Window *w,VkInstance inst,VkPhysicalDevice pd)
{ {
uint32_t family_count; uint32_t family_count;
vkGetPhysicalDeviceQueueFamilyProperties(physical_device,&family_count,nullptr); vkGetPhysicalDeviceQueueFamilyProperties(physical_device,&family_count,nullptr);
family_properties.SetCount(family_count); family_properties.SetCount(family_count);
vkGetPhysicalDeviceQueueFamilyProperties(physical_device,&family_count,family_properties.GetData()); vkGetPhysicalDeviceQueueFamilyProperties(physical_device,&family_count,family_properties.GetData());
@ -66,7 +66,7 @@ RenderSurface::RenderSurface(Window *w,VkInstance inst,VkPhysicalDevice pd)
if(swapchain_extent.width<surface_caps.minImageExtent.width)swapchain_extent.width=surface_caps.minImageExtent.width;else if(swapchain_extent.width<surface_caps.minImageExtent.width)swapchain_extent.width=surface_caps.minImageExtent.width;else
if(swapchain_extent.width>surface_caps.maxImageExtent.width)swapchain_extent.width=surface_caps.maxImageExtent.width; if(swapchain_extent.width>surface_caps.maxImageExtent.width)swapchain_extent.width=surface_caps.maxImageExtent.width;
if(swapchain_extent.height<surface_caps.minImageExtent.height)swapchain_extent.height=surface_caps.minImageExtent.height;else if(swapchain_extent.height<surface_caps.minImageExtent.height)swapchain_extent.height=surface_caps.minImageExtent.height;else
if(swapchain_extent.height>surface_caps.maxImageExtent.height)swapchain_extent.height=surface_caps.maxImageExtent.height; if(swapchain_extent.height>surface_caps.maxImageExtent.height)swapchain_extent.height=surface_caps.maxImageExtent.height;
} }
else else
@ -150,7 +150,7 @@ CommandBuffer *RenderSurface::CreateCommandBuffer()
return(new CommandBuffer(device,cmd_pool,cmd_buf)); return(new CommandBuffer(device,cmd_pool,cmd_buf));
} }
bool RenderSurface::CreateDevice() bool RenderSurface::CreateDevice()
{ {
family_index=QueueFamilyProperties(VK_QUEUE_GRAPHICS_BIT); family_index=QueueFamilyProperties(VK_QUEUE_GRAPHICS_BIT);
@ -179,8 +179,9 @@ bool RenderSurface::CreateDevice()
create_info.pEnabledFeatures=nullptr; create_info.pEnabledFeatures=nullptr;
VkResult res=vkCreateDevice(physical_device,&create_info,nullptr,&device); VkResult res=vkCreateDevice(physical_device,&create_info,nullptr,&device);
if(res!=VK_SUCCESS) if(res!=VK_SUCCESS)
return(nullptr); return(false);
CreateCommandPool(); CreateCommandPool();
return(true); return(true);

View File

@ -71,7 +71,7 @@ RenderSurface *Instance::CreateRenderSurface(int pd_index)
VkPhysicalDevice pd; VkPhysicalDevice pd;
if(!physical_devices.Get(pd_index,pd)) if(!physical_devices.Get(pd_index,pd))
return(false); return(nullptr);
return(new RenderSurface(win,inst,pd)); return(new RenderSurface(win,inst,pd));
} }

View File

@ -111,23 +111,23 @@ namespace hgl
void Show()override{} void Show()override{}
void Hide()override{} void Hide()override{}
vulkan::Surface* CreateVulkanSurface(VkInstance vk_inst)const override VkSurfaceKHR CreateSurface(VkInstance vk_inst)const override
{ {
VkXcbSurfaceCreateInfoKHR createInfo = {}; VkXcbSurfaceCreateInfoKHR createInfo = {};
createInfo.sType = VK_STRUCTURE_TYPE_XCB_SURFACE_CREATE_INFO_KHR; createInfo.sType = VK_STRUCTURE_TYPE_XCB_SURFACE_CREATE_INFO_KHR;
createInfo.pNext = nullptr; createInfo.pNext = nullptr;
createInfo.connection = connection; createInfo.connection = connection;
createInfo.window = window; createInfo.window = window;
VkSurfaceKHR surface;
VkResult res = vkCreateXcbSurfaceKHR(info.inst, &createInfo, nullptr, &info.surface); VkSurfaceKHR surface;
if (res != VK_SUCCESS) VkResult res = vkCreateXcbSurfaceKHR(vk_inst, &createInfo, nullptr, &surface);
return(nullptr);
return(new vulkan::Surface(vk_inst,surface)); if (res != VK_SUCCESS)
} return(nullptr);
return(surface);
}
};//class XCBWindow:public Window };//class XCBWindow:public Window
Window *CreateRenderWindow(const UTF8String &win_name) Window *CreateRenderWindow(const UTF8String &win_name)