improve a few codes.

This commit is contained in:
2021-09-23 22:13:57 +08:00
parent 66c6072de4
commit b222c52cc2
6 changed files with 38 additions and 32 deletions

View File

@@ -5,25 +5,9 @@
#include<iostream>
VK_NAMESPACE_BEGIN
namespace
{
PFN_vkGetPhysicalDeviceSurfaceCapabilities2KHR vkGetPhysicalDeviceSurfaceCapabilities2KHR = NULL;
PFN_vkGetPhysicalDeviceSurfaceFormats2KHR vkGetPhysicalDeviceSurfaceFormats2KHR = NULL;
PFN_vkSetHdrMetadataEXT vkSetHdrMetadataEXT = NULL;
PFN_vkAcquireFullScreenExclusiveModeEXT vkAcquireFullScreenExclusiveModeEXT = NULL;
PFN_vkReleaseFullScreenExclusiveModeEXT vkReleaseFullScreenExclusiveModeEXT = NULL;
}
bool InitPhysicsDeviceSurfaceAPI2()
{
return(false);
}
void SavePipelineCacheData(VkDevice device,VkPipelineCache cache,const VkPhysicalDeviceProperties &pdp);
GPUDeviceAttribute::GPUDeviceAttribute(VkInstance inst,const GPUPhysicalDevice *pd,VkSurfaceKHR s)
GPUDeviceAttribute::GPUDeviceAttribute(VulkanInstance *inst,const GPUPhysicalDevice *pd,VkSurfaceKHR s)
{
instance=inst;
physical_device=pd;
@@ -50,7 +34,7 @@ GPUDeviceAttribute::~GPUDeviceAttribute()
vkDestroyDevice(device,nullptr);
if(surface)
vkDestroySurfaceKHR(instance,surface,nullptr);
instance->DestroySurface(surface);
}
bool GPUDeviceAttribute::CheckMemoryType(uint32_t typeBits,VkMemoryPropertyFlags properties,uint32_t *typeIndex) const

View File

@@ -371,7 +371,7 @@ namespace
constexpr size_t VK_DRIVER_ID_RANGE_SIZE=VK_DRIVER_ID_END_RANGE-VK_DRIVER_ID_BEGIN_RANGE+1;
#endif//VK_DRIVER_ID_RANGE_SIZE
GPUDevice *CreateRenderDevice(VkInstance inst,const GPUPhysicalDevice *physical_device,VkSurfaceKHR surface,const VkExtent2D &extent)
GPUDevice *CreateRenderDevice(VulkanInstance *inst,const GPUPhysicalDevice *physical_device,VkSurfaceKHR surface,const VkExtent2D &extent)
{
#ifdef _DEBUG
{
@@ -387,7 +387,7 @@ GPUDevice *CreateRenderDevice(VkInstance inst,const GPUPhysicalDevice *physical_
if(device_attr->graphics_family==ERROR_FAMILY_INDEX)
return(nullptr);
device_attr->device=CreateDevice(inst,physical_device,device_attr->graphics_family);
device_attr->device=CreateDevice(*inst,physical_device,device_attr->graphics_family);
if(!device_attr->device)
return(nullptr);
@@ -436,7 +436,7 @@ GPUDevice *CreateRenderDevice(VulkanInstance *inst,Window *win,const GPUPhysical
extent.width=win->GetWidth();
extent.height=win->GetHeight();
GPUDevice *device=CreateRenderDevice(*inst,pd,surface,extent);
GPUDevice *device=CreateRenderDevice(inst,pd,surface,extent);
if(!device)
{

View File

@@ -87,6 +87,8 @@ VulkanInstance::VulkanInstance(VkInstance i,VKDebugOut *out)
delete[] pd_list;
}
GetDeviceProcAddr = (PFN_vkGetDeviceProcAddr)vkGetInstanceProcAddr(inst, "vkGetDeviceProcAddr");
}
VulkanInstance::~VulkanInstance()
@@ -105,4 +107,9 @@ const GPUPhysicalDevice *VulkanInstance::GetDevice(VkPhysicalDeviceType type)con
return(nullptr);
}
void VulkanInstance::DestroySurface(VkSurfaceKHR surface)
{
vkDestroySurfaceKHR(inst,surface,nullptr);
}
VK_NAMESPACE_END