moved Swapchain's codes to SwapchainModule
This commit is contained in:
parent
173d3e075a
commit
c3a5518b38
@ -51,10 +51,6 @@ private:
|
|||||||
|
|
||||||
VkCommandBuffer CreateCommandBuffer(const AnsiString &);
|
VkCommandBuffer CreateCommandBuffer(const AnsiString &);
|
||||||
|
|
||||||
bool CreateSwapchainFBO(Swapchain *);
|
|
||||||
|
|
||||||
Swapchain *CreateSwapchain(const VkExtent2D &acquire_extent);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
friend class VulkanDeviceCreater;
|
friend class VulkanDeviceCreater;
|
||||||
|
@ -11,6 +11,8 @@ public:
|
|||||||
|
|
||||||
VkDevice device =VK_NULL_HANDLE;
|
VkDevice device =VK_NULL_HANDLE;
|
||||||
|
|
||||||
|
VkExtent2D extent;
|
||||||
|
|
||||||
VkSwapchainKHR swap_chain =VK_NULL_HANDLE;
|
VkSwapchainKHR swap_chain =VK_NULL_HANDLE;
|
||||||
|
|
||||||
uint32_t color_count =0;
|
uint32_t color_count =0;
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include<hgl/graph/VK.h>
|
#include<hgl/graph/VK.h>
|
||||||
|
#include<hgl/graph/VKDevice.h>
|
||||||
#include<hgl/type/IDName.h>
|
#include<hgl/type/IDName.h>
|
||||||
|
|
||||||
VK_NAMESPACE_BEGIN
|
VK_NAMESPACE_BEGIN
|
||||||
@ -20,6 +21,9 @@ public:
|
|||||||
~GraphModuleManager();
|
~GraphModuleManager();
|
||||||
|
|
||||||
GPUDevice * GetDevice ()noexcept{return device;} ///<取得GPU设备
|
GPUDevice * GetDevice ()noexcept{return device;} ///<取得GPU设备
|
||||||
|
VkDevice GetVkDevice (){return device->GetDevice();}
|
||||||
|
const GPUPhysicalDevice * GetPhysicalDevice (){return device->GetPhysicalDevice();} ///<取得物理设备
|
||||||
|
const GPUDeviceAttribute *GetDeviceAttribute (){return device->GetDeviceAttribute();} ///<取得设备属性
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取指定名称的模块
|
* 获取指定名称的模块
|
||||||
@ -68,7 +72,9 @@ public:
|
|||||||
|
|
||||||
GraphModuleManager *GetManager (){return module_manager;} ///<取得模块管理器
|
GraphModuleManager *GetManager (){return module_manager;} ///<取得模块管理器
|
||||||
GPUDevice * GetDevice (){return module_manager->GetDevice();} ///<取得GPU设备
|
GPUDevice * GetDevice (){return module_manager->GetDevice();} ///<取得GPU设备
|
||||||
GPUDeviceAttribute *GetDeviceAttribute();
|
VkDevice GetVkDevice (){return module_manager->GetVkDevice();} ///<取得VkDevice
|
||||||
|
const GPUPhysicalDevice * GetPhysicalDevice (){return module_manager->GetPhysicalDevice();} ///<取得物理设备
|
||||||
|
const GPUDeviceAttribute *GetDeviceAttribute (){return module_manager->GetDeviceAttribute();}///<取得设备属性
|
||||||
|
|
||||||
static const AnsiIDName *GetModuleName(){return nullptr;} ///<取得模块名称(标准通用的名称,比如Upscale,供通用模块使用)
|
static const AnsiIDName *GetModuleName(){return nullptr;} ///<取得模块名称(标准通用的名称,比如Upscale,供通用模块使用)
|
||||||
virtual const AnsiIDName *GetName()const{return &module_name;} ///<取得名称(完整的私有名称,比如FSR3Upscale,DLSS3Upscale)
|
virtual const AnsiIDName *GetName()const{return &module_name;} ///<取得名称(完整的私有名称,比如FSR3Upscale,DLSS3Upscale)
|
||||||
|
@ -10,6 +10,12 @@ class SwapchainModule:public GraphModule
|
|||||||
|
|
||||||
RTSwapchain *swapchain_rt=nullptr;
|
RTSwapchain *swapchain_rt=nullptr;
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
bool CreateSwapchainFBO(Swapchain *);
|
||||||
|
|
||||||
|
Swapchain *CreateSwapchain(const VkExtent2D &acquire_extent);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
GRAPH_MODULE_CONSTRUCT(Swapchain)
|
GRAPH_MODULE_CONSTRUCT(Swapchain)
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
#include<hgl/graph/VKDevice.h>
|
#include<hgl/graph/VKDevice.h>
|
||||||
#include<hgl/graph/VKDeviceAttribute.h>
|
#include<hgl/graph/VKDeviceAttribute.h>
|
||||||
#include<hgl/graph/VKPhysicalDevice.h>
|
#include<hgl/graph/VKPhysicalDevice.h>
|
||||||
|
#include<hgl/graph/module/SwapchainModule.h>
|
||||||
|
#include<hgl/graph/VKSwapchain.h>
|
||||||
#include<iostream>
|
#include<iostream>
|
||||||
|
|
||||||
VK_NAMESPACE_BEGIN
|
VK_NAMESPACE_BEGIN
|
||||||
@ -82,17 +84,17 @@ namespace
|
|||||||
}
|
}
|
||||||
}//namespace
|
}//namespace
|
||||||
|
|
||||||
bool GPUDevice::CreateSwapchainFBO(Swapchain *swapchain)
|
bool SwapchainModule::CreateSwapchainFBO(Swapchain *swapchain)
|
||||||
{
|
{
|
||||||
if(vkGetSwapchainImagesKHR(attr->device,swapchain->swap_chain,&(swapchain->color_count),nullptr)!=VK_SUCCESS)
|
if(vkGetSwapchainImagesKHR(swapchain->device,swapchain->swap_chain,&(swapchain->color_count),nullptr)!=VK_SUCCESS)
|
||||||
return(false);
|
return(false);
|
||||||
|
|
||||||
AutoDeleteArray<VkImage> sc_images(swapchain->color_count);
|
AutoDeleteArray<VkImage> sc_images(swapchain->color_count);
|
||||||
|
|
||||||
if(vkGetSwapchainImagesKHR(attr->device,swapchain->swap_chain,&(swapchain->color_count),sc_images)!=VK_SUCCESS)
|
if(vkGetSwapchainImagesKHR(swapchain->device,swapchain->swap_chain,&(swapchain->color_count),sc_images)!=VK_SUCCESS)
|
||||||
return(false);
|
return(false);
|
||||||
|
|
||||||
swapchain->sc_depth =CreateTexture2D(new SwapchainDepthTextureCreateInfo(attr->physical_device->GetDepthFormat(),swapchain->extent));
|
swapchain->sc_depth =CreateTexture2D(new SwapchainDepthTextureCreateInfo(GetPhysicalDevice()->GetDepthFormat(),swapchain->extent));
|
||||||
|
|
||||||
if(!swapchain->sc_depth)
|
if(!swapchain->sc_depth)
|
||||||
return(false);
|
return(false);
|
||||||
@ -134,14 +136,14 @@ bool GPUDevice::CreateSwapchainFBO(Swapchain *swapchain)
|
|||||||
return(true);
|
return(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
Swapchain *GPUDevice::CreateSwapchain(const VkExtent2D &acquire_extent)
|
Swapchain *SwapchainModule::CreateSwapchain(const VkExtent2D &acquire_extent)
|
||||||
{
|
{
|
||||||
Swapchain *swapchain=new Swapchain;
|
Swapchain *swapchain=new Swapchain;
|
||||||
|
|
||||||
swapchain->device =attr->device;
|
swapchain->device =GetVkDevice();
|
||||||
swapchain->extent =acquire_extent;
|
swapchain->extent =acquire_extent;
|
||||||
|
|
||||||
swapchain->swap_chain =CreateSwapChain(attr,acquire_extent);
|
swapchain->swap_chain =CreateSwapChain(GetDeviceAttribute(),acquire_extent);
|
||||||
|
|
||||||
if(swapchain->swap_chain)
|
if(swapchain->swap_chain)
|
||||||
if(CreateSwapchainFBO(swapchain))
|
if(CreateSwapchainFBO(swapchain))
|
||||||
|
@ -3,9 +3,5 @@
|
|||||||
|
|
||||||
VK_NAMESPACE_BEGIN
|
VK_NAMESPACE_BEGIN
|
||||||
|
|
||||||
GPUDeviceAttribute *GraphModule::GetDeviceAttribute()
|
|
||||||
{
|
|
||||||
return module_manager->GetDevice()->GetDeviceAttribute();
|
|
||||||
}
|
|
||||||
|
|
||||||
VK_NAMESPACE_END
|
VK_NAMESPACE_END
|
||||||
|
Loading…
x
Reference in New Issue
Block a user