all compile OK! but 100% can't run.
This commit is contained in:
parent
64e8410f3f
commit
adc3c5bd81
@ -67,16 +67,6 @@ public:
|
||||
|
||||
DebugUtils * GetDebugUtils (){return attr->debug_utils;}
|
||||
|
||||
public:
|
||||
|
||||
bool Resize (const VkExtent2D &);
|
||||
bool Resize (const uint32_t &w,const uint32_t &h)
|
||||
{
|
||||
VkExtent2D extent={w,h};
|
||||
|
||||
return Resize(extent);
|
||||
}
|
||||
|
||||
public: //内存相关
|
||||
|
||||
DeviceMemory *CreateMemory(const VkMemoryRequirements &,const uint32_t properties);
|
||||
|
@ -32,7 +32,7 @@ protected:
|
||||
|
||||
protected:
|
||||
|
||||
friend class GPUDevice;
|
||||
friend class TextureManager;
|
||||
|
||||
RenderTarget(DeviceQueue *,Semaphore *);
|
||||
RenderTarget(DeviceQueue *,Semaphore *,RenderPass *_rp,Framebuffer *_fb,Texture2D **color_texture_list,const uint32_t color_count,Texture2D *depth_texture);
|
||||
|
@ -10,9 +10,15 @@ struct Swapchain
|
||||
public:
|
||||
|
||||
VkDevice device =VK_NULL_HANDLE;
|
||||
|
||||
|
||||
VkExtent2D extent;
|
||||
VkSurfaceTransformFlagBitsKHR transform;
|
||||
|
||||
VkSwapchainKHR swap_chain =VK_NULL_HANDLE;
|
||||
|
||||
VkSurfaceFormatKHR surface_format;
|
||||
VkFormat depth_format;
|
||||
|
||||
uint32_t color_count =0;
|
||||
|
||||
Texture2D ** sc_color =nullptr;
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
#include<hgl/type/StrChar.h>
|
||||
#include<hgl/type/Map.h>
|
||||
#include<hgl/type/SortedSets.h>
|
||||
#include<hgl/type/SortedSet.h>
|
||||
#include<hgl/graph/font/Font.h>
|
||||
#include<hgl/type/UnicodeBlocks.h>
|
||||
|
||||
@ -71,7 +71,7 @@ namespace hgl
|
||||
{
|
||||
protected:
|
||||
|
||||
SortedSets<void *> ref_object;
|
||||
SortedSet<void *> ref_object;
|
||||
|
||||
ObjectMap<u32char,CLA> cla_cache;
|
||||
|
||||
|
@ -24,7 +24,7 @@ namespace hgl
|
||||
|
||||
TileResPool to_res;
|
||||
|
||||
SortedSets<u32char> not_bitmap_chars;
|
||||
SortedSet<u32char> not_bitmap_chars;
|
||||
|
||||
public:
|
||||
|
||||
@ -37,7 +37,7 @@ namespace hgl
|
||||
TileFont(TileData *td,FontSource *fs);
|
||||
virtual ~TileFont();
|
||||
|
||||
bool Registry(TileUVFloatMap &,SortedSets<u32char> &chars_sets); ///<注册要使用的字符
|
||||
bool Registry(TileUVFloatMap &,SortedSet<u32char> &chars_sets); ///<注册要使用的字符
|
||||
void Unregistry(const List<u32char> &); ///<注销要使用的字符
|
||||
};//class TileFont
|
||||
}//namespace graph
|
||||
|
@ -42,6 +42,8 @@ public:
|
||||
|
||||
bool Init() override;
|
||||
|
||||
const VkFormatProperties GetFormatProperties(const VkFormat)const;
|
||||
|
||||
public: //Buffer
|
||||
|
||||
DeviceBuffer *CreateTransferSourceBuffer(const VkDeviceSize,const void *data_ptr=nullptr);
|
||||
|
@ -21,9 +21,9 @@ public:
|
||||
~GraphModuleManager();
|
||||
|
||||
GPUDevice * GetDevice ()noexcept{return device;} ///<取得GPU设备
|
||||
VkDevice GetVkDevice (){return device->GetDevice();}
|
||||
const GPUPhysicalDevice * GetPhysicalDevice (){return device->GetPhysicalDevice();} ///<取得物理设备
|
||||
const GPUDeviceAttribute *GetDeviceAttribute (){return device->GetDeviceAttribute();} ///<取得设备属性
|
||||
VkDevice GetVkDevice ()const{return device->GetDevice();}
|
||||
const GPUPhysicalDevice * GetPhysicalDevice ()const{return device->GetPhysicalDevice();} ///<取得物理设备
|
||||
GPUDeviceAttribute *GetDeviceAttribute (){return device->GetDeviceAttribute();} ///<取得设备属性
|
||||
|
||||
/**
|
||||
* 获取指定名称的模块
|
||||
@ -72,9 +72,9 @@ public:
|
||||
|
||||
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();}///<取得设备属性
|
||||
VkDevice GetVkDevice ()const{return module_manager->GetVkDevice();} ///<取得VkDevice
|
||||
const GPUPhysicalDevice * GetPhysicalDevice ()const{return module_manager->GetPhysicalDevice();} ///<取得物理设备
|
||||
GPUDeviceAttribute *GetDeviceAttribute (){return module_manager->GetDeviceAttribute();}///<取得设备属性
|
||||
|
||||
static const AnsiIDName *GetModuleName(){return nullptr;} ///<取得模块名称(标准通用的名称,比如Upscale,供通用模块使用)
|
||||
virtual const AnsiIDName *GetName()const{return &module_name;} ///<取得名称(完整的私有名称,比如FSR3Upscale,DLSS3Upscale)
|
||||
|
@ -36,10 +36,10 @@ public:
|
||||
return(nullptr);
|
||||
}
|
||||
|
||||
return(true);
|
||||
return(gm);
|
||||
}
|
||||
};//template<typename T> class RegistryGraphModule:public GraphModuleFactory
|
||||
|
||||
#define REGISTRY_GRAPH_MODULE(Class) {RegistryGraphModuleFactory(#Class,new RegistryGraphModule<Class##Module>);}
|
||||
#define REGISTRY_GRAPH_MODULE(Class) {RegistryGraphModuleFactory(#Class,new RegistryGraphModule<Class>);}
|
||||
|
||||
VK_NAMESPACE_END
|
@ -16,6 +16,11 @@ protected:
|
||||
|
||||
bool CreateSwapchainFBO();
|
||||
bool CreateSwapchain();
|
||||
bool CreateSwapchainRenderTarget();
|
||||
|
||||
public:
|
||||
|
||||
virtual void OnResize(const VkExtent2D &)override; ///<窗口大小改变
|
||||
|
||||
public:
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include<hgl/graph/RenderFramework.h>
|
||||
#include<hgl/graph/manager/RenderPassManager.h>
|
||||
#include<hgl/graph/module/SwapchainModule.h>
|
||||
#include<hgl/Time.h>
|
||||
|
||||
|
@ -16,7 +16,7 @@ DeviceBuffer *TextureManager::CreateTransferSourceBuffer(const VkDeviceSize size
|
||||
|
||||
bool TextureManager::CheckFormatSupport(const VkFormat format,const uint32_t bits,ImageTiling tiling) const
|
||||
{
|
||||
const VkFormatProperties fp=GetPhysicalDevice()->GetFormatProperties(format);
|
||||
const VkFormatProperties fp=GetFormatProperties(format);
|
||||
|
||||
if(tiling==ImageTiling::Optimal)
|
||||
return(fp.optimalTilingFeatures&bits);
|
||||
|
@ -8,7 +8,6 @@
|
||||
#include<hgl/graph/VKRenderPass.h>
|
||||
#include<hgl/graph/VKFramebuffer.h>
|
||||
#include<hgl/graph/VKDescriptorSet.h>
|
||||
#include<hgl/graph/VKDeviceRenderPassManage.h>
|
||||
#include<hgl/graph/module/GraphModule.h>
|
||||
#include<hgl/graph/module/SwapchainModule.h>
|
||||
|
||||
@ -19,27 +18,11 @@ bool ClearGraphModuleManager(GPUDevice *dev);
|
||||
GPUDevice::GPUDevice(GPUDeviceAttribute *da)
|
||||
{
|
||||
attr=da;
|
||||
|
||||
Resize(attr->surface_caps.currentExtent);
|
||||
}
|
||||
|
||||
GPUDevice::~GPUDevice()
|
||||
{
|
||||
delete attr;
|
||||
|
||||
//按设计,上面那些rt/queue/cmdbuf都需要走graph_module_manager释放和申请
|
||||
ClearGraphModuleManager(this);
|
||||
}
|
||||
|
||||
bool GPUDevice::Resize(const VkExtent2D &extent)
|
||||
{
|
||||
SAFE_CLEAR(sc_rt);
|
||||
|
||||
attr->RefreshSurfaceCaps();
|
||||
|
||||
sc_rt=CreateSwapchainRenderTarget();
|
||||
|
||||
return(sc_rt);
|
||||
}
|
||||
|
||||
VkCommandBuffer GPUDevice::CreateCommandBuffer(const AnsiString &name)
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include<hgl/graph/VKDevice.h>
|
||||
#include<hgl/graph/manager/TextureManager.h>
|
||||
#include<hgl/graph/manager/RenderPassManager.h>
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
RenderTarget *TextureManager::CreateRT(const FramebufferInfo *fbi,RenderPass *rp,const uint32_t fence_count)
|
||||
@ -34,8 +35,10 @@ RenderTarget *TextureManager::CreateRT(const FramebufferInfo *fbi,RenderPass *rp
|
||||
|
||||
if(fb)
|
||||
{
|
||||
DeviceQueue *q=CreateQueue(fence_count,false);
|
||||
Semaphore *render_complete_semaphore=CreateGPUSemaphore();
|
||||
auto *dev=GetDevice();
|
||||
|
||||
DeviceQueue *q=dev->CreateQueue(fence_count,false);
|
||||
Semaphore *render_complete_semaphore=dev->CreateGPUSemaphore();
|
||||
|
||||
RenderTarget *rt=new RenderTarget(q,render_complete_semaphore,rp,fb,color_texture_list,color_count,depth_texture);
|
||||
|
||||
@ -51,7 +54,9 @@ RenderTarget *TextureManager::CreateRT(const FramebufferInfo *fbi,const uint32_t
|
||||
{
|
||||
if(!fbi)return(nullptr);
|
||||
|
||||
RenderPass *rp=AcquireRenderPass(fbi);
|
||||
RenderPassManager *rpm=GetModule<RenderPassManager>();
|
||||
|
||||
RenderPass *rp=rpm->AcquireRenderPass(fbi);
|
||||
|
||||
if(!rp)return(nullptr);
|
||||
|
||||
|
@ -17,7 +17,7 @@ Texture::~Texture()
|
||||
delete data->memory;
|
||||
|
||||
if(data->image)
|
||||
vkDestroyImage(device,data->image,nullptr);
|
||||
vkDestroyImage(manager->GetVkDevice(),data->image,nullptr);
|
||||
}
|
||||
}
|
||||
VK_NAMESPACE_END
|
||||
|
@ -1,5 +1,7 @@
|
||||
#include<hgl/graph/font/TileFont.h>
|
||||
#include<hgl/graph/VKDevice.h>
|
||||
#include<hgl/graph/RenderFramework.h>
|
||||
#include<hgl/graph/module/SwapchainModule.h>
|
||||
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
/**
|
||||
@ -15,7 +17,7 @@ TileFont *RenderFramework::CreateTileFont(FontSource *fs,int limit_count)
|
||||
|
||||
if(limit_count<=0)
|
||||
{
|
||||
const VkExtent2D &ext=GetSwapchainSize();
|
||||
const VkExtent2D &ext=swapchain_module->GetSwapchainSize();
|
||||
|
||||
limit_count=(ext.width/height)*(ext.height/height); //按全屏幕放满不一样的字符为上限
|
||||
}
|
||||
|
@ -3,6 +3,10 @@
|
||||
#include<hgl/graph/VKCommandBuffer.h>
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
const VkFormatProperties TextureManager::GetFormatProperties(const VkFormat format) const
|
||||
{
|
||||
return GetPhysicalDevice()->GetFormatProperties(format);
|
||||
}
|
||||
|
||||
bool TextureManager::Init()
|
||||
{
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include<hgl/graph/mesh/StaticMesh.h>
|
||||
#include<hgl/graph/VKRenderResource.h>
|
||||
#include<hgl/graph/SceneNode.h>
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include<hgl/graph/module/GraphModuleFactory.h>
|
||||
#include<hgl/graph/manager/TextureManager.h>
|
||||
#include<hgl/graph/manager/RenderPassManager.h>
|
||||
#include<hgl/graph/module/SwapchainModule.h>
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
@ -7,7 +8,8 @@ VK_NAMESPACE_BEGIN
|
||||
void RegistryCommonGraphModule()
|
||||
{
|
||||
REGISTRY_GRAPH_MODULE(TextureManager)
|
||||
REGISTRY_GRAPH_MODULE(Swapchain)
|
||||
REGISTRY_GRAPH_MODULE(RenderPassManager)
|
||||
REGISTRY_GRAPH_MODULE(SwapchainModule)
|
||||
}
|
||||
|
||||
VK_NAMESPACE_END
|
||||
|
@ -95,13 +95,12 @@ bool SwapchainModule::CreateSwapchainFBO()
|
||||
if(vkGetSwapchainImagesKHR(swapchain->device,swapchain->swap_chain,&(swapchain->color_count),sc_images)!=VK_SUCCESS)
|
||||
return(false);
|
||||
|
||||
const auto *dev_attr=GetDeviceAttribute();
|
||||
TextureManager *tex_manager=GetModule<TextureManager>();
|
||||
|
||||
if(!tex_manager)
|
||||
return(false);
|
||||
|
||||
swapchain->sc_depth =tex_manager->CreateTexture2D(new SwapchainDepthTextureCreateInfo(GetPhysicalDevice()->GetDepthFormat(),dev_attr->surface_caps.currentExtent));
|
||||
swapchain->sc_depth =tex_manager->CreateTexture2D(new SwapchainDepthTextureCreateInfo(GetPhysicalDevice()->GetDepthFormat(),swapchain->extent));
|
||||
|
||||
if(!swapchain->sc_depth)
|
||||
return(false);
|
||||
@ -120,7 +119,7 @@ bool SwapchainModule::CreateSwapchainFBO()
|
||||
|
||||
for(uint32_t i=0;i<swapchain->color_count;i++)
|
||||
{
|
||||
swapchain->sc_color[i]=tex_manager->CreateTexture2D(new SwapchainColorTextureCreateInfo(dev_attr->surface_format.format,dev_attr->surface_caps.currentExtent,sc_images[i]));
|
||||
swapchain->sc_color[i]=tex_manager->CreateTexture2D(new SwapchainColorTextureCreateInfo(swapchain->surface_format.format,swapchain->extent,sc_images[i]));
|
||||
|
||||
if(!swapchain->sc_color[i])
|
||||
return(false);
|
||||
@ -155,7 +154,11 @@ bool SwapchainModule::CreateSwapchain()
|
||||
|
||||
swapchain=new Swapchain;
|
||||
|
||||
swapchain->device=dev_attr->device;
|
||||
swapchain->device =dev_attr->device;
|
||||
swapchain->extent =dev_attr->surface_caps.currentExtent;
|
||||
swapchain->transform =dev_attr->surface_caps.currentTransform;
|
||||
swapchain->surface_format =dev_attr->surface_format;
|
||||
swapchain->depth_format =dev_attr->physical_device->GetDepthFormat();
|
||||
|
||||
swapchain->swap_chain=CreateVulkanSwapChain(dev_attr);
|
||||
|
||||
@ -170,6 +173,25 @@ bool SwapchainModule::CreateSwapchain()
|
||||
return(false);
|
||||
}
|
||||
|
||||
bool SwapchainModule::CreateSwapchainRenderTarget()
|
||||
{
|
||||
GPUDevice *device=GetDevice();
|
||||
|
||||
DeviceQueue *q=device->CreateQueue(swapchain->color_count,false);
|
||||
Semaphore *render_complete_semaphore=device->CreateGPUSemaphore();
|
||||
Semaphore *present_complete_semaphore=device->CreateGPUSemaphore();
|
||||
|
||||
swapchain_rt=new RTSwapchain( device->GetDevice(),
|
||||
swapchain,
|
||||
q,
|
||||
render_complete_semaphore,
|
||||
present_complete_semaphore,
|
||||
swapchain_rp
|
||||
);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
SwapchainModule::~SwapchainModule()
|
||||
{
|
||||
if(swapchain_rt)
|
||||
@ -181,45 +203,36 @@ SwapchainModule::~SwapchainModule()
|
||||
|
||||
bool SwapchainModule::Init()
|
||||
{
|
||||
if(!CreateSwapchain())
|
||||
return(false);
|
||||
|
||||
RenderPassManager *rpm=GetModule<RenderPassManager>();
|
||||
|
||||
if(!rpm)
|
||||
return(false);
|
||||
|
||||
{
|
||||
auto *dev_attr=GetDeviceAttribute();
|
||||
SwapchainRenderbufferInfo rbi(swapchain->surface_format.format,swapchain->depth_format);
|
||||
|
||||
SwapchainRenderbufferInfo rbi(dev_attr->surface_format.format,dev_attr->physical_device->GetDepthFormat());
|
||||
swapchain_rp=rpm->AcquireRenderPass(&rbi);
|
||||
|
||||
swapchain_rp=rpm->AcquireRenderPass(&rbi);
|
||||
//#ifdef _DEBUG
|
||||
// if(dev_attr->debug_utils)
|
||||
// dev_attr->debug_utils->SetRenderPass(swapchain_rp->GetVkRenderPass(),"SwapchainRenderPass");
|
||||
//#endif//_DEBUG
|
||||
|
||||
#ifdef _DEBUG
|
||||
if(dev_attr->debug_utils)
|
||||
dev_attr->debug_utils->SetRenderPass(swapchain_rp->GetVkRenderPass(),"SwapchainRenderPass");
|
||||
#endif//_DEBUG
|
||||
}
|
||||
|
||||
|
||||
if(!CreateSwapchain())
|
||||
if(!CreateSwapchainRenderTarget())
|
||||
return(false);
|
||||
|
||||
{
|
||||
GPUDevice *device=GetDevice();
|
||||
|
||||
DeviceQueue *q=device->CreateQueue(swapchain->color_count,false);
|
||||
Semaphore *render_complete_semaphore=device->CreateGPUSemaphore();
|
||||
Semaphore *present_complete_semaphore=device->CreateGPUSemaphore();
|
||||
|
||||
swapchain_rt=new RTSwapchain( device->GetDevice(),
|
||||
swapchain,
|
||||
q,
|
||||
render_complete_semaphore,
|
||||
present_complete_semaphore,
|
||||
swapchain_rp
|
||||
);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void SwapchainModule::OnResize(const VkExtent2D &extent)
|
||||
{
|
||||
SAFE_CLEAR(swapchain_rt)
|
||||
|
||||
GetDeviceAttribute()->RefreshSurfaceCaps();
|
||||
|
||||
CreateSwapchainRenderTarget();
|
||||
}
|
||||
|
||||
VK_NAMESPACE_END
|
||||
|
Loading…
x
Reference in New Issue
Block a user