moved Swapchain's codes to SwapchainModule

This commit is contained in:
hyzboy 2024-11-06 00:34:23 +08:00
parent 173d3e075a
commit c3a5518b38
6 changed files with 27 additions and 19 deletions

View File

@ -51,10 +51,6 @@ private:
VkCommandBuffer CreateCommandBuffer(const AnsiString &);
bool CreateSwapchainFBO(Swapchain *);
Swapchain *CreateSwapchain(const VkExtent2D &acquire_extent);
private:
friend class VulkanDeviceCreater;

View File

@ -11,6 +11,8 @@ public:
VkDevice device =VK_NULL_HANDLE;
VkExtent2D extent;
VkSwapchainKHR swap_chain =VK_NULL_HANDLE;
uint32_t color_count =0;

View File

@ -1,6 +1,7 @@
#pragma once
#include<hgl/graph/VK.h>
#include<hgl/graph/VKDevice.h>
#include<hgl/type/IDName.h>
VK_NAMESPACE_BEGIN
@ -19,7 +20,10 @@ public:
GraphModuleManager(GPUDevice *dev){device=dev;}
~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();} ///<取得设备属性
/**
*
@ -66,9 +70,11 @@ public:
virtual const bool IsRender(){return false;} ///<是否为渲染模块
GraphModuleManager *GetManager(){return module_manager;} ///<取得模块管理器
GPUDevice * GetDevice(){return module_manager->GetDevice();} ///<取得GPU设备
GPUDeviceAttribute *GetDeviceAttribute();
GraphModuleManager *GetManager (){return module_manager;} ///<取得模块管理器
GPUDevice * GetDevice (){return module_manager->GetDevice();} ///<取得GPU设备
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供通用模块使用)
virtual const AnsiIDName *GetName()const{return &module_name;} ///<取得名称(完整的私有名称比如FSR3Upscale,DLSS3Upscale)

View File

@ -10,6 +10,12 @@ class SwapchainModule:public GraphModule
RTSwapchain *swapchain_rt=nullptr;
private:
bool CreateSwapchainFBO(Swapchain *);
Swapchain *CreateSwapchain(const VkExtent2D &acquire_extent);
public:
GRAPH_MODULE_CONSTRUCT(Swapchain)

View File

@ -1,6 +1,8 @@
#include<hgl/graph/VKDevice.h>
#include<hgl/graph/VKDeviceAttribute.h>
#include<hgl/graph/VKPhysicalDevice.h>
#include<hgl/graph/module/SwapchainModule.h>
#include<hgl/graph/VKSwapchain.h>
#include<iostream>
VK_NAMESPACE_BEGIN
@ -82,17 +84,17 @@ 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);
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);
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)
return(false);
@ -134,14 +136,14 @@ bool GPUDevice::CreateSwapchainFBO(Swapchain *swapchain)
return(true);
}
Swapchain *GPUDevice::CreateSwapchain(const VkExtent2D &acquire_extent)
Swapchain *SwapchainModule::CreateSwapchain(const VkExtent2D &acquire_extent)
{
Swapchain *swapchain=new Swapchain;
swapchain->device =attr->device;
swapchain->device =GetVkDevice();
swapchain->extent =acquire_extent;
swapchain->swap_chain =CreateSwapChain(attr,acquire_extent);
swapchain->swap_chain =CreateSwapChain(GetDeviceAttribute(),acquire_extent);
if(swapchain->swap_chain)
if(CreateSwapchainFBO(swapchain))

View File

@ -3,9 +3,5 @@
VK_NAMESPACE_BEGIN
GPUDeviceAttribute *GraphModule::GetDeviceAttribute()
{
return module_manager->GetDevice()->GetDeviceAttribute();
}
VK_NAMESPACE_END