Added "RenderFramework *" in GraphModule and IRenderTarget
This commit is contained in:
@@ -40,11 +40,13 @@ protected:
|
||||
|
||||
public:
|
||||
|
||||
Window * GetWindow (){return win;}
|
||||
GPUDevice * GetDevice (){return device;}
|
||||
GPUDeviceAttribute * GetDeviceAttribute (){return device->GetDeviceAttribute();}
|
||||
Window * GetWindow ()const{return win;}
|
||||
GPUDevice * GetDevice ()const{return device;}
|
||||
VkDevice GetVkDevice ()const{return device->GetDevice();}
|
||||
const GPUPhysicalDevice * GetPhysicalDevice ()const{return device->GetPhysicalDevice();}
|
||||
GPUDeviceAttribute * GetDeviceAttribute ()const{return device->GetDeviceAttribute();}
|
||||
|
||||
RenderResource * GetRenderResource (){return render_resource;}
|
||||
RenderResource * GetRenderResource ()const{return render_resource;}
|
||||
|
||||
public:
|
||||
|
||||
|
@@ -36,6 +36,9 @@ struct VertexAttribDataPtr
|
||||
using BindingMap =Map<AnsiString,int>;
|
||||
using BindingMapArray =BindingMap[VK_DESCRIPTOR_TYPE_RANGE_SIZE];
|
||||
|
||||
class GraphModule;
|
||||
class RenderFramework;
|
||||
|
||||
class VulkanInstance;
|
||||
class GPUPhysicalDevice;
|
||||
class GPUDevice;
|
||||
@@ -44,9 +47,13 @@ class DeviceQueue;
|
||||
class ImageView;
|
||||
class Framebuffer;
|
||||
struct Swapchain;
|
||||
class IRenderTarget;
|
||||
class RenderTarget;
|
||||
class MFRenderTarget;
|
||||
class SwapchainRenderTarget;
|
||||
|
||||
struct CopyBufferToImageInfo;
|
||||
|
||||
class Texture;
|
||||
class Texture1D;
|
||||
class Texture1DArray;
|
||||
@@ -58,6 +65,8 @@ class TextureCubeArray;
|
||||
|
||||
class Sampler;
|
||||
|
||||
class TileData;
|
||||
|
||||
class DeviceMemory;
|
||||
class DeviceBuffer;
|
||||
struct DeviceBufferData;
|
||||
|
@@ -51,65 +51,4 @@ public:
|
||||
bool Write (const void *ptr) {return buf.memory->Write(ptr);}
|
||||
};//class DeviceBuffer
|
||||
|
||||
template<typename T> struct DeviceBufferData
|
||||
{
|
||||
T *data; ///<CPU端数据
|
||||
|
||||
// 数据如何被设置为不可以在CPU端访问,那么不会在CPU端保存备份。
|
||||
// 这种情况的话,将不会允许CPU端随机读写,只能写入
|
||||
|
||||
|
||||
VkDeviceSize size;
|
||||
DeviceBuffer *dev_buffer;
|
||||
};
|
||||
|
||||
template<typename T> class DeviceBufferRandomAccess
|
||||
{
|
||||
DeviceBufferData<T> *dbd;
|
||||
|
||||
public:
|
||||
|
||||
operator T *(){return dbd->data;}
|
||||
|
||||
public:
|
||||
|
||||
DeviceBufferRandomAccess(DeviceBufferData<T> *obj)
|
||||
{
|
||||
dbd=obj;
|
||||
|
||||
}
|
||||
virtual ~DeviceBufferAccess()
|
||||
{
|
||||
if(!dbd)return;
|
||||
delete dbd->dev_buffer;
|
||||
delete dbd;
|
||||
}
|
||||
bool Write(const T *ptr)
|
||||
{
|
||||
return dbd->dev_buffer->Write(ptr);
|
||||
}
|
||||
};
|
||||
|
||||
template<typename T> class DeviceBufferObject
|
||||
{
|
||||
DeviceBufferData<T> *dbd;
|
||||
|
||||
public:
|
||||
|
||||
DeviceBufferObject(DeviceBufferData<T> *obj)
|
||||
{
|
||||
dbd=obj;
|
||||
}
|
||||
|
||||
virtual ~DeviceBufferObject()
|
||||
{
|
||||
if(!dbd)return;
|
||||
|
||||
delete dbd->dev_buffer;
|
||||
delete dbd;
|
||||
}
|
||||
|
||||
|
||||
|
||||
};//template<typename T> class DeviceBufferObject
|
||||
VK_NAMESPACE_END
|
||||
|
@@ -23,16 +23,6 @@ class RenderFramework;
|
||||
* 所以RenderTarget的其实是一个多态类,根据不同的情况,有不同的实现
|
||||
*/
|
||||
|
||||
template<typename T> class DeviceBufferObject
|
||||
{
|
||||
T data;
|
||||
DeviceBuffer *dev_buffer;
|
||||
|
||||
|
||||
|
||||
public:
|
||||
};
|
||||
|
||||
class IRenderTarget
|
||||
{
|
||||
RenderFramework *render_framework;
|
||||
@@ -44,8 +34,8 @@ class IRenderTarget
|
||||
public:
|
||||
|
||||
RenderFramework * GetRenderFramework ()const{return render_framework;}
|
||||
GPUDevice * GetDevice ()const{return render_framework->GetDevice();}
|
||||
VkDevice GetVkDevice ()const{return render_framework->GetDevice()->GetDevice();}
|
||||
GPUDevice * GetDevice ()const;
|
||||
VkDevice GetVkDevice ()const;
|
||||
|
||||
const VkExtent2D &GetExtent ()const{return extent;}
|
||||
|
||||
|
@@ -1,20 +1,26 @@
|
||||
#pragma once
|
||||
|
||||
#include<hgl/graph/VKDevice.h>
|
||||
#include<hgl/graph/VK.h>
|
||||
#include<hgl/type/TypeInfo.h>
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
|
||||
class TextureManager;
|
||||
class RenderTargetManager;
|
||||
class RenderPassManager;
|
||||
|
||||
class GraphModule
|
||||
{
|
||||
GPUDevice *device;
|
||||
RenderFramework *render_framework;
|
||||
|
||||
public:
|
||||
|
||||
GPUDevice * GetDevice () {return device;} ///<取得GPU设备
|
||||
VkDevice GetVkDevice ()const {return device->GetDevice();} ///<取得VkDevice
|
||||
const GPUPhysicalDevice * GetPhysicalDevice ()const {return device->GetPhysicalDevice();} ///<取得物理设备
|
||||
GPUDeviceAttribute *GetDeviceAttribute () {return device->GetDeviceAttribute();} ///<取得设备属性
|
||||
RenderFramework * GetRenderFramework ()const{return render_framework;} ///<取得渲染框架
|
||||
GPUDevice * GetDevice (); ///<取得GPU设备
|
||||
VkDevice GetVkDevice ()const; ///<取得VkDevice
|
||||
const GPUPhysicalDevice * GetPhysicalDevice ()const; ///<取得物理设备
|
||||
GPUDeviceAttribute *GetDeviceAttribute ()const; ///<取得设备属性
|
||||
VkPipelineCache GetPipelineCache ()const; ///<取得PipelineCache
|
||||
|
||||
public:
|
||||
|
||||
@@ -22,7 +28,7 @@ public:
|
||||
|
||||
public:
|
||||
|
||||
GraphModule(GPUDevice *dev){device=dev;}
|
||||
GraphModule(RenderFramework *rf){render_framework=rf;}
|
||||
virtual ~GraphModule()=default;
|
||||
|
||||
virtual const size_t GetTypeHash()const noexcept=0;
|
||||
@@ -47,7 +53,7 @@ public:
|
||||
|
||||
public:
|
||||
|
||||
GraphModuleInherit(GPUDevice *dev,const AnsiString &name):BASE(dev)
|
||||
GraphModuleInherit(RenderFramework *rf,const AnsiString &name):BASE(rf)
|
||||
{
|
||||
manager_name=name;
|
||||
}
|
||||
@@ -57,6 +63,6 @@ public:
|
||||
|
||||
#define GRAPH_MODULE_CLASS(class_name) class class_name:public GraphModuleInherit<class_name,GraphModule>
|
||||
|
||||
#define GRAPH_MODULE_CONSTRUCT(class_name) class_name::class_name(GPUDevice *dev):GraphModuleInherit<class_name,GraphModule>(dev,#class_name)
|
||||
#define GRAPH_MODULE_CONSTRUCT(class_name) class_name::class_name(RenderFramework *rf):GraphModuleInherit<class_name,GraphModule>(rf,#class_name)
|
||||
|
||||
VK_NAMESPACE_END
|
||||
|
@@ -5,11 +5,9 @@
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
|
||||
class GraphModule;
|
||||
|
||||
class GraphModuleManager
|
||||
{
|
||||
GPUDevice *device;
|
||||
RenderFramework *render_framework;
|
||||
|
||||
protected:
|
||||
|
||||
@@ -18,13 +16,14 @@ protected:
|
||||
|
||||
public:
|
||||
|
||||
GraphModuleManager(GPUDevice *dev){device=dev;}
|
||||
GraphModuleManager(RenderFramework *rf){render_framework=rf;}
|
||||
|
||||
virtual ~GraphModuleManager();
|
||||
|
||||
public:
|
||||
|
||||
GPUDevice * GetDevice() {return device;} ///<取得GPU设备
|
||||
RenderFramework * GetRenderFramework ()const{return render_framework;} ///<取得渲染框架
|
||||
GPUDevice * GetDevice ()const; ///<取得GPU设备
|
||||
|
||||
public:
|
||||
|
||||
@@ -46,7 +45,7 @@ public:
|
||||
if(Contains<T>())
|
||||
return Get<T>();
|
||||
|
||||
T *result=new T(device);
|
||||
T *result=new T(render_framework);
|
||||
|
||||
Registry(result);
|
||||
|
||||
|
@@ -15,15 +15,13 @@ inline util::Hash *CreateRenderPassHash()
|
||||
|
||||
GRAPH_MODULE_CLASS(RenderPassManager)
|
||||
{
|
||||
VkPipelineCache pipeline_cache;
|
||||
|
||||
util::Hash *hash;
|
||||
|
||||
Map<RenderPassHASHCode,RenderPass *> RenderPassList;
|
||||
|
||||
private:
|
||||
|
||||
RenderPassManager(GPUDevice *);
|
||||
RenderPassManager(RenderFramework *);
|
||||
~RenderPassManager();
|
||||
|
||||
friend class GraphModuleManager;
|
||||
|
@@ -14,7 +14,7 @@ GRAPH_MODULE_CLASS(RenderTargetManager)
|
||||
|
||||
public:
|
||||
|
||||
RenderTargetManager(GPUDevice *,TextureManager *tm,RenderPassManager *rpm);
|
||||
RenderTargetManager(RenderFramework *,TextureManager *tm,RenderPassManager *rpm);
|
||||
virtual ~RenderTargetManager()=default;
|
||||
|
||||
public: //FrameBuffer相关
|
||||
|
@@ -4,10 +4,6 @@
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
|
||||
class RenderTargetManager;
|
||||
class RenderPassManager;
|
||||
class RenderPass;
|
||||
|
||||
GRAPH_MODULE_CLASS(SwapchainModule)
|
||||
{
|
||||
TextureManager * tex_manager =nullptr;
|
||||
@@ -30,7 +26,7 @@ public:
|
||||
|
||||
public:
|
||||
|
||||
SwapchainModule(GPUDevice *,TextureManager *tm,RenderTargetManager *rtm,RenderPassManager *rpm);
|
||||
SwapchainModule(RenderFramework *,TextureManager *tm,RenderTargetManager *rtm,RenderPassManager *rpm);
|
||||
virtual ~SwapchainModule();
|
||||
|
||||
// RenderCmdBuffer *BeginRender();
|
||||
@@ -41,10 +37,10 @@ public:
|
||||
|
||||
RenderPass * GetRenderPass ()const{return sc_render_pass;}
|
||||
|
||||
const VkExtent2D & GetSwapchainSize()const{return sc_render_target->GetExtent();}
|
||||
const VkExtent2D & GetSwapchainSize()const;
|
||||
|
||||
SwapchainRenderTarget * GetRenderTarget ()const{return sc_render_target;}
|
||||
IRenderTarget * AcquireNextImage()const{return sc_render_target->AcquireNextImage();}
|
||||
IRenderTarget * AcquireNextImage()const;
|
||||
};//class SwapchainModule:public GraphModule
|
||||
|
||||
VK_NAMESPACE_END
|
||||
|
@@ -34,7 +34,7 @@ private:
|
||||
|
||||
public:
|
||||
|
||||
TextureManager(GPUDevice *);
|
||||
TextureManager(RenderFramework *rf);
|
||||
virtual ~TextureManager();
|
||||
|
||||
const VkFormatProperties GetFormatProperties(const VkFormat)const;
|
||||
|
Reference in New Issue
Block a user