删除VKPhysicalDevice/VKSurface/VKDevice封装,建立新的RenderSurface
This commit is contained in:
parent
5c14902e79
commit
b4ce1b6b50
@ -7,10 +7,8 @@ ENDIF()
|
||||
|
||||
add_executable(VulkanTest main.cpp
|
||||
${RENDER_WINDOW_SOURCE}
|
||||
VKInstance.cpp
|
||||
VKSurface.cpp
|
||||
VKPhysicalDevice.cpp
|
||||
VKDevice.cpp
|
||||
VKCommandBuffer.cpp)
|
||||
VKInstance.cpp
|
||||
VKCommandBuffer.cpp
|
||||
RenderSurface.cpp)
|
||||
|
||||
target_link_libraries(VulkanTest PRIVATE ${ULRE} ${VULKAN_LIB} ${RENDER_WINDOW_LIBRARY})
|
||||
|
188
example/Vulkan/RenderSurface.cpp
Normal file
188
example/Vulkan/RenderSurface.cpp
Normal file
@ -0,0 +1,188 @@
|
||||
#include"RenderSurface.h"
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
RenderSurface::RenderSurface(Window *w,VkInstance inst,VkPhysicalDevice pd)
|
||||
{
|
||||
win=w;
|
||||
instance=inst;
|
||||
physical_device=pd;
|
||||
family_index=-1;
|
||||
device=nullptr;
|
||||
cmd_pool=nullptr;
|
||||
|
||||
vkGetPhysicalDeviceFeatures(physical_device,&features);
|
||||
vkGetPhysicalDeviceProperties(physical_device,&properties);
|
||||
vkGetPhysicalDeviceMemoryProperties(physical_device,&memory_properties);
|
||||
|
||||
surface=win->CreateSurface(inst);
|
||||
|
||||
{
|
||||
uint32_t family_count;
|
||||
vkGetPhysicalDeviceQueueFamilyProperties(physical_device,&family_count,nullptr);
|
||||
family_properties.SetCount(family_count);
|
||||
vkGetPhysicalDeviceQueueFamilyProperties(physical_device,&family_count,family_properties.GetData());
|
||||
|
||||
{
|
||||
supports_present.SetCount(family_count);
|
||||
VkBool32 *sp=supports_present.GetData();
|
||||
for(uint32_t i=0; i<family_count; i++)
|
||||
{
|
||||
vkGetPhysicalDeviceSurfaceSupportKHR(physical_device,i,surface,sp);
|
||||
++sp;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
uint32_t format_count;
|
||||
if(vkGetPhysicalDeviceSurfaceFormatsKHR(physical_device,surface,&format_count,nullptr)==VK_SUCCESS)
|
||||
{
|
||||
surface_formts.SetCount(format_count);
|
||||
|
||||
if(vkGetPhysicalDeviceSurfaceFormatsKHR(physical_device,surface,&format_count,surface_formts.GetData())!=VK_SUCCESS)
|
||||
surface_formts.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
uint32_t mode_count;
|
||||
if(vkGetPhysicalDeviceSurfacePresentModesKHR(physical_device,surface,&mode_count,nullptr)==VK_SUCCESS)
|
||||
{
|
||||
present_modes.SetCount(mode_count);
|
||||
if(vkGetPhysicalDeviceSurfacePresentModesKHR(physical_device,surface,&mode_count,present_modes.GetData())!=VK_SUCCESS)
|
||||
present_modes.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
vkGetPhysicalDeviceSurfaceCapabilitiesKHR(physical_device,surface,&surface_caps);
|
||||
|
||||
VkExtent2D swapchain_extent;
|
||||
if(surface_caps.currentExtent.width==0xFFFFFFFF)
|
||||
{
|
||||
swapchain_extent.width=win->GetWidth();
|
||||
swapchain_extent.height=win->GetHeight();
|
||||
|
||||
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.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;
|
||||
}
|
||||
else
|
||||
{
|
||||
swapchain_extent=surface_caps.currentExtent;
|
||||
}
|
||||
}
|
||||
|
||||
CreateDevice();
|
||||
}
|
||||
|
||||
RenderSurface::~RenderSurface()
|
||||
{
|
||||
if(device)
|
||||
{
|
||||
if(cmd_pool)
|
||||
vkDestroyCommandPool(device,cmd_pool,nullptr);
|
||||
|
||||
vkDestroyDevice(device,nullptr);
|
||||
}
|
||||
|
||||
if(surface)
|
||||
vkDestroySurfaceKHR(instance,surface,nullptr);
|
||||
}
|
||||
|
||||
int RenderSurface::QueueFamilyProperties(VkQueueFlags flag) const
|
||||
{
|
||||
const int count=family_properties.GetCount();
|
||||
|
||||
if(count<=0)
|
||||
return(-1);
|
||||
|
||||
VkBool32*sp=supports_present.GetData();
|
||||
VkQueueFamilyProperties*fp=family_properties.GetData();
|
||||
for(int i=0;i<count;i++)
|
||||
{
|
||||
if((*sp)
|
||||
&&(fp->queueFlags&flag))
|
||||
return i;
|
||||
|
||||
++sp;
|
||||
++fp;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
bool RenderSurface::CreateCommandPool()
|
||||
{
|
||||
VkCommandPoolCreateInfo cmd_pool_info={};
|
||||
|
||||
cmd_pool_info.sType=VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO;
|
||||
cmd_pool_info.pNext=NULL;
|
||||
cmd_pool_info.queueFamilyIndex=family_index;
|
||||
cmd_pool_info.flags=0;
|
||||
|
||||
VkResult res=vkCreateCommandPool(device,&cmd_pool_info,nullptr,&cmd_pool);
|
||||
|
||||
return(res==VK_SUCCESS);
|
||||
}
|
||||
|
||||
CommandBuffer *RenderSurface::CreateCommandBuffer()
|
||||
{
|
||||
if(!cmd_pool)
|
||||
return(nullptr);
|
||||
|
||||
VkCommandBufferAllocateInfo cmd={};
|
||||
cmd.sType=VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO;
|
||||
cmd.pNext=nullptr;
|
||||
cmd.commandPool=cmd_pool;
|
||||
cmd.level=VK_COMMAND_BUFFER_LEVEL_PRIMARY;
|
||||
cmd.commandBufferCount=1;
|
||||
|
||||
VkCommandBuffer cmd_buf;
|
||||
|
||||
VkResult res=vkAllocateCommandBuffers(device,&cmd,&cmd_buf);
|
||||
|
||||
if(res!=VK_SUCCESS)
|
||||
return(nullptr);
|
||||
|
||||
return(new CommandBuffer(device,cmd_pool,cmd_buf));
|
||||
}
|
||||
|
||||
bool RenderSurface::CreateDevice()
|
||||
{
|
||||
family_index=QueueFamilyProperties(VK_QUEUE_GRAPHICS_BIT);
|
||||
|
||||
if(family_index==-1)
|
||||
return(false);
|
||||
|
||||
float queue_priorities[1]={0.0};
|
||||
|
||||
VkDeviceQueueCreateInfo queue_info;
|
||||
queue_info.queueFamilyIndex=family_index;
|
||||
queue_info.sType=VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO;
|
||||
queue_info.pNext=nullptr;
|
||||
queue_info.queueCount=1;
|
||||
queue_info.pQueuePriorities=queue_priorities;
|
||||
|
||||
VkDeviceCreateInfo create_info={};
|
||||
const char *ext_list[1]={VK_KHR_SWAPCHAIN_EXTENSION_NAME};
|
||||
create_info.sType=VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO;
|
||||
create_info.pNext=nullptr;
|
||||
create_info.queueCreateInfoCount=1;
|
||||
create_info.pQueueCreateInfos=&queue_info;
|
||||
create_info.enabledExtensionCount=1;
|
||||
create_info.ppEnabledExtensionNames=ext_list;
|
||||
create_info.enabledLayerCount=0;
|
||||
create_info.ppEnabledLayerNames=nullptr;
|
||||
create_info.pEnabledFeatures=nullptr;
|
||||
|
||||
VkResult res=vkCreateDevice(physical_device,&create_info,nullptr,&device);
|
||||
if(res!=VK_SUCCESS)
|
||||
return(nullptr);
|
||||
|
||||
CreateCommandPool();
|
||||
return(true);
|
||||
}
|
||||
VK_NAMESPACE_END
|
52
example/Vulkan/RenderSurface.h
Normal file
52
example/Vulkan/RenderSurface.h
Normal file
@ -0,0 +1,52 @@
|
||||
#ifndef HGL_GRAPH_RENDER_SURFACE_INCLUDE
|
||||
#define HGL_GRAPH_RENDER_SURFACE_INCLUDE
|
||||
|
||||
#include<hgl/type/List.h>
|
||||
#include"VK.h"
|
||||
#include"Window.h"
|
||||
#include"VKCommandBuffer.h"
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
class RenderSurface
|
||||
{
|
||||
Window *win;
|
||||
VkInstance instance;
|
||||
VkPhysicalDevice physical_device;
|
||||
VkSurfaceKHR surface;
|
||||
|
||||
VkPhysicalDeviceFeatures features;
|
||||
VkPhysicalDeviceProperties properties;
|
||||
VkPhysicalDeviceMemoryProperties memory_properties;
|
||||
|
||||
List<VkQueueFamilyProperties> family_properties;
|
||||
List<VkBool32> supports_present;
|
||||
|
||||
List<VkSurfaceFormatKHR> surface_formts;
|
||||
VkSurfaceCapabilitiesKHR surface_caps;
|
||||
List<VkPresentModeKHR> present_modes;
|
||||
|
||||
uint32_t family_index;
|
||||
VkDevice device;
|
||||
VkCommandPool cmd_pool; ///<命令池,用于创建命令缓冲区。由于不知道创建多个是否有好处,所以暂时设计为一个设备只有一个。
|
||||
|
||||
protected:
|
||||
|
||||
int QueueFamilyProperties(VkQueueFlags) const;
|
||||
|
||||
bool CreateDevice();
|
||||
bool CreateCommandPool();
|
||||
|
||||
public:
|
||||
|
||||
RenderSurface(Window *,VkInstance,VkPhysicalDevice);
|
||||
virtual ~RenderSurface();
|
||||
|
||||
VkPhysicalDevice GetPhysicalDevice() { return physical_device; }
|
||||
VkSurfaceKHR GetSurface() { return surface; }
|
||||
|
||||
public:
|
||||
|
||||
CommandBuffer *CreateCommandBuffer();
|
||||
};//class RenderSurface
|
||||
VK_NAMESPACE_END
|
||||
#endif//HGL_GRAPH_RENDER_SURFACE_INCLUDE
|
@ -1,53 +0,0 @@
|
||||
#include"VKDevice.h"
|
||||
#include"VKCommandBuffer.h"
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
Device::Device(VkDevice dev,int family_index)
|
||||
{
|
||||
device=dev;
|
||||
|
||||
cmd_pool=nullptr;
|
||||
|
||||
if(!device)
|
||||
return;
|
||||
|
||||
{
|
||||
VkCommandPoolCreateInfo cmd_pool_info = {};
|
||||
|
||||
cmd_pool_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO;
|
||||
cmd_pool_info.pNext = NULL;
|
||||
cmd_pool_info.queueFamilyIndex = family_index;
|
||||
cmd_pool_info.flags = 0;
|
||||
|
||||
VkResult res = vkCreateCommandPool(device, &cmd_pool_info, nullptr, &cmd_pool);
|
||||
}
|
||||
}
|
||||
|
||||
Device::~Device()
|
||||
{
|
||||
vkDestroyCommandPool(device,cmd_pool,nullptr);
|
||||
vkDestroyDevice(device,nullptr);
|
||||
}
|
||||
|
||||
CommandBuffer *Device::CreateCommandBuffer()
|
||||
{
|
||||
if(!cmd_pool)
|
||||
return(nullptr);
|
||||
|
||||
VkCommandBufferAllocateInfo cmd = {};
|
||||
cmd.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO;
|
||||
cmd.pNext = nullptr;
|
||||
cmd.commandPool = cmd_pool;
|
||||
cmd.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY;
|
||||
cmd.commandBufferCount = 1;
|
||||
|
||||
VkCommandBuffer cmd_buf;
|
||||
|
||||
VkResult res = vkAllocateCommandBuffers(device, &cmd, &cmd_buf);
|
||||
|
||||
if(res!=VK_SUCCESS)
|
||||
return(nullptr);
|
||||
|
||||
return(new CommandBuffer(device,cmd_pool,cmd_buf));
|
||||
}
|
||||
VK_NAMESPACE_END
|
@ -1,27 +0,0 @@
|
||||
#ifndef HGL_GRAPH_VULKAN_DEVICE_INCLUDE
|
||||
#define HGL_GRAPH_VULKAN_DEVICE_INCLUDE
|
||||
|
||||
#include"VK.h"
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
|
||||
class CommandBuffer;
|
||||
|
||||
/**
|
||||
* Vulkan设备对象封装
|
||||
*/
|
||||
class Device
|
||||
{
|
||||
VkDevice device;
|
||||
VkCommandPool cmd_pool; ///<命令池,用于创建命令缓冲区。由于不知道创建多个是否有好处,所以暂时设计为一个设备只有一个。
|
||||
|
||||
public:
|
||||
|
||||
Device(VkDevice,int);
|
||||
virtual ~Device();
|
||||
|
||||
CommandBuffer *CreateCommandBuffer();
|
||||
};//class Device
|
||||
VK_NAMESPACE_END
|
||||
|
||||
#endif//HGL_GRAPH_VULKAN_DEVICE_INCLUDE
|
@ -59,22 +59,21 @@ bool Instance::Init()
|
||||
if(res!=VK_SUCCESS)
|
||||
return(false);
|
||||
|
||||
VkPhysicalDevice *pd_list=new VkPhysicalDevice[gpu_count];
|
||||
physical_devices.SetCount(gpu_count);
|
||||
vkEnumeratePhysicalDevices(inst, &gpu_count, pd_list);
|
||||
|
||||
for(uint32_t i=0;i<gpu_count;i++)
|
||||
physical_devices.Add(new PhysicalDevice(pd_list[i]));
|
||||
|
||||
delete[] pd_list;
|
||||
vkEnumeratePhysicalDevices(inst, &gpu_count,physical_devices.GetData());
|
||||
}
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
Surface* Instance::CreateSurface()
|
||||
RenderSurface *Instance::CreateRenderSurface(int pd_index)
|
||||
{
|
||||
return win->CreateVulkanSurface(inst);
|
||||
VkPhysicalDevice pd;
|
||||
|
||||
if(!physical_devices.Get(pd_index,pd))
|
||||
return(false);
|
||||
|
||||
return(new RenderSurface(win,inst,pd));
|
||||
}
|
||||
|
||||
VK_NAMESPACE_END
|
||||
|
@ -4,9 +4,7 @@
|
||||
#include<hgl/type/BaseString.h>
|
||||
#include<hgl/type/List.h>
|
||||
#include"Window.h"
|
||||
#include"VK.h"
|
||||
#include"VKSurface.h"
|
||||
#include"VKPhysicalDevice.h"
|
||||
#include"RenderSurface.h"
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
class Instance
|
||||
@ -20,7 +18,7 @@ VK_NAMESPACE_BEGIN
|
||||
|
||||
VkInstance inst;
|
||||
|
||||
ObjectList<PhysicalDevice> physical_devices;
|
||||
List<VkPhysicalDevice> physical_devices;
|
||||
|
||||
private:
|
||||
|
||||
@ -33,9 +31,9 @@ VK_NAMESPACE_BEGIN
|
||||
|
||||
virtual bool Init();
|
||||
|
||||
const ObjectList<PhysicalDevice> & GetDeviceList()const{return physical_devices;}
|
||||
const List<VkPhysicalDevice> & GetDeviceList()const{return physical_devices;}
|
||||
|
||||
virtual Surface *CreateSurface();
|
||||
RenderSurface *CreateRenderSurface(int pd_index=0);
|
||||
};//class Instance
|
||||
VK_NAMESPACE_END
|
||||
#endif//HGL_GRAPH_VULKAN_INSTANCE_INCLUDE
|
||||
|
@ -1,83 +0,0 @@
|
||||
#include"VKPhysicalDevice.h"
|
||||
#include"VKDevice.h"
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
|
||||
PhysicalDevice::PhysicalDevice(VkPhysicalDevice pd)
|
||||
{
|
||||
physical_device=pd;
|
||||
|
||||
if(!pd)return;
|
||||
|
||||
vkGetPhysicalDeviceFeatures(physical_device,&features);
|
||||
vkGetPhysicalDeviceProperties(physical_device,&properties);
|
||||
vkGetPhysicalDeviceMemoryProperties(physical_device,&memory_properties);
|
||||
|
||||
{
|
||||
uint32_t family_count;
|
||||
vkGetPhysicalDeviceQueueFamilyProperties(physical_device,&family_count,nullptr);
|
||||
family_properties.SetCount(family_count);
|
||||
vkGetPhysicalDeviceQueueFamilyProperties(physical_device,&family_count,family_properties.GetData());
|
||||
}
|
||||
}
|
||||
|
||||
PhysicalDevice::~PhysicalDevice()
|
||||
{
|
||||
}
|
||||
|
||||
int PhysicalDevice::QueueFamilyProperties(VkQueueFlags flag) const
|
||||
{
|
||||
const int count=family_properties.GetCount();
|
||||
|
||||
if(count<=0)
|
||||
return(-1);
|
||||
|
||||
VkQueueFamilyProperties *fp=family_properties.GetData();
|
||||
for(int i=0;i<count;i++)
|
||||
{
|
||||
if(fp->queueFlags&flag)
|
||||
return i;
|
||||
|
||||
++fp;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
Device *PhysicalDevice::CreateGraphicsDevice() const
|
||||
{
|
||||
const int index=QueueFamilyProperties(VK_QUEUE_GRAPHICS_BIT);
|
||||
|
||||
if(index==-1)
|
||||
return(nullptr);
|
||||
|
||||
float queue_priorities[1] = {0.0};
|
||||
|
||||
VkDeviceQueueCreateInfo queue_info;
|
||||
queue_info.queueFamilyIndex=index;
|
||||
queue_info.sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO;
|
||||
queue_info.pNext = nullptr;
|
||||
queue_info.queueCount = 1;
|
||||
queue_info.pQueuePriorities = queue_priorities;
|
||||
|
||||
VkDeviceCreateInfo create_info = {};
|
||||
const char *ext_list[1]={VK_KHR_SWAPCHAIN_EXTENSION_NAME};
|
||||
create_info.sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO;
|
||||
create_info.pNext = nullptr;
|
||||
create_info.queueCreateInfoCount = 1;
|
||||
create_info.pQueueCreateInfos = &queue_info;
|
||||
create_info.enabledExtensionCount = 1;
|
||||
create_info.ppEnabledExtensionNames = ext_list;
|
||||
create_info.enabledLayerCount = 0;
|
||||
create_info.ppEnabledLayerNames = nullptr;
|
||||
create_info.pEnabledFeatures = nullptr;
|
||||
|
||||
VkDevice device;
|
||||
VkResult res = vkCreateDevice(physical_device, &create_info, nullptr, &device);
|
||||
if(res != VK_SUCCESS)
|
||||
return(nullptr);
|
||||
|
||||
return(new Device(device,index));
|
||||
}
|
||||
|
||||
VK_NAMESPACE_END
|
@ -1,34 +0,0 @@
|
||||
#ifndef HGL_GRAPH_VULKAN_PHYSICAL_DEVICE_INCLUDE
|
||||
#define HGL_GRAPH_VULKAN_PHYSICAL_DEVICE_INCLUDE
|
||||
|
||||
#include"VK.h"
|
||||
#include<hgl/type/List.h>
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
|
||||
class Device;
|
||||
|
||||
/**
|
||||
* Vulkan物理设备对象封装<br>
|
||||
* 注:这个设备可能是图形设备,也可能是计算设备等,我们暂时只支持图形设备
|
||||
*/
|
||||
class PhysicalDevice
|
||||
{
|
||||
VkPhysicalDevice physical_device;
|
||||
|
||||
VkPhysicalDeviceFeatures features;
|
||||
VkPhysicalDeviceProperties properties;
|
||||
VkPhysicalDeviceMemoryProperties memory_properties;
|
||||
|
||||
List<VkQueueFamilyProperties> family_properties;
|
||||
int QueueFamilyProperties(VkQueueFlags) const;
|
||||
|
||||
public:
|
||||
|
||||
PhysicalDevice(VkPhysicalDevice pd);
|
||||
~PhysicalDevice();
|
||||
|
||||
Device *CreateGraphicsDevice()const; ///<创建一个图形设备
|
||||
};//class PhysicalDevice
|
||||
VK_NAMESPACE_END
|
||||
#endif//HGL_GRAPH_VULKAN_PHYSICAL_DEVICE_INCLUDE
|
@ -1,8 +0,0 @@
|
||||
#include"VKSurface.h"
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
Surface::~Surface()
|
||||
{
|
||||
vkDestroySurfaceKHR(instance, surface, nullptr);
|
||||
}
|
||||
VK_NAMESPACE_END
|
@ -1,25 +0,0 @@
|
||||
#ifndef HGL_GRAPH_VULKAN_SURFACE_INCLUDE
|
||||
#define HGL_GRAPH_VULKAN_SURFACE_INCLUDE
|
||||
|
||||
#include"VK.h"
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
|
||||
class Surface
|
||||
{
|
||||
VkInstance instance;
|
||||
VkSurfaceKHR surface;
|
||||
|
||||
public:
|
||||
|
||||
Surface(VkInstance inst,VkSurfaceKHR surf)
|
||||
{
|
||||
instance = inst;
|
||||
surface = surf;
|
||||
}
|
||||
|
||||
virtual ~Surface();
|
||||
};//class Surface
|
||||
|
||||
VK_NAMESPACE_END
|
||||
#endif//HGL_GRAPH_VULKAN_SURFACE_INCLUDE
|
@ -173,7 +173,7 @@ namespace hgl
|
||||
UpdateWindow(win_hwnd);
|
||||
}
|
||||
|
||||
vulkan::Surface* CreateVulkanSurface(VkInstance vk_inst)const override
|
||||
VkSurfaceKHR CreateSurface(VkInstance vk_inst)const override
|
||||
{
|
||||
VkWin32SurfaceCreateInfoKHR createInfo = {};
|
||||
createInfo.sType = VK_STRUCTURE_TYPE_WIN32_SURFACE_CREATE_INFO_KHR;
|
||||
@ -188,7 +188,7 @@ namespace hgl
|
||||
if (res != VK_SUCCESS)
|
||||
return(nullptr);
|
||||
|
||||
return(new vulkan::Surface(vk_inst,surface));
|
||||
return(surface);
|
||||
}
|
||||
};//class WinWindow :public Window
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
#define HGL_GRAPH_WINDOW_INCLUDE
|
||||
|
||||
#include<hgl/type/BaseString.h>
|
||||
#include"VKSurface.h"
|
||||
#include"VK.h"
|
||||
namespace hgl
|
||||
{
|
||||
namespace graph
|
||||
@ -38,7 +38,7 @@ namespace hgl
|
||||
virtual void Show()=0;
|
||||
virtual void Hide()=0;
|
||||
|
||||
virtual vulkan::Surface *CreateVulkanSurface(VkInstance)const = 0;
|
||||
virtual VkSurfaceKHR CreateSurface(VkInstance)const = 0;
|
||||
};//class Window
|
||||
|
||||
Window *CreateRenderWindow(const OSString &win_name);
|
||||
|
@ -1,9 +1,5 @@
|
||||
#include"VK.h"
|
||||
#include"Window.h"
|
||||
#include"VKInstance.h"
|
||||
#include"VKSurface.h"
|
||||
#include"VKDevice.h"
|
||||
#include"VKCommandBuffer.h"
|
||||
#include"Window.h"
|
||||
|
||||
using namespace hgl;
|
||||
using namespace hgl::graph;
|
||||
@ -22,19 +18,13 @@ int main(int,char **)
|
||||
return(-1);
|
||||
}
|
||||
|
||||
vulkan::Surface *surface = inst.CreateSurface();
|
||||
vulkan::RenderSurface *render=inst.CreateRenderSurface();
|
||||
vulkan::CommandBuffer *cmd_buf=render->CreateCommandBuffer();
|
||||
|
||||
const ObjectList<vulkan::PhysicalDevice> &device_list=inst.GetDeviceList();
|
||||
|
||||
vulkan::PhysicalDevice *pd=device_list[0];
|
||||
|
||||
vulkan::Device *dev=pd->CreateGraphicsDevice();
|
||||
|
||||
vulkan::CommandBuffer *cmd_buf=dev->CreateCommandBuffer();
|
||||
|
||||
delete surface;
|
||||
delete cmd_buf;
|
||||
delete dev;
|
||||
delete render;
|
||||
delete win;
|
||||
|
||||
return 0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user