moved few codes to TextureManager
This commit is contained in:
parent
88f5948a2e
commit
95e9fe79a9
2
CMCore
2
CMCore
@ -1 +1 @@
|
||||
Subproject commit 6d9bced95c7fb7fe7a3b6c734d0e7330bacfb2d6
|
||||
Subproject commit 2dfcdf0e4114729384b1c8490c8ab048f9c11c80
|
@ -3,10 +3,11 @@
|
||||
#include<hgl/graph/BlendMode.h>
|
||||
#include<hgl/type/List.h>
|
||||
#include<hgl/graph/ViewportInfo.h>
|
||||
#include<hgl/graph/module/GraphModule.h>
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
|
||||
class GraphModule;
|
||||
class GPUDevice;
|
||||
class TileData;
|
||||
class TileFont;
|
||||
class FontSource;
|
||||
@ -70,10 +71,12 @@ protected:
|
||||
|
||||
ObjectList<GraphModule> module_list;
|
||||
|
||||
TextureManager * texture_manager =nullptr;
|
||||
|
||||
SwapchainModule * swapchain_module =nullptr;
|
||||
|
||||
protected:
|
||||
|
||||
TextureManager * texture_manager =nullptr;
|
||||
|
||||
protected:
|
||||
|
||||
ViewportInfo viewport_info;
|
||||
@ -90,6 +93,12 @@ public:
|
||||
const uint64 GetFrameCount ()const noexcept{return frame_count;} ///<取得当前帧数
|
||||
void RestartFrameCount ()noexcept{frame_count=0;} ///<重新开始统计帧数
|
||||
|
||||
public: //module
|
||||
|
||||
SwapchainModule *GetSwapchain(){return swapchain_module;} ///<取得Swapchain模块
|
||||
|
||||
template<typename T> T *GetModule(){return graph_module_manager->GetModule<T>(false);} ///<获取指定类型的模块
|
||||
|
||||
public:
|
||||
|
||||
NO_COPY_NO_MOVE(RenderFramework)
|
||||
@ -97,7 +106,7 @@ public:
|
||||
RenderFramework();
|
||||
virtual ~RenderFramework();
|
||||
|
||||
virtual bool Init();
|
||||
virtual bool Init(); ///<初始化
|
||||
|
||||
virtual void StartTime();
|
||||
|
||||
|
@ -50,7 +50,6 @@ class RenderResource
|
||||
|
||||
ShaderModuleMapByName shader_module_by_name[VK_SHADER_STAGE_TYPE_COUNT];
|
||||
Map<AnsiString,Material *> material_by_name;
|
||||
//Map<OSString,Texture *> texture_by_name;
|
||||
|
||||
IDObjectManage<MaterialID, Material> rm_material; ///<材质合集
|
||||
IDObjectManage<MaterialInstanceID, MaterialInstance> rm_material_instance; ///<材质实例合集
|
||||
|
@ -16,6 +16,8 @@ class TextureManager:public GraphManager
|
||||
SortedSet<VkImage> image_set;
|
||||
SortedSet<Texture *> texture_set; ///<纹理合集
|
||||
|
||||
Map<OSString,Texture *> texture_by_name;
|
||||
|
||||
private:
|
||||
|
||||
DeviceQueue *texture_queue;
|
||||
|
@ -1,20 +1,24 @@
|
||||
#include<hgl/graph/RenderFramework.h>
|
||||
#include<hgl/graph/module/GraphModule.h>
|
||||
#include<hgl/graph/module/SwapchainModule.h>
|
||||
#include<hgl/Time.h>
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
|
||||
GraphModuleManager *InitGraphModuleManager(GPUDevice *dev);
|
||||
bool ClearGraphModuleManager(GPUDevice *dev);
|
||||
|
||||
RenderFramework::RenderFramework()
|
||||
{
|
||||
|
||||
|
||||
graph_module_manager=InitGraphModuleManager(device);
|
||||
|
||||
swapchain_module=graph_module_manager->GetModule<SwapchainModule>(device);
|
||||
swapchain_module=graph_module_manager->GetModule<SwapchainModule>(true);
|
||||
}
|
||||
|
||||
RenderFramework::~RenderFramework()
|
||||
{
|
||||
// if(swapchain_module)graph_module_manager->ReleaseModule(swapchain_module);
|
||||
|
||||
ClearGraphModuleManager(device);
|
||||
}
|
||||
|
||||
void RenderFramework::StartTime()
|
||||
|
@ -13,7 +13,7 @@ Texture2D *TextureManager::CreateTexture2D(TextureData *tex_data)
|
||||
if(!tex_data)
|
||||
return(nullptr);
|
||||
|
||||
Texture2D *tex=new Texture2D(GetVkDevice(),tex_data);
|
||||
Texture2D *tex=new Texture2D(this,tex_data);
|
||||
|
||||
texture_set.Add(tex);
|
||||
|
||||
|
@ -13,7 +13,7 @@ Texture2DArray *TextureManager::CreateTexture2DArray(TextureData *tex_data)
|
||||
if(!tex_data)
|
||||
return(nullptr);
|
||||
|
||||
return(new Texture2DArray(GetVkDevice(),tex_data));
|
||||
return(new Texture2DArray(this,tex_data));
|
||||
}
|
||||
|
||||
Texture2DArray *TextureManager::CreateTexture2DArray(TextureCreateInfo *tci)
|
||||
|
@ -12,7 +12,7 @@ TextureCube *TextureManager::CreateTextureCube(TextureData *tex_data)
|
||||
if(!tex_data)
|
||||
return(nullptr);
|
||||
|
||||
return(new TextureCube(GetVkDevice(),tex_data));
|
||||
return(new TextureCube(this,tex_data));
|
||||
}
|
||||
|
||||
TextureCube *TextureManager::CreateTextureCube(TextureCreateInfo *tci)
|
||||
|
@ -14,23 +14,16 @@
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
|
||||
GraphModuleManager *InitGraphModuleManager(GPUDevice *dev);
|
||||
bool ClearGraphModuleManager(GPUDevice *dev);
|
||||
|
||||
GPUDevice::GPUDevice(GPUDeviceAttribute *da)
|
||||
{
|
||||
attr=da;
|
||||
|
||||
texture_queue=nullptr;
|
||||
texture_cmd_buf=nullptr;
|
||||
|
||||
InitRenderPassManage();
|
||||
|
||||
sc_rt=nullptr;
|
||||
Resize(attr->surface_caps.currentExtent);
|
||||
|
||||
texture_cmd_buf=CreateTextureCommandBuffer(attr->physical_device->GetDeviceName()+AnsiString(":TexCmdBuffer"));
|
||||
texture_queue=CreateQueue();
|
||||
}
|
||||
|
||||
GPUDevice::~GPUDevice()
|
||||
@ -39,9 +32,6 @@ GPUDevice::~GPUDevice()
|
||||
|
||||
SAFE_CLEAR(sc_rt);
|
||||
|
||||
SAFE_CLEAR(texture_queue);
|
||||
SAFE_CLEAR(texture_cmd_buf);
|
||||
|
||||
delete attr;
|
||||
|
||||
//按设计,上面那些rt/queue/cmdbuf都需要走graph_module_manager释放和申请
|
||||
|
@ -2,6 +2,18 @@
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
|
||||
TextureManager::TextureManager()
|
||||
{
|
||||
texture_cmd_buf=CreateTextureCommandBuffer(attr->physical_device->GetDeviceName()+AnsiString(":TexCmdBuffer"));
|
||||
texture_queue=CreateQueue();
|
||||
}
|
||||
|
||||
TextureManager::~TextureManager()
|
||||
{
|
||||
SAFE_CLEAR(texture_queue);
|
||||
SAFE_CLEAR(texture_cmd_buf);
|
||||
}
|
||||
|
||||
void TextureManager::Release(Texture *tex)
|
||||
{
|
||||
if(!tex)
|
||||
@ -10,7 +22,7 @@ void TextureManager::Release(Texture *tex)
|
||||
texture_set.Delete(tex);
|
||||
}
|
||||
|
||||
Texture2D *CreateTexture2DFromFile(GPUDevice *device,const OSString &filename,bool auto_mipmaps);
|
||||
Texture2D *CreateTexture2DFromFile(TextureManager *tm,const OSString &filename,bool auto_mipmaps);
|
||||
|
||||
Texture2D *TextureManager::LoadTexture2D(const OSString &filename,bool auto_mipmaps)
|
||||
{
|
||||
@ -19,7 +31,7 @@ Texture2D *TextureManager::LoadTexture2D(const OSString &filename,bool auto_mipm
|
||||
if(texture_by_name.Get(filename,(Texture *&)tex))
|
||||
return tex;
|
||||
|
||||
tex=CreateTexture2DFromFile(device,filename,auto_mipmaps);
|
||||
tex=CreateTexture2DFromFile(this,filename,auto_mipmaps);
|
||||
|
||||
if(tex)
|
||||
{
|
||||
@ -43,7 +55,7 @@ Texture2D *TextureManager::LoadTexture2D(const OSString &filename,bool auto_mipm
|
||||
|
||||
Texture2DArray *TextureManager::CreateTexture2DArray(const AnsiString &name,const uint32_t width,const uint32_t height,const uint32_t layer,const VkFormat &fmt,bool auto_mipmaps)
|
||||
{
|
||||
Texture2DArray *ta=device->CreateTexture2DArray(width,height,layer,fmt,auto_mipmaps);
|
||||
Texture2DArray *ta=CreateTexture2DArray(width,height,layer,fmt,auto_mipmaps);
|
||||
|
||||
if(ta)
|
||||
Add(ta);
|
||||
@ -70,13 +82,13 @@ bool TextureManager::LoadTexture2DToArray(Texture2DArray *ta,const uint32_t laye
|
||||
{
|
||||
if(!ta)return(false);
|
||||
|
||||
if(!LoadTexture2DLayerFromFile(device,ta,layer,filename,false))
|
||||
if(!LoadTexture2DLayerFromFile(this,ta,layer,filename,false))
|
||||
return(false);
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
TextureCube *CreateTextureCubeFromFile(GPUDevice *device,const OSString &filename,bool auto_mipmaps);
|
||||
TextureCube *CreateTextureCubeFromFile(TextureManager *tm,const OSString &filename,bool auto_mipmaps);
|
||||
|
||||
TextureCube *TextureManager::LoadTextureCube(const OSString &filename,bool auto_mipmaps)
|
||||
{
|
||||
@ -85,7 +97,7 @@ TextureCube *TextureManager::LoadTextureCube(const OSString &filename,bool auto_
|
||||
if(texture_by_name.Get(filename,(Texture *&)tex))
|
||||
return tex;
|
||||
|
||||
tex=CreateTextureCubeFromFile(device,filename,auto_mipmaps);
|
||||
tex=CreateTextureCubeFromFile(this,filename,auto_mipmaps);
|
||||
|
||||
if(tex)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user