Compare commits
12 Commits
devel_37_R
...
devel_36_P
Author | SHA1 | Date | |
---|---|---|---|
11ca8e7fdf | |||
02ac76e5bd | |||
39aa63aa0a | |||
d73966b1d0 | |||
c9b99dd125 | |||
ea6c009c70 | |||
6080422f3a | |||
6ca0cd2987 | |||
bd0a3d8be1 | |||
d810540b81 | |||
3259f1af4c | |||
62d370e508 |
14
.gitmodules
vendored
14
.gitmodules
vendored
@@ -1,21 +1,21 @@
|
||||
[submodule "CMCMakeModule"]
|
||||
path = CMCMakeModule
|
||||
url = https://github.com/hyzboy/CMCMakeModule
|
||||
url = http://www.hyzgame.com:3000/hyzboy/CMCMakeModule
|
||||
[submodule "CMCore"]
|
||||
path = CMCore
|
||||
url = https://github.com/hyzboy/CMCore
|
||||
url = http://www.hyzgame.com:3000/hyzboy/CMCore
|
||||
[submodule "CMPlatform"]
|
||||
path = CMPlatform
|
||||
url = https://github.com/hyzboy/CMPlatform
|
||||
url = http://www.hyzgame.com:3000/hyzboy/CMPlatform
|
||||
[submodule "CMAssetsManage"]
|
||||
path = CMAssetsManage
|
||||
url = https://github.com/hyzboy/CMAssetsManage.git
|
||||
url = http://www.hyzgame.com:3000/hyzboy/CMAssetsManage.git
|
||||
[submodule "res"]
|
||||
path = res
|
||||
url = https://github.com/hyzboy/RuntimeData.git
|
||||
url = http://www.hyzgame.com:3000/hyzboy/RuntimeData.git
|
||||
[submodule "CMSceneGraph"]
|
||||
path = CMSceneGraph
|
||||
url = https://github.com/hyzboy/CMSceneGraph.git
|
||||
url = http://www.hyzgame.com:3000/hyzboy/CMSceneGraph.git
|
||||
[submodule "CMUtil"]
|
||||
path = CMUtil
|
||||
url = https://github.com/hyzboy/CMUtil.git
|
||||
url = http://www.hyzgame.com:3000/hyzboy/CMUtil.git
|
||||
|
Submodule CMAssetsManage updated: 85436b5a7b...0fae462338
2
CMCore
2
CMCore
Submodule CMCore updated: 09d777261f...9dd89aa5a3
Submodule CMPlatform updated: 103b0d845d...aa7abe4763
Submodule CMSceneGraph updated: 9ff596c424...2370ba12d7
2
CMUtil
2
CMUtil
Submodule CMUtil updated: f7dce03048...57ff3a70c9
@@ -28,7 +28,7 @@ private:
|
||||
|
||||
bool InitTextRenderable()
|
||||
{
|
||||
UTF16String str;
|
||||
U16String str;
|
||||
|
||||
LoadStringFromTextFile(str,OS_TEXT("res/text/DaoDeBible.txt"));
|
||||
|
||||
|
@@ -22,6 +22,7 @@
|
||||
*/
|
||||
|
||||
#include"GizmoResource.h"
|
||||
#include<hgl/graph/SceneNode.h>
|
||||
#include<hgl/graph/VKRenderResource.h>
|
||||
#include<hgl/graph/InlineGeometry.h>
|
||||
|
||||
|
@@ -1,4 +1,5 @@
|
||||
#include"GizmoResource.h"
|
||||
#include<hgl/graph/SceneNode.h>
|
||||
#include<hgl/graph/VKRenderResource.h>
|
||||
#include<hgl/graph/TransformFaceToCamera.h>
|
||||
|
||||
|
@@ -22,6 +22,7 @@
|
||||
*/
|
||||
|
||||
#include"GizmoResource.h"
|
||||
#include<hgl/graph/SceneNode.h>
|
||||
#include<hgl/graph/VKRenderResource.h>
|
||||
#include<hgl/graph/InlineGeometry.h>
|
||||
|
||||
|
@@ -8,6 +8,7 @@
|
||||
#include<hgl/graph/VKRenderResource.h>
|
||||
#include<hgl/color/Color.h>
|
||||
#include<hgl/graph/InlineGeometry.h>
|
||||
#include<hgl/graph/SceneNode.h>
|
||||
#include"GizmoResource.h"
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
|
@@ -54,15 +54,10 @@ protected:
|
||||
protected:
|
||||
|
||||
GPUDevice * device =nullptr;
|
||||
RenderPass * device_render_pass =nullptr;
|
||||
RTSwapchain * sc_render_target =nullptr;
|
||||
SwapchainRenderTarget * sc_render_target =nullptr;
|
||||
|
||||
protected:
|
||||
|
||||
int32_t swap_chain_count =0;
|
||||
|
||||
RenderCmdBuffer ** cmd_buf =nullptr;
|
||||
|
||||
Color4f clear_color;
|
||||
|
||||
protected:
|
||||
@@ -91,7 +86,6 @@ public:
|
||||
win->Unjoin(this);
|
||||
|
||||
SAFE_CLEAR(db);
|
||||
SAFE_CLEAR_OBJECT_ARRAY_OBJECT(cmd_buf,swap_chain_count);
|
||||
|
||||
SAFE_CLEAR(device);
|
||||
SAFE_CLEAR(win);
|
||||
@@ -146,14 +140,12 @@ public:
|
||||
|
||||
if(!device)
|
||||
return(false);
|
||||
|
||||
sc_render_target=device->GetSwapchainRT();
|
||||
}
|
||||
|
||||
device_render_pass=device->GetRenderPass();
|
||||
|
||||
db=new RenderResource(device);
|
||||
|
||||
InitCommandBuffer();
|
||||
|
||||
win->Join(this);
|
||||
|
||||
{
|
||||
@@ -198,34 +190,17 @@ public:
|
||||
if(w>0&&h>0)
|
||||
device->Resize(w,h);
|
||||
|
||||
InitCommandBuffer();
|
||||
sc_render_target=device->GetSwapchainRT();
|
||||
|
||||
Resize(w,h);
|
||||
}
|
||||
|
||||
void InitCommandBuffer()
|
||||
{
|
||||
if(cmd_buf)
|
||||
SAFE_CLEAR_OBJECT_ARRAY_OBJECT(cmd_buf,swap_chain_count);
|
||||
|
||||
sc_render_target=device->GetSwapchainRT();
|
||||
|
||||
swap_chain_count=sc_render_target->GetImageCount();
|
||||
{
|
||||
const VkExtent2D extent=sc_render_target->GetExtent();
|
||||
|
||||
cmd_buf=hgl_zero_new<RenderCmdBuffer *>(swap_chain_count);
|
||||
|
||||
for(int32_t i=0;i<swap_chain_count;i++)
|
||||
cmd_buf[i]=device->CreateRenderCommandBuffer(device->GetPhysicalDevice()->GetDeviceName()+AnsiString(":RenderCmdBuffer_")+AnsiString::numberOf(i));
|
||||
}
|
||||
}
|
||||
|
||||
bool BuildCommandBuffer(RenderCmdBuffer *cb,RenderPass *rp,Framebuffer *fb,Renderable *ri)
|
||||
bool BuildCommandBuffer(RenderCmdBuffer *cb,Framebuffer *fb,Renderable *ri)
|
||||
{
|
||||
if(!ri)return(false);
|
||||
|
||||
cb->Begin();
|
||||
cb->BindFramebuffer(rp,fb);
|
||||
cb->BindFramebuffer(fb);
|
||||
cb->SetClearColor(0,clear_color);
|
||||
cb->BeginRenderPass();
|
||||
cb->BindPipeline(ri->GetPipeline());
|
||||
@@ -238,26 +213,30 @@ public:
|
||||
return(true);
|
||||
}
|
||||
|
||||
void BuildCommandBuffer(RenderCmdBuffer *cb,RenderTarget *rt,Renderable *ri)
|
||||
bool BuildCommandBuffer(RenderCmdBuffer *cb,RenderTarget *rt,Renderable *ri)
|
||||
{
|
||||
if(!cb||!rt||!ri)
|
||||
return;
|
||||
return(false);
|
||||
|
||||
BuildCommandBuffer(cb,rt->GetRenderPass(),rt->GetFramebuffer(),ri);
|
||||
return BuildCommandBuffer(cb,rt->GetFramebuffer(),ri);
|
||||
}
|
||||
|
||||
bool BuildCommandBuffer(uint32_t index,Renderable *ri)
|
||||
{
|
||||
if(!ri)return(false);
|
||||
|
||||
return BuildCommandBuffer(cmd_buf[index],sc_render_target->GetRenderPass(),sc_render_target->GetFramebuffer(index),ri);
|
||||
IRenderTarget *rt=sc_render_target->GetCurrentFrameRenderTarget();
|
||||
|
||||
return BuildCommandBuffer(rt->GetRenderCmdBuffer(),
|
||||
rt->GetFramebuffer(),
|
||||
ri);
|
||||
}
|
||||
|
||||
bool BuildCommandBuffer(Renderable *ri)
|
||||
{
|
||||
if(!ri)return(false);
|
||||
|
||||
for(int32_t i=0;i<swap_chain_count;i++)
|
||||
for(uint32_t i=0;i<sc_render_target->GetFrameCount();i++)
|
||||
BuildCommandBuffer(i,ri);
|
||||
|
||||
return(true);
|
||||
@@ -274,10 +253,10 @@ public:
|
||||
{
|
||||
if(!rl)return;
|
||||
|
||||
RenderCmdBuffer *cb=cmd_buf[index];
|
||||
RenderCmdBuffer *cb=sc_render_target->GetRenderCmdBuffer(index);
|
||||
|
||||
cb->Begin();
|
||||
cb->BindFramebuffer(sc_render_target->GetRenderPass(),sc_render_target->GetFramebuffer(index));
|
||||
cb->BindFramebuffer(sc_render_target->GetFramebuffer(index));
|
||||
cb->SetClearColor(0,clear_color);
|
||||
cb->BeginRenderPass();
|
||||
rl->Render(cb);
|
||||
@@ -287,7 +266,7 @@ public:
|
||||
|
||||
void BuildCommandBuffer(RenderList *rl)
|
||||
{
|
||||
for(int32_t i=0;i<swap_chain_count;i++)
|
||||
for(uint32_t i=0;i<sc_render_target->GetFrameCount();i++)
|
||||
BuildCommandBuffer(i,rl);
|
||||
}
|
||||
|
||||
@@ -299,7 +278,7 @@ public:
|
||||
template<typename ...ARGS>
|
||||
Pipeline *CreatePipeline(ARGS...args)
|
||||
{
|
||||
Pipeline *p=device_render_pass->CreatePipeline(args...);
|
||||
Pipeline *p=sc_render_target->GetRenderPass()->CreatePipeline(args...);
|
||||
|
||||
if(!p)
|
||||
return(nullptr);
|
||||
@@ -321,11 +300,9 @@ public:
|
||||
return sc_render_target->AcquireNextImage();
|
||||
}
|
||||
|
||||
virtual void SubmitDraw(int index)
|
||||
virtual void SubmitDraw()
|
||||
{
|
||||
VkCommandBuffer cb=*cmd_buf[index];
|
||||
|
||||
sc_render_target->Submit(cb);
|
||||
sc_render_target->Submit();
|
||||
sc_render_target->PresentBackbuffer();
|
||||
sc_render_target->WaitQueue();
|
||||
sc_render_target->WaitFence();
|
||||
@@ -335,9 +312,9 @@ public:
|
||||
{
|
||||
int index=AcquireNextImage();
|
||||
|
||||
if(index<0||index>=swap_chain_count)return;
|
||||
if(index<0||index>=sc_render_target->GetFrameCount())return;
|
||||
|
||||
SubmitDraw(index);
|
||||
SubmitDraw();
|
||||
}
|
||||
|
||||
bool Run()
|
||||
@@ -568,7 +545,7 @@ public:
|
||||
|
||||
BuildCommandBuffer(index);
|
||||
|
||||
SubmitDraw(index);
|
||||
SubmitDraw();
|
||||
|
||||
ckc->Update();
|
||||
cmc->Update();
|
||||
|
@@ -8,15 +8,48 @@ class RenderAssignBuffer;
|
||||
class SceneNode;
|
||||
struct CameraInfo;
|
||||
|
||||
struct RenderPipelineIndex:public Comparator<RenderPipelineIndex>
|
||||
{
|
||||
Material *material;
|
||||
Pipeline *pipeline;
|
||||
|
||||
public:
|
||||
|
||||
const int compare(const RenderPipelineIndex &rli)const override
|
||||
{
|
||||
if(material<rli.material)return(-1);
|
||||
if(material>rli.material)return(1);
|
||||
|
||||
if(pipeline<rli.pipeline)return(-1);
|
||||
if(pipeline>rli.pipeline)return(1);
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
RenderPipelineIndex()
|
||||
{
|
||||
material=nullptr;
|
||||
pipeline=nullptr;
|
||||
}
|
||||
|
||||
RenderPipelineIndex(Material *m,Pipeline *p)
|
||||
{
|
||||
material=m;
|
||||
pipeline=p;
|
||||
}
|
||||
};//struct RenderPipelineIndex
|
||||
|
||||
/**
|
||||
* 同一材质的对象渲染列表
|
||||
* 同一材质与管线的渲染列表
|
||||
*/
|
||||
class MaterialRenderList
|
||||
{
|
||||
GPUDevice *device;
|
||||
RenderCmdBuffer *cmd_buf;
|
||||
|
||||
Material *material;
|
||||
RenderPipelineIndex rp_index;
|
||||
|
||||
CameraInfo *camera_info;
|
||||
|
||||
@@ -33,7 +66,6 @@ private:
|
||||
uint32_t first_instance; ///<第一个绘制实例(和instance渲染无关,对应InstanceRate的VAB)
|
||||
uint32_t instance_count;
|
||||
|
||||
Pipeline * pipeline;
|
||||
MaterialInstance * mi;
|
||||
|
||||
const PrimitiveDataBuffer * pdb;
|
||||
@@ -60,7 +92,6 @@ protected:
|
||||
|
||||
VABList * vab_list;
|
||||
|
||||
Pipeline * last_pipeline;
|
||||
const PrimitiveDataBuffer * last_data_buffer;
|
||||
const VDM * last_vdm;
|
||||
const PrimitiveRenderData * last_render_data;
|
||||
@@ -75,20 +106,14 @@ protected:
|
||||
|
||||
public:
|
||||
|
||||
MaterialRenderList(GPUDevice *d,bool l2w,Material *m);
|
||||
MaterialRenderList(GPUDevice *d,bool l2w,const RenderPipelineIndex &rpi);
|
||||
~MaterialRenderList();
|
||||
|
||||
void Add(SceneNode *);
|
||||
|
||||
void SetCameraInfo(CameraInfo *ci)
|
||||
{
|
||||
camera_info=ci;
|
||||
}
|
||||
void SetCameraInfo(CameraInfo *ci){camera_info=ci;}
|
||||
|
||||
void Clear()
|
||||
{
|
||||
rn_list.Clear();
|
||||
}
|
||||
void Clear(){rn_list.Clear();}
|
||||
|
||||
void End();
|
||||
|
||||
|
@@ -2,7 +2,7 @@
|
||||
#include<hgl/graph/MaterialRenderList.h>
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
class MaterialRenderMap:public ObjectMap<Material *,MaterialRenderList>
|
||||
class MaterialRenderMap:public ObjectMap<RenderPipelineIndex,MaterialRenderList>
|
||||
{
|
||||
public:
|
||||
|
||||
|
@@ -2,7 +2,7 @@
|
||||
#define HGL_GRAPH_RENDER_NODE_INCLUDE
|
||||
|
||||
#include<hgl/graph/VK.h>
|
||||
#include<hgl/type/SortedSets.h>
|
||||
#include<hgl/type/SortedSet.h>
|
||||
namespace hgl
|
||||
{
|
||||
namespace graph
|
||||
@@ -11,9 +11,9 @@ namespace hgl
|
||||
class MaterialInstance;
|
||||
class SceneNode;
|
||||
|
||||
struct RenderNode
|
||||
struct RenderNode:public Comparator<RenderNode>
|
||||
{
|
||||
uint index; ///<在MaterialRenderList中的索引
|
||||
uint index; ///<在MaterialRenderList中的索引
|
||||
|
||||
SceneNode * scene_node;
|
||||
|
||||
@@ -22,12 +22,22 @@ namespace hgl
|
||||
|
||||
Vector3f world_position;
|
||||
float to_camera_distance;
|
||||
|
||||
public:
|
||||
|
||||
//该函数位于MaterialRenderList.cpp
|
||||
const int compare(const RenderNode &)const override;
|
||||
};
|
||||
|
||||
using RenderNodeList=List<RenderNode>;
|
||||
using RenderNodePointerList=List<RenderNode *>;
|
||||
|
||||
using MaterialInstanceSets=SortedSets<MaterialInstance *>; ///<材质实例集合
|
||||
using MaterialInstanceSets=SortedSet<MaterialInstance *>; ///<材质实例集合
|
||||
}//namespace graph
|
||||
|
||||
template<> inline const int ItemComparator<graph::RenderNode>::compare(const graph::RenderNode &a,const graph::RenderNode &b)
|
||||
{
|
||||
return a.compare(b);
|
||||
}
|
||||
}//namespace hgl
|
||||
#endif//HGL_GRAPH_RENDER_NODE_INCLUDE
|
||||
|
@@ -10,7 +10,7 @@ namespace hgl
|
||||
namespace graph
|
||||
{
|
||||
using SceneNodeID =uint64;
|
||||
using SceneNodeName =UTF16IDName;
|
||||
using SceneNodeName =U16IDName;
|
||||
|
||||
/**
|
||||
* 场景节点数据类<br>
|
||||
@@ -19,6 +19,8 @@ namespace hgl
|
||||
*/
|
||||
class SceneNode:public SceneOrient ///场景节点类
|
||||
{
|
||||
SceneNode *Owner; ///<上级节点
|
||||
|
||||
SceneNodeID NodeID; ///<节点ID
|
||||
SceneNodeName NodeName; ///<节点名称
|
||||
|
||||
@@ -59,6 +61,8 @@ namespace hgl
|
||||
{
|
||||
SceneOrient::Clear();
|
||||
|
||||
Owner=nullptr;
|
||||
|
||||
BoundingBox.SetZero();
|
||||
LocalBoundingBox.SetZero();
|
||||
|
||||
@@ -74,8 +78,13 @@ namespace hgl
|
||||
return(true);
|
||||
}
|
||||
|
||||
Renderable *GetRenderable(){return render_obj;}
|
||||
void SetRenderable(Renderable *);
|
||||
void SetOwner(SceneNode *sn) {Owner=sn;}
|
||||
SceneNode * GetOwner() noexcept{return Owner;}
|
||||
const SceneNode * GetOwner()const noexcept{return Owner;}
|
||||
|
||||
void SetRenderable(Renderable *);
|
||||
Renderable *GetRenderable() noexcept{return render_obj;}
|
||||
const Renderable *GetRenderable()const noexcept{return render_obj;}
|
||||
|
||||
SceneNode *Add(SceneNode *sn)
|
||||
{
|
||||
@@ -83,6 +92,7 @@ namespace hgl
|
||||
return(nullptr);
|
||||
|
||||
ChildNode.Add(sn);
|
||||
sn->SetOwner(this);
|
||||
return sn;
|
||||
}
|
||||
|
||||
|
@@ -37,7 +37,7 @@ class ImageView;
|
||||
class Framebuffer;
|
||||
struct Swapchain;
|
||||
class RenderTarget;
|
||||
class RTSwapchain;
|
||||
class SwapchainRenderTarget;
|
||||
|
||||
class Texture;
|
||||
class Texture1D;
|
||||
|
@@ -44,11 +44,12 @@ class RenderCmdBuffer:public GPUCmdBuffer
|
||||
VkRect2D render_area;
|
||||
VkViewport viewport;
|
||||
|
||||
Framebuffer *fbo;
|
||||
RenderPassBeginInfo rp_begin;
|
||||
VkPipelineLayout pipeline_layout;
|
||||
|
||||
void SetFBO(Framebuffer *);
|
||||
private:
|
||||
|
||||
void SetClear();
|
||||
|
||||
public:
|
||||
|
||||
@@ -78,7 +79,7 @@ public:
|
||||
|
||||
//以上设定在Begin开始后即不可改变
|
||||
|
||||
bool BindFramebuffer(RenderPass *rp,Framebuffer *fb);
|
||||
bool BindFramebuffer(Framebuffer *);
|
||||
|
||||
bool BeginRenderPass();
|
||||
void NextSubpass(){vkCmdNextSubpass(cmd_buf,VK_SUBPASS_CONTENTS_INLINE);}
|
||||
|
@@ -3,6 +3,7 @@
|
||||
|
||||
#include<hgl/graph/VK.h>
|
||||
#include<hgl/color/Color4f.h>
|
||||
#include<hgl/graph/VKTexture.h>
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
struct DebugUtilsFunction
|
||||
@@ -92,6 +93,13 @@ public:
|
||||
// DU_FUNC(BufferCollectionFuchsia, BUFFER_COLLECTION_FUCHSIA)
|
||||
|
||||
#undef DU_FUNC
|
||||
|
||||
void SetTexture(Texture *tex,const AnsiString &info)
|
||||
{
|
||||
SetImage( tex->GetImage(), info+"_Image" );
|
||||
SetImageView( tex->GetVulkanImageView(), info+"_ImageView" );
|
||||
SetDeviceMemory(tex->GetDeviceMemory(), info+"_Memory" );
|
||||
}
|
||||
|
||||
void QueueBegin (VkQueue,const char *,const Color4f &color=Color4f(1,1,1,1));
|
||||
void QueueEnd (VkQueue q){duf.QueueEnd(q);}
|
||||
|
@@ -4,7 +4,7 @@
|
||||
#include<hgl/graph/VK.h>
|
||||
#include<hgl/type/Map.h>
|
||||
#include<hgl/type/ObjectList.h>
|
||||
#include<hgl/type/SortedSets.h>
|
||||
#include<hgl/type/SortedSet.h>
|
||||
VK_NAMESPACE_BEGIN
|
||||
class DeviceBuffer;
|
||||
|
||||
@@ -20,7 +20,7 @@ class DescriptorSet
|
||||
ObjectList<VkDescriptorImageInfo> image_list;
|
||||
List<VkWriteDescriptorSet> wds_list;
|
||||
|
||||
SortedSets<uint32_t> binded_sets;
|
||||
SortedSet<uint32_t> binded_sets;
|
||||
|
||||
bool is_dirty;
|
||||
|
||||
|
@@ -38,11 +38,10 @@ class GPUDevice
|
||||
private:
|
||||
|
||||
DeviceRenderPassManage *render_pass_manage;
|
||||
RenderPass *device_render_pass;
|
||||
|
||||
RTSwapchain *sc_rt;
|
||||
SwapchainRenderTarget *sc_rt;
|
||||
|
||||
RTSwapchain *CreateSwapchainRenderTarget();
|
||||
SwapchainRenderTarget *CreateSwapchainRenderTarget();
|
||||
|
||||
void InitRenderPassManage();
|
||||
void ClearRenderPassManage();
|
||||
@@ -79,9 +78,9 @@ public:
|
||||
const VkColorSpaceKHR GetColorSpace ()const {return attr->surface_format.colorSpace;}
|
||||
VkQueue GetGraphicsQueue () {return attr->graphics_queue;}
|
||||
|
||||
RenderPass * GetRenderPass () {return device_render_pass;}
|
||||
RenderPass * GetRenderPass () {return sc_rt->GetRenderPass();}
|
||||
|
||||
RTSwapchain * GetSwapchainRT () {return sc_rt;}
|
||||
SwapchainRenderTarget * GetSwapchainRT () {return sc_rt;}
|
||||
|
||||
const VkExtent2D & GetSwapchainSize ()const {return sc_rt->GetExtent();}
|
||||
|
||||
|
@@ -1,12 +1,16 @@
|
||||
#ifndef HGL_VULKAN_DEVICE_RENDERPASS_MANAGE_INCLUDE
|
||||
#define HGL_VULKAN_DEVICE_RENDERPASS_MANAGE_INCLUDE
|
||||
#pragma once
|
||||
|
||||
#include<hgl/graph/VK.h>
|
||||
#include<hgl/type/Map.h>
|
||||
#include<hgl/util/hash/Hash.h>
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
using RenderPassHASHCode=util::HashCodeSHA1LE;
|
||||
|
||||
using RenderPassHASHCode=util::HashCode<128/8>;
|
||||
inline util::Hash *CreateRenderPassHash()
|
||||
{
|
||||
return util::CreateHash(util::HASH::xxH3_128);
|
||||
}
|
||||
|
||||
class DeviceRenderPassManage
|
||||
{
|
||||
@@ -34,4 +38,3 @@ private:
|
||||
RenderPass * AcquireRenderPass( const RenderbufferInfo *,const uint subpass_count=2);
|
||||
};//class DeviceRenderPassManage
|
||||
VK_NAMESPACE_END
|
||||
#endif//HGL_VULKAN_DEVICE_RENDERPASS_MANAGE_INCLUDE
|
||||
|
@@ -1,13 +1,13 @@
|
||||
#ifndef HGL_GRAPH_VULKAN_FRAMEBUFFER_INCLUDE
|
||||
#define HGL_GRAPH_VULKAN_FRAMEBUFFER_INCLUDE
|
||||
|
||||
#include<hgl/graph/VK.h>
|
||||
#include<hgl/graph/VKRenderPass.h>
|
||||
VK_NAMESPACE_BEGIN
|
||||
class Framebuffer
|
||||
{
|
||||
VkDevice device;
|
||||
VkFramebuffer frame_buffer;
|
||||
VkRenderPass render_pass;
|
||||
RenderPass *render_pass;
|
||||
|
||||
VkExtent2D extent;
|
||||
uint32_t attachment_count;
|
||||
@@ -18,7 +18,7 @@ private:
|
||||
|
||||
friend class GPUDevice;
|
||||
|
||||
Framebuffer(VkDevice,VkFramebuffer,const VkExtent2D &,VkRenderPass,uint32_t color_count,bool depth);
|
||||
Framebuffer(VkDevice,VkFramebuffer,const VkExtent2D &,RenderPass *,uint32_t color_count,bool depth);
|
||||
|
||||
public:
|
||||
|
||||
@@ -27,7 +27,7 @@ public:
|
||||
operator VkFramebuffer(){return frame_buffer;}
|
||||
|
||||
const VkFramebuffer GetFramebuffer ()const{return frame_buffer;}
|
||||
const VkRenderPass GetRenderPass ()const{return render_pass;}
|
||||
RenderPass * GetRenderPass () {return render_pass;}
|
||||
|
||||
const VkExtent2D & GetExtent ()const{return extent;}
|
||||
|
||||
|
@@ -95,6 +95,6 @@ public:
|
||||
MaterialInstance *CreateMI(const VILConfig *vil_cfg=nullptr);
|
||||
};//class Material
|
||||
|
||||
using MaterialSets=SortedSets<Material *>;
|
||||
using MaterialSets=SortedSet<Material *>;
|
||||
VK_NAMESPACE_END
|
||||
#endif//HGL_GRAPH_VULKAN_MATERIAL_INCLUDE
|
||||
|
@@ -2,7 +2,7 @@
|
||||
|
||||
#include<hgl/graph/VK.h>
|
||||
#include<hgl/type/String.h>
|
||||
#include<hgl/type/SortedSets.h>
|
||||
#include<hgl/type/SortedSet.h>
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
class GPUPhysicalDevice
|
||||
@@ -14,11 +14,13 @@ class GPUPhysicalDevice
|
||||
VkPhysicalDeviceVulkan11Features features11;
|
||||
VkPhysicalDeviceVulkan12Features features12;
|
||||
VkPhysicalDeviceVulkan13Features features13;
|
||||
VkPhysicalDeviceVulkan14Features features14;
|
||||
|
||||
VkPhysicalDeviceProperties properties;
|
||||
VkPhysicalDeviceVulkan11Properties properties11;
|
||||
VkPhysicalDeviceVulkan12Properties properties12;
|
||||
VkPhysicalDeviceVulkan13Properties properties13;
|
||||
VkPhysicalDeviceVulkan14Properties properties14;
|
||||
|
||||
VkPhysicalDeviceMemoryProperties memory_properties;
|
||||
List<VkLayerProperties> layer_properties;
|
||||
@@ -36,6 +38,7 @@ public:
|
||||
const VkPhysicalDeviceVulkan11Features &GetFeatures11 ()const{return features11;}
|
||||
const VkPhysicalDeviceVulkan12Features &GetFeatures12 ()const{return features12;}
|
||||
const VkPhysicalDeviceVulkan13Features &GetFeatures13 ()const{return features13;}
|
||||
const VkPhysicalDeviceVulkan14Features &GetFeatures14 ()const{return features14;}
|
||||
|
||||
const VkPhysicalDeviceProperties & GetProperties ()const{return properties;}
|
||||
const VkPhysicalDeviceMemoryProperties &GetMemoryProperties ()const{return memory_properties;}
|
||||
@@ -66,7 +69,11 @@ public:
|
||||
const uint32_t GetSSBORange ()const{return properties.limits.maxStorageBufferRange;}
|
||||
const VkDeviceSize GetSSBOAlign ()const{return properties.limits.minStorageBufferOffsetAlignment;}
|
||||
|
||||
const uint32_t GetConstantSize ()const{return properties.limits.maxPushConstantsSize;}
|
||||
const uint32_t GetConstantSize ()const{return properties.limits.maxPushConstantsSize;}
|
||||
|
||||
const VkDeviceSize GetMaxBufferSize()const{return properties13.maxBufferSize;}
|
||||
|
||||
const uint32_t GetMaxPushDescriptors()const{return properties14.maxPushDescriptors;}
|
||||
|
||||
public:
|
||||
|
||||
@@ -182,6 +189,9 @@ public:
|
||||
const VkBool32 SupportYcbcrConversion ()const{return features11.samplerYcbcrConversion;}
|
||||
const VkBool32 SupportClampMirrorToEdge ()const{return features12.samplerMirrorClampToEdge;}
|
||||
|
||||
const VkBool32 SupportSmoothLines ()const{return features14.smoothLines;}
|
||||
const VkBool32 SupportStippledSmoothLines ()const{return features14.stippledSmoothLines;}
|
||||
|
||||
const void GetPointSize(float &granularity,float &min_size,float &max_size) const
|
||||
{
|
||||
granularity =properties.limits.pointSizeGranularity;
|
||||
|
@@ -37,8 +37,10 @@ public:
|
||||
|
||||
virtual ~RenderPass();
|
||||
|
||||
VkRenderPass GetVkRenderPass(){return render_pass;}
|
||||
VkPipelineCache GetPipelineCache(){return pipeline_cache;}
|
||||
operator const VkRenderPass()const{return render_pass;}
|
||||
|
||||
const VkRenderPass GetVkRenderPass()const{return render_pass;}
|
||||
const VkPipelineCache GetPipelineCache()const{return pipeline_cache;}
|
||||
|
||||
const uint GetColorCount()const{return color_formats.GetCount();}
|
||||
const List<VkFormat> & GetColorFormat()const{return color_formats;}
|
||||
|
@@ -1,5 +1,4 @@
|
||||
#ifndef HGL_GRAPH_VULKAN_RENDER_TARGET_INCLUDE
|
||||
#define HGL_GRAPH_VULKAN_RENDER_TARGET_INCLUDE
|
||||
#pragma once
|
||||
|
||||
#include<hgl/graph/VK.h>
|
||||
#include<hgl/graph/VKRenderPass.h>
|
||||
@@ -7,63 +6,216 @@
|
||||
#include<hgl/graph/VKSwapchain.h>
|
||||
#include<hgl/graph/VKQueue.h>
|
||||
#include<hgl/graph/VKPipeline.h>
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
/**
|
||||
* 渲染目标
|
||||
*/
|
||||
class RenderTarget
|
||||
* RenderTarget 存在几种情况:
|
||||
*
|
||||
* 1.正常单帧渲染目标,即只有一帧的数据,每次渲染都是当前帧
|
||||
*
|
||||
* 2.多帧渲染目标,即有多帧数据,每次渲染都是指定帧,典型的是Swapchain
|
||||
*
|
||||
* 所以RenderTarget的其实是一个多态类,根据不同的情况,有不同的实现
|
||||
*/
|
||||
|
||||
class IRenderTarget
|
||||
{
|
||||
protected:
|
||||
|
||||
DeviceQueue *queue;
|
||||
|
||||
RenderPass *render_pass;
|
||||
Framebuffer *fbo;
|
||||
|
||||
VkExtent2D extent;
|
||||
|
||||
Semaphore *render_complete_semaphore =nullptr;
|
||||
public:
|
||||
|
||||
protected:
|
||||
const VkExtent2D &GetExtent ()const{return extent;}
|
||||
|
||||
uint32_t color_count;
|
||||
Texture2D **color_textures;
|
||||
Texture2D *depth_texture;
|
||||
virtual uint32_t GetColorCount ()=0;
|
||||
virtual bool hasDepth ()=0;
|
||||
|
||||
public:
|
||||
|
||||
IRenderTarget(const VkExtent2D &ext){extent=ext;}
|
||||
virtual ~IRenderTarget()=default;
|
||||
|
||||
virtual Framebuffer * GetFramebuffer ()=0;
|
||||
virtual RenderPass * GetRenderPass ()=0;
|
||||
|
||||
virtual Texture2D * GetColorTexture (const int index=0)=0;
|
||||
virtual Texture2D * GetDepthTexture ()=0;
|
||||
|
||||
public: // Command Buffer
|
||||
|
||||
virtual DeviceQueue * GetQueue ()=0;
|
||||
virtual Semaphore * GetRenderCompleteSemaphore()=0;
|
||||
|
||||
virtual RenderCmdBuffer * GetRenderCmdBuffer ()=0;
|
||||
|
||||
virtual bool Submit (Semaphore *wait_sem)=0;
|
||||
|
||||
virtual bool Submit (){return Submit(nullptr);}
|
||||
|
||||
virtual bool WaitQueue ()=0;
|
||||
virtual bool WaitFence ()=0;
|
||||
};//class IRenderTarget
|
||||
|
||||
struct RenderTargetData
|
||||
{
|
||||
Framebuffer * fbo;
|
||||
DeviceQueue * queue;
|
||||
Semaphore * render_complete_semaphore;
|
||||
|
||||
RenderCmdBuffer * cmd_buf;
|
||||
|
||||
uint32_t color_count; ///<颜色成分数量
|
||||
Texture2D ** color_textures; ///<颜色成分纹理列表
|
||||
Texture2D * depth_texture; ///<深度成分纹理
|
||||
|
||||
public:
|
||||
|
||||
Texture2D *GetColorTexture(const uint32_t index)
|
||||
{
|
||||
if(index>=color_count)
|
||||
return(nullptr);
|
||||
|
||||
return color_textures[index];
|
||||
}
|
||||
|
||||
virtual void Clear();
|
||||
};//struct RenderTargetData
|
||||
|
||||
/**
|
||||
* 单帧渲染目标
|
||||
*/
|
||||
class RenderTarget:public IRenderTarget
|
||||
{
|
||||
RenderTargetData *data;
|
||||
|
||||
protected:
|
||||
|
||||
friend class GPUDevice;
|
||||
|
||||
RenderTarget(DeviceQueue *,Semaphore *);
|
||||
RenderTarget(DeviceQueue *,Semaphore *,RenderPass *_rp,Framebuffer *_fb,Texture2D **color_texture_list,const uint32_t color_count,Texture2D *depth_texture);
|
||||
RenderTarget(RenderTargetData *rtd):IRenderTarget(rtd->fbo->GetExtent())
|
||||
{
|
||||
data=rtd;
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
virtual ~RenderTarget();
|
||||
virtual ~RenderTarget()
|
||||
{
|
||||
if(data)
|
||||
{
|
||||
data->Clear();
|
||||
delete data;
|
||||
}
|
||||
}
|
||||
|
||||
Framebuffer * GetFramebuffer ()override{return data->fbo;}
|
||||
RenderPass * GetRenderPass ()override{return data->fbo->GetRenderPass();}
|
||||
|
||||
uint32_t GetColorCount ()override{return data->color_count;}
|
||||
|
||||
DeviceQueue * GetQueue () {return queue;}
|
||||
const VkExtent2D & GetExtent ()const {return extent;}
|
||||
virtual RenderPass * GetRenderPass () {return render_pass;}
|
||||
virtual const VkRenderPass GetVkRenderPass ()const {return render_pass->GetVkRenderPass();}
|
||||
virtual const uint32_t GetColorCount ()const {return fbo->GetColorCount();}
|
||||
virtual Framebuffer * GetFramebuffer () {return fbo;}
|
||||
bool hasDepth ()override{return data->depth_texture;}
|
||||
|
||||
virtual Texture2D * GetColorTexture (const int index=0){return color_textures[index];}
|
||||
virtual Texture2D * GetDepthTexture (){return depth_texture;}
|
||||
Texture2D * GetColorTexture (const int index=0) override{return data->GetColorTexture(index);}
|
||||
Texture2D * GetDepthTexture () override{return data->depth_texture;}
|
||||
|
||||
public: // command buffer
|
||||
public: // Command Buffer
|
||||
|
||||
Semaphore * GetRenderCompleteSemaphore (){return render_complete_semaphore;}
|
||||
virtual bool Submit (RenderCmdBuffer *,Semaphore *present_complete_semaphore=nullptr);
|
||||
DeviceQueue * GetQueue ()override{return data->queue;}
|
||||
Semaphore * GetRenderCompleteSemaphore()override{return data->render_complete_semaphore;}
|
||||
|
||||
bool WaitQueue(){return queue->WaitQueue();}
|
||||
bool WaitFence(){return queue->WaitFence();}
|
||||
RenderCmdBuffer * GetRenderCmdBuffer ()override{return data->cmd_buf;}
|
||||
|
||||
virtual bool Submit (Semaphore *wait_sem)override
|
||||
{
|
||||
if(!data)
|
||||
return(false);
|
||||
|
||||
return data->queue->Submit(*data->cmd_buf,wait_sem,data->render_complete_semaphore);
|
||||
}
|
||||
|
||||
bool WaitQueue ()override{return data->queue->WaitQueue();}
|
||||
bool WaitFence ()override{return data->queue->WaitFence();}
|
||||
};//class RenderTarget
|
||||
|
||||
/**
|
||||
* 多帧渲染目标
|
||||
*/
|
||||
class MFRenderTarget:public IRenderTarget
|
||||
{
|
||||
protected:
|
||||
|
||||
uint32_t frame_number;
|
||||
uint32_t current_frame;
|
||||
|
||||
RenderTarget **rt_list;
|
||||
|
||||
protected:
|
||||
|
||||
friend class GPUDevice;
|
||||
|
||||
MFRenderTarget(const uint32_t fn,RenderTarget **rtl):IRenderTarget(rtl[0]->GetFramebuffer()->GetExtent())
|
||||
{
|
||||
frame_number=fn;
|
||||
current_frame=0;
|
||||
|
||||
rt_list=rtl;
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
virtual ~MFRenderTarget()
|
||||
{
|
||||
SAFE_CLEAR_OBJECT_ARRAY_OBJECT(rt_list,frame_number);
|
||||
}
|
||||
|
||||
virtual void NextFrame()
|
||||
{
|
||||
++current_frame;
|
||||
|
||||
if(current_frame>=frame_number)
|
||||
current_frame=0;
|
||||
}
|
||||
|
||||
uint32_t GetCurrentFrameIndices ()const{return current_frame;}
|
||||
uint32_t GetFrameCount ()const{return frame_number;}
|
||||
RenderTarget * GetCurrentFrameRenderTarget (){return rt_list[current_frame];}
|
||||
|
||||
public:
|
||||
|
||||
Framebuffer * GetFramebuffer ()override{return rt_list[current_frame]->GetFramebuffer();}
|
||||
RenderPass * GetRenderPass ()override{return rt_list[current_frame]->GetRenderPass();}
|
||||
|
||||
uint32_t GetColorCount ()override{return rt_list[current_frame]->GetColorCount();}
|
||||
|
||||
Texture2D * GetColorTexture (const int index=0) override{return rt_list[current_frame]->GetColorTexture(index);}
|
||||
Texture2D * GetDepthTexture () override{return rt_list[current_frame]->GetDepthTexture();}
|
||||
|
||||
|
||||
bool hasDepth ()override{return rt_list[current_frame]->hasDepth();}
|
||||
|
||||
public: // Command Buffer
|
||||
|
||||
DeviceQueue * GetQueue ()override{return rt_list[current_frame]->GetQueue();}
|
||||
Semaphore * GetRenderCompleteSemaphore()override{return rt_list[current_frame]->GetRenderCompleteSemaphore();}
|
||||
RenderCmdBuffer * GetRenderCmdBuffer ()override{return rt_list[current_frame]->GetRenderCmdBuffer();}
|
||||
|
||||
Framebuffer * GetFramebuffer (const uint32_t index){return rt_list[index]->GetFramebuffer();}
|
||||
RenderCmdBuffer * GetRenderCmdBuffer (const uint32_t index){return rt_list[index]->GetRenderCmdBuffer();}
|
||||
|
||||
virtual bool Submit ()override{return rt_list[current_frame]->Submit(nullptr);}
|
||||
|
||||
virtual bool Submit (Semaphore *wait_sem) override
|
||||
{
|
||||
return rt_list[current_frame]->Submit(wait_sem);
|
||||
}
|
||||
|
||||
bool WaitQueue ()override{return rt_list[current_frame]->WaitQueue();}
|
||||
bool WaitFence ()override{return rt_list[current_frame]->WaitFence();}
|
||||
};//class MFRenderTarget
|
||||
|
||||
/**
|
||||
* 交换链专用渲染目标
|
||||
*/
|
||||
class RTSwapchain:public RenderTarget
|
||||
class SwapchainRenderTarget:public MFRenderTarget
|
||||
{
|
||||
VkDevice device;
|
||||
Swapchain *swapchain;
|
||||
@@ -71,45 +223,25 @@ class RTSwapchain:public RenderTarget
|
||||
|
||||
Semaphore *present_complete_semaphore=nullptr;
|
||||
|
||||
uint32_t current_frame;
|
||||
private:
|
||||
|
||||
SwapchainRenderTarget(VkDevice dev,Swapchain *sc,Semaphore *pcs,RenderTarget **rtl);
|
||||
|
||||
friend class GPUDevice;
|
||||
|
||||
public:
|
||||
|
||||
RTSwapchain(VkDevice dev,Swapchain *sc,DeviceQueue *q,Semaphore *rcs,Semaphore *pcs,RenderPass *rp);
|
||||
~RTSwapchain();
|
||||
|
||||
Framebuffer * GetFramebuffer ()override {return swapchain->sc_fbo[current_frame];}
|
||||
Framebuffer * GetFramebuffer (const uint32_t index) {return swapchain->sc_fbo[index];}
|
||||
|
||||
const uint32_t GetColorCount ()const override {return 1;}
|
||||
const uint32_t GetImageCount ()const {return swapchain->color_count;}
|
||||
|
||||
virtual Texture2D * GetColorTexture (const int index=0) override{return swapchain->sc_color[index];}
|
||||
virtual Texture2D * GetDepthTexture () override{return swapchain->sc_depth;}
|
||||
~SwapchainRenderTarget();
|
||||
|
||||
public:
|
||||
|
||||
const uint32_t GetCurrentFrameIndices ()const {return current_frame;}
|
||||
Semaphore * GetPresentCompleteSemaphore () {return present_complete_semaphore;}
|
||||
int AcquireNextImage(); ///<获取下一帧的索引
|
||||
|
||||
public:
|
||||
bool PresentBackbuffer(); ///<推送后台画面到前台
|
||||
|
||||
/**
|
||||
* 请求下一帧画面的索引
|
||||
* @param present_complete_semaphore 推送完成信号
|
||||
*/
|
||||
int AcquireNextImage();
|
||||
|
||||
/**
|
||||
* 推送后台画面到前台
|
||||
* @param render_complete_semaphore 渲染完成信号
|
||||
*/
|
||||
bool PresentBackbuffer(VkSemaphore *wait_semaphores,const uint32_t wait_semaphore_count);
|
||||
|
||||
bool PresentBackbuffer();
|
||||
|
||||
bool Submit(VkCommandBuffer);
|
||||
bool Submit(VkCommandBuffer,Semaphore *);
|
||||
bool Submit()override
|
||||
{
|
||||
return rt_list[current_frame]->Submit(present_complete_semaphore);
|
||||
}
|
||||
};//class RTSwapchain:public RenderTarget
|
||||
VK_NAMESPACE_END
|
||||
#endif//HGL_GRAPH_VULKAN_RENDER_TARGET_INCLUDE
|
||||
|
@@ -12,7 +12,7 @@ VK_NAMESPACE_BEGIN
|
||||
* 原始图元数据缓冲区<Br>
|
||||
* 提供在渲染之前的数据绑定信息
|
||||
*/
|
||||
struct PrimitiveDataBuffer
|
||||
struct PrimitiveDataBuffer:public Comparator<PrimitiveDataBuffer>
|
||||
{
|
||||
uint32_t vab_count;
|
||||
VkBuffer * vab_list;
|
||||
@@ -32,14 +32,14 @@ public:
|
||||
PrimitiveDataBuffer(const uint32_t,IndexBuffer *,VertexDataManager *_v=nullptr);
|
||||
~PrimitiveDataBuffer();
|
||||
|
||||
const bool Comp(const PrimitiveDataBuffer *pdb)const;
|
||||
const int compare(const PrimitiveDataBuffer &pdb)const override;
|
||||
};//struct PrimitiveDataBuffer
|
||||
|
||||
/**
|
||||
* 原始图元渲染数据<Br>
|
||||
* 提供在渲染时的数据
|
||||
*/
|
||||
struct PrimitiveRenderData
|
||||
struct PrimitiveRenderData:public ComparatorData<PrimitiveRenderData>
|
||||
{
|
||||
//因为要VAB是流式访问,所以我们这个结构会被用做排序依据
|
||||
//也因此,把vertex_offset放在最前面
|
||||
@@ -59,9 +59,6 @@ public:
|
||||
vertex_offset =vo;
|
||||
first_index =fi;
|
||||
}
|
||||
|
||||
CompOperatorMemcmp(const PrimitiveRenderData &);
|
||||
CompOperatorMemcmpPointer(PrimitiveRenderData);
|
||||
};
|
||||
|
||||
/**
|
||||
|
@@ -3,7 +3,7 @@
|
||||
|
||||
#include<hgl/graph/VK.h>
|
||||
#include<hgl/graph/VKVertexInputLayout.h>
|
||||
#include<hgl/type/SortedSets.h>
|
||||
#include<hgl/type/SortedSet.h>
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
|
||||
|
@@ -1,30 +1,53 @@
|
||||
#ifndef HGL_GRAPH_VULKAN_SWAP_CHAIN_INCLUDE
|
||||
#define HGL_GRAPH_VULKAN_SWAP_CHAIN_INCLUDE
|
||||
#pragma once
|
||||
|
||||
#include<hgl/graph/VK.h>
|
||||
#include<hgl/graph/VKTexture.h>
|
||||
#include<hgl/type/List.h>
|
||||
#include<hgl/graph/VKFramebuffer.h>
|
||||
#include<hgl/graph/VKCommandBuffer.h>
|
||||
VK_NAMESPACE_BEGIN
|
||||
|
||||
struct SwapchainImage
|
||||
{
|
||||
Texture2D * color =nullptr;
|
||||
Texture2D * depth =nullptr;
|
||||
|
||||
Framebuffer * fbo =nullptr;
|
||||
|
||||
RenderCmdBuffer * cmd_buf =nullptr;
|
||||
|
||||
public:
|
||||
|
||||
~SwapchainImage()
|
||||
{
|
||||
delete cmd_buf;
|
||||
delete fbo;
|
||||
delete depth;
|
||||
delete color;
|
||||
}
|
||||
};//struct SwapchainImage
|
||||
|
||||
struct Swapchain
|
||||
{
|
||||
public:
|
||||
|
||||
VkDevice device =VK_NULL_HANDLE;
|
||||
VkDevice device =VK_NULL_HANDLE;
|
||||
|
||||
VkExtent2D extent;
|
||||
VkExtent2D extent;
|
||||
VkSurfaceTransformFlagBitsKHR transform;
|
||||
|
||||
VkSwapchainKHR swap_chain =VK_NULL_HANDLE;
|
||||
VkSwapchainKHR swap_chain =VK_NULL_HANDLE;
|
||||
VkSurfaceFormatKHR surface_format;
|
||||
VkFormat depth_format;
|
||||
|
||||
uint32_t color_count =0;
|
||||
RenderPass * render_pass =nullptr;
|
||||
|
||||
Texture2D ** sc_color =nullptr;
|
||||
Texture2D * sc_depth =nullptr;
|
||||
uint32_t image_count =0;
|
||||
|
||||
Framebuffer ** sc_fbo =nullptr;
|
||||
SwapchainImage * sc_image =nullptr;
|
||||
|
||||
public:
|
||||
|
||||
virtual ~Swapchain();
|
||||
};//struct Swapchain
|
||||
VK_NAMESPACE_END
|
||||
#endif//HGL_GRAPH_VULKAN_SWAP_CHAIN_INCLUDE
|
||||
|
@@ -12,7 +12,7 @@ namespace hgl
|
||||
/**
|
||||
* 字体信息
|
||||
*/
|
||||
struct Font
|
||||
struct Font:public ComparatorData<Font>
|
||||
{
|
||||
os_char name[MAX_FONT_NAME_LENGTH]; ///<字体名称
|
||||
|
||||
@@ -28,8 +28,6 @@ namespace hgl
|
||||
|
||||
Font();
|
||||
Font(const os_char *,int,int,bool b=false,bool i=false,bool=true);
|
||||
|
||||
CompOperatorMemcmp(const Font &); ///<比较操作符重载
|
||||
};//struct Font
|
||||
}//namespace graph
|
||||
}//namespace hgl
|
||||
|
@@ -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,10 +24,10 @@ namespace hgl
|
||||
friend class TextLayout;
|
||||
friend class TextRender;
|
||||
|
||||
SortedSets<u32char> chars_sets;
|
||||
SortedSet<u32char> chars_sets;
|
||||
|
||||
const SortedSets<u32char> &GetCharsSets()const{return chars_sets;}
|
||||
void SetCharsSets(const SortedSets<u32char> &sl){chars_sets=sl;}
|
||||
const SortedSet<u32char> &GetCharsSets()const{return chars_sets;}
|
||||
void SetCharsSets(const SortedSet<u32char> &sl){chars_sets=sl;}
|
||||
void ClearCharsSets(){chars_sets.Clear();}
|
||||
|
||||
private:
|
||||
|
@@ -54,9 +54,9 @@ namespace hgl
|
||||
public:
|
||||
|
||||
TextPrimitive *CreatePrimitive();
|
||||
TextPrimitive *CreatePrimitive(const UTF16String &str);
|
||||
TextPrimitive *CreatePrimitive(const U16String &str);
|
||||
|
||||
bool Layout(TextPrimitive *tr,const UTF16String &str);
|
||||
bool Layout(TextPrimitive *tr,const U16String &str);
|
||||
|
||||
Renderable *CreateRenderable(TextPrimitive *text_primitive);
|
||||
|
||||
|
@@ -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
|
||||
|
@@ -6,7 +6,7 @@
|
||||
#include<hgl/graph/VertexAttrib.h>
|
||||
|
||||
STD_MTL_NAMESPACE_BEGIN
|
||||
struct Material2DCreateConfig:public MaterialCreateConfig
|
||||
struct Material2DCreateConfig:public MaterialCreateConfig,public Comparator<Material2DCreateConfig>
|
||||
{
|
||||
CoordinateSystem2D coordinate_system; ///<使用的坐标系
|
||||
|
||||
@@ -32,9 +32,9 @@ public:
|
||||
position_format=VAT_VEC2;
|
||||
}
|
||||
|
||||
int Comp(const Material2DCreateConfig &cfg)const
|
||||
const int compare(const Material2DCreateConfig &cfg)const override
|
||||
{
|
||||
int off=MaterialCreateConfig::Comp(cfg);
|
||||
int off=MaterialCreateConfig::compare(cfg);
|
||||
|
||||
if(off)return off;
|
||||
|
||||
@@ -48,8 +48,6 @@ public:
|
||||
|
||||
return off;
|
||||
}
|
||||
|
||||
CompOperator(const Material2DCreateConfig &,Comp)
|
||||
};//struct Material2DCreateConfig:public MaterialCreateConfig
|
||||
|
||||
MaterialCreateInfo *CreateVertexColor2D(const Material2DCreateConfig *);
|
||||
|
@@ -5,58 +5,8 @@
|
||||
#include<hgl/graph/VertexAttrib.h>
|
||||
|
||||
STD_MTL_NAMESPACE_BEGIN
|
||||
enum class LightingModel:uint8
|
||||
{
|
||||
Unlit,
|
||||
|
||||
Gizmo, ///<Gizmo专用(Blinnphong的特定版本,内置假的太阳光方向、高光系数等,使其不需要外部UBO传入)
|
||||
|
||||
Blinnphong, ///<Blinnphong光照模型
|
||||
|
||||
FakePBR, ///<假PBR(使用Blinnphong+HalfLambert模拟)
|
||||
MicroPBR, ///<微型PBR(只有BaseColor/Normal/Metallic/Roughness四个基础数据的PBR)
|
||||
|
||||
WebPBR, ///<Khronos为WebGL提供的PBR
|
||||
FilamentPBR, ///<Filament引擎所使用的PBR
|
||||
AMDPBR, ///<AMD Caulrdon框架所使用的PBR
|
||||
|
||||
BlenderPBR, ///<Blender所使用的PBR
|
||||
|
||||
ENUM_CLASS_RANGE(Unlit,BlenderPBR)
|
||||
};
|
||||
|
||||
constexpr const char *LightingModelName[]=
|
||||
{
|
||||
"Unlit",
|
||||
|
||||
"Gizmo",
|
||||
|
||||
"Blinnphong",
|
||||
|
||||
"FakePBR",
|
||||
"MicroPBR",
|
||||
|
||||
"WebPBR",
|
||||
"FilamentPBR",
|
||||
"AMDPBR",
|
||||
|
||||
"BlenderPBR"
|
||||
};
|
||||
|
||||
/**
|
||||
* 天光来源
|
||||
*/
|
||||
enum class SkyLightSource:uint8
|
||||
{
|
||||
PureColor, ///<纯色
|
||||
Simplest, ///<极简(一行代码)
|
||||
Cubemap, ///<立方体贴图
|
||||
IBL, ///<IBL立方体贴图
|
||||
|
||||
ENUM_CLASS_RANGE(PureColor,IBL)
|
||||
};
|
||||
|
||||
struct Material3DCreateConfig:public MaterialCreateConfig
|
||||
struct Material3DCreateConfig:public MaterialCreateConfig,public Comparator<Material3DCreateConfig>
|
||||
{
|
||||
bool camera; ///<包含摄像机矩阵信息
|
||||
|
||||
@@ -82,9 +32,9 @@ public:
|
||||
// reverse_depth=false;
|
||||
}
|
||||
|
||||
int Comp(const Material3DCreateConfig &cfg)const
|
||||
const int compare(const Material3DCreateConfig &cfg)const override
|
||||
{
|
||||
int off=MaterialCreateConfig::Comp(cfg);
|
||||
int off=MaterialCreateConfig::compare(cfg);
|
||||
|
||||
if(off)return off;
|
||||
|
||||
@@ -98,8 +48,6 @@ public:
|
||||
|
||||
return off;
|
||||
}
|
||||
|
||||
CompOperator(const Material3DCreateConfig &,Comp)
|
||||
};//struct Material3DCreateConfig:public MaterialCreateConfig
|
||||
|
||||
MaterialCreateInfo *CreateVertexColor3D(const Material3DCreateConfig *);
|
||||
|
@@ -13,7 +13,7 @@ class MaterialCreateInfo;
|
||||
/**
|
||||
* 材质配置结构
|
||||
*/
|
||||
struct MaterialCreateConfig
|
||||
struct MaterialCreateConfig:public Comparator<MaterialCreateConfig>
|
||||
{
|
||||
const GPUDeviceAttribute *dev_attr;
|
||||
|
||||
@@ -42,7 +42,7 @@ public:
|
||||
prim=p;
|
||||
}
|
||||
|
||||
virtual int Comp(const MaterialCreateConfig &cfg)const
|
||||
const int compare(const MaterialCreateConfig &cfg)const override
|
||||
{
|
||||
int off;
|
||||
|
||||
@@ -59,8 +59,6 @@ public:
|
||||
|
||||
return off;
|
||||
}
|
||||
|
||||
CompOperator(const MaterialCreateConfig &,Comp)
|
||||
};//struct MaterialCreateConfig
|
||||
STD_MTL_NAMESPACE_END
|
||||
#endif//HGL_GRAPH_MTL_CONFIG_INCLUDE
|
||||
|
@@ -6,551 +6,436 @@
|
||||
#include<hgl/graph/VKInterpolation.h>
|
||||
#include<hgl/graph/VKSamplerType.h>
|
||||
#include<hgl/graph/VKImageType.h>
|
||||
#include<hgl/CompOperator.h>
|
||||
#include<hgl/Comparator.h>
|
||||
|
||||
namespace hgl
|
||||
VK_NAMESPACE_BEGIN
|
||||
enum class ShaderVariableBaseType:uint8
|
||||
{
|
||||
namespace graph
|
||||
{
|
||||
enum class ShaderVariableBaseType:uint8
|
||||
{
|
||||
Scalar=0,
|
||||
Vector,
|
||||
Matrix,
|
||||
Sampler,
|
||||
Image,
|
||||
AtomicCounter,
|
||||
Scalar=0,
|
||||
Vector,
|
||||
Matrix,
|
||||
Sampler,
|
||||
Image,
|
||||
AtomicCounter,
|
||||
|
||||
ENUM_CLASS_RANGE(Scalar,AtomicCounter)
|
||||
};//enum class ShaderVariableBaseType
|
||||
ENUM_CLASS_RANGE(Scalar,AtomicCounter)
|
||||
};//enum class ShaderVariableBaseType
|
||||
|
||||
using SVBaseType=ShaderVariableBaseType;
|
||||
using SVBaseType=ShaderVariableBaseType;
|
||||
|
||||
#pragma pack(push,1)
|
||||
#pragma pack(push,1)
|
||||
|
||||
struct ShaderVariableType
|
||||
struct ShaderVariableType:public Comparator<ShaderVariableType>
|
||||
{
|
||||
union
|
||||
{
|
||||
struct
|
||||
{
|
||||
union
|
||||
{
|
||||
struct
|
||||
{
|
||||
SVBaseType base_type;
|
||||
|
||||
union
|
||||
{
|
||||
struct
|
||||
struct Scalar
|
||||
{
|
||||
SVBaseType base_type;
|
||||
VABaseType type;
|
||||
}scalar;
|
||||
|
||||
union
|
||||
{
|
||||
struct Scalar
|
||||
{
|
||||
VABaseType type;
|
||||
}scalar;
|
||||
struct Vector
|
||||
{
|
||||
VABaseType type;
|
||||
uint8 vec_size;
|
||||
}vector;
|
||||
|
||||
struct Vector
|
||||
{
|
||||
VABaseType type;
|
||||
uint8 vec_size;
|
||||
}vector;
|
||||
struct Matrix
|
||||
{
|
||||
VABaseType type;
|
||||
uint8 n;
|
||||
uint8 m;
|
||||
}matrix;
|
||||
|
||||
struct Matrix
|
||||
{
|
||||
VABaseType type;
|
||||
uint8 n;
|
||||
uint8 m;
|
||||
}matrix;
|
||||
struct Sampler
|
||||
{
|
||||
SamplerType type;
|
||||
}sampler;
|
||||
|
||||
struct Sampler
|
||||
{
|
||||
SamplerType type;
|
||||
}sampler;
|
||||
|
||||
struct Image
|
||||
{
|
||||
ShaderImageType type;
|
||||
}image;
|
||||
};
|
||||
};
|
||||
|
||||
uint32 type_code;
|
||||
struct Image
|
||||
{
|
||||
ShaderImageType type;
|
||||
}image;
|
||||
};
|
||||
|
||||
uint32 array_size;
|
||||
};
|
||||
|
||||
uint64 svt_code;
|
||||
uint32 type_code;
|
||||
};
|
||||
|
||||
public:
|
||||
|
||||
ShaderVariableType()
|
||||
{
|
||||
svt_code=0;
|
||||
}
|
||||
|
||||
ShaderVariableType(const ShaderVariableType &svt)
|
||||
{
|
||||
svt_code=svt.svt_code;
|
||||
}
|
||||
|
||||
ShaderVariableType(const VAType &vat,const uint count)
|
||||
{
|
||||
From(vat,count);
|
||||
}
|
||||
|
||||
ShaderVariableType(const VABaseType &vabt,const uint32 count)
|
||||
{
|
||||
svt_code=0;
|
||||
|
||||
base_type=SVBaseType::Scalar;
|
||||
|
||||
scalar.type=vabt;
|
||||
|
||||
array_size=count;
|
||||
}
|
||||
|
||||
ShaderVariableType(const VABaseType &vabt,const uint8 size,const uint32 count)
|
||||
{
|
||||
svt_code=0;
|
||||
|
||||
base_type=SVBaseType::Vector;
|
||||
|
||||
vector.type=vabt;
|
||||
vector.vec_size=size;
|
||||
|
||||
array_size=count;
|
||||
}
|
||||
|
||||
ShaderVariableType(const VABaseType &vabt,const uint8 row,const uint8 col,const uint32 count)
|
||||
{
|
||||
svt_code=0;
|
||||
|
||||
base_type=SVBaseType::Matrix;
|
||||
|
||||
matrix.type=vabt;
|
||||
matrix.n=col;
|
||||
matrix.m=row;
|
||||
|
||||
array_size=count;
|
||||
}
|
||||
|
||||
ShaderVariableType(const SamplerType &st,const uint32 count)
|
||||
{
|
||||
svt_code=0;
|
||||
|
||||
base_type=SVBaseType::Sampler;
|
||||
|
||||
sampler.type=st;
|
||||
|
||||
array_size=count;
|
||||
}
|
||||
|
||||
ShaderVariableType(const ShaderImageType &sit,const uint32 count)
|
||||
{
|
||||
svt_code=0;
|
||||
|
||||
base_type=SVBaseType::Image;
|
||||
|
||||
image.type=sit;
|
||||
|
||||
array_size=count;
|
||||
}
|
||||
|
||||
const bool Check()const
|
||||
{
|
||||
if(!RangeCheck(base_type))return(false);
|
||||
|
||||
RANGE_CHECK_RETURN_FALSE(base_type)
|
||||
|
||||
if(base_type==SVBaseType::Scalar)
|
||||
return(true);
|
||||
|
||||
if(base_type==SVBaseType::Vector)
|
||||
{
|
||||
if(vector.vec_size<2||vector.vec_size>4)return(false);
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
if(base_type==SVBaseType::Matrix)
|
||||
{
|
||||
if(matrix.m==0)
|
||||
{
|
||||
if(matrix.n<2||matrix.n>4)return(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(matrix.n<2||matrix.n>4)return(false);
|
||||
if(matrix.m<2||matrix.m>4)return(false);
|
||||
}
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
if(base_type==SVBaseType::Sampler)
|
||||
return RangeCheck(sampler.type);
|
||||
|
||||
if(base_type==SVBaseType::Image)
|
||||
return RangeCheck(image.type);
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
int Comp(const ShaderVariableType &svt)const
|
||||
{
|
||||
int off=(int)base_type-(int)svt.base_type;
|
||||
|
||||
if(off)return(off);
|
||||
|
||||
if(base_type==SVBaseType::Scalar)
|
||||
return int(scalar.type)-int(svt.scalar.type);
|
||||
|
||||
if(base_type==SVBaseType::Vector)
|
||||
{
|
||||
off=int(vector.type)-int(svt.vector.type);
|
||||
|
||||
if(off)return(off);
|
||||
|
||||
off=vector.vec_size-svt.vector.vec_size;
|
||||
|
||||
if(off)return(off);
|
||||
|
||||
return int(vector.type)-int(svt.vector.type);
|
||||
}
|
||||
|
||||
if(base_type==SVBaseType::Matrix)
|
||||
{
|
||||
off=int(matrix.type)-int(svt.matrix.type);
|
||||
|
||||
if(off)return(off);
|
||||
|
||||
off=matrix.n-svt.matrix.n;
|
||||
|
||||
if(off)return(off);
|
||||
|
||||
return matrix.m-svt.matrix.m;
|
||||
}
|
||||
|
||||
if(base_type==SVBaseType::Sampler)
|
||||
return int(sampler.type)-int(svt.sampler.type);
|
||||
|
||||
if(base_type==SVBaseType::Image)
|
||||
return int(image.type)-int(svt.image.type);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
CompOperator(const ShaderVariableType &,Comp)
|
||||
|
||||
const char *GetTypename()const;
|
||||
|
||||
bool ParseTypeString(const char *str);
|
||||
|
||||
const uint64 ToCode()const{return svt_code;}
|
||||
const bool FromCode(const uint64 code)
|
||||
{
|
||||
svt_code=code;
|
||||
|
||||
return Check();
|
||||
}
|
||||
|
||||
const bool From(const VAType &vat,const uint16 count=1)
|
||||
{
|
||||
array_size=count;
|
||||
|
||||
if(vat.vec_size==1)
|
||||
{
|
||||
base_type=SVBaseType::Scalar;
|
||||
scalar.type=vat.basetype;
|
||||
|
||||
return(true);
|
||||
}
|
||||
else if(vat.vec_size<=4)
|
||||
{
|
||||
base_type=SVBaseType::Vector;
|
||||
|
||||
vector.type=vat.basetype;
|
||||
vector.vec_size=vat.vec_size;
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
return(false);
|
||||
}
|
||||
|
||||
static const ShaderVariableType Scalar(const VABaseType &vabt,const uint count=1)
|
||||
{
|
||||
ShaderVariableType svt;
|
||||
|
||||
svt.base_type =SVBaseType::Scalar;
|
||||
svt.scalar.type =vabt;
|
||||
svt.array_size =count;
|
||||
|
||||
return svt;
|
||||
}
|
||||
};//struct ShaderVariableType
|
||||
#pragma pack(pop)
|
||||
|
||||
using SVType=ShaderVariableType;
|
||||
|
||||
const SVType SVT_BOOL (VABaseType::Bool, 1);
|
||||
const SVType SVT_INT (VABaseType::Int, 1);
|
||||
const SVType SVT_UINT (VABaseType::UInt, 1);
|
||||
const SVType SVT_FLOAT (VABaseType::Float, 1);
|
||||
const SVType SVT_DOUBLE(VABaseType::Double, 1);
|
||||
|
||||
const SVType SVT_BVEC2 (VABaseType::Bool, 2,1);
|
||||
const SVType SVT_BVEC3 (VABaseType::Bool, 3,1);
|
||||
const SVType SVT_BVEC4 (VABaseType::Bool, 4,1);
|
||||
|
||||
const SVType SVT_IVEC2 (VABaseType::Int, 2,1);
|
||||
const SVType SVT_IVEC3 (VABaseType::Int, 3,1);
|
||||
const SVType SVT_IVEC4 (VABaseType::Int, 4,1);
|
||||
|
||||
const SVType SVT_UVEC2 (VABaseType::UInt, 2,1);
|
||||
const SVType SVT_UVEC3 (VABaseType::UInt, 3,1);
|
||||
const SVType SVT_UVEC4 (VABaseType::UInt, 4,1);
|
||||
|
||||
const SVType SVT_VEC2 (VABaseType::Float, 2,1);
|
||||
const SVType SVT_VEC3 (VABaseType::Float, 3,1);
|
||||
const SVType SVT_VEC4 (VABaseType::Float, 4,1);
|
||||
|
||||
const SVType SVT_DVEC2 (VABaseType::Double, 2,1);
|
||||
const SVType SVT_DVEC3 (VABaseType::Double, 3,1);
|
||||
const SVType SVT_DVEC4 (VABaseType::Double, 4,1);
|
||||
|
||||
const SVType SVT_MAT2 (VABaseType::Float, 2,2,1);
|
||||
const SVType SVT_MAT3 (VABaseType::Float, 3,3,1);
|
||||
const SVType SVT_MAT4 (VABaseType::Float, 4,4,1);
|
||||
const SVType SVT_MAT2x3(VABaseType::Float, 2,3,1);
|
||||
const SVType SVT_MAT2x4(VABaseType::Float, 2,4,1);
|
||||
const SVType SVT_MAT3x2(VABaseType::Float, 3,2,1);
|
||||
const SVType SVT_MAT3x4(VABaseType::Float, 3,4,1);
|
||||
const SVType SVT_MAT4x2(VABaseType::Float, 4,2,1);
|
||||
const SVType SVT_MAT4x3(VABaseType::Float, 4,3,1);
|
||||
|
||||
const SVType SVT_Sampler1D(SamplerType::Sampler1D, 1);
|
||||
const SVType SVT_Sampler2D(SamplerType::Sampler2D, 1);
|
||||
const SVType SVT_Sampler3D(SamplerType::Sampler3D, 1);
|
||||
|
||||
const SVType SVT_SamplerCube(SamplerType::SamplerCube, 1);
|
||||
const SVType SVT_Sampler2DRect(SamplerType::Sampler2DRect, 1);
|
||||
|
||||
const SVType SVT_Sampler1DArray(SamplerType::Sampler1DArray,1);
|
||||
const SVType SVT_Sampler2DArray(SamplerType::Sampler2DArray,1);
|
||||
|
||||
const SVType SVT_SamplerCubeArray(SamplerType::SamplerCubeArray,1);
|
||||
|
||||
const SVType SVT_SamplerBuffer(SamplerType::SamplerBuffer,1);
|
||||
|
||||
const SVType SVT_Sampler2DMS(SamplerType::Sampler2DMS,1);
|
||||
const SVType SVT_Sampler2DMSArray(SamplerType::Sampler2DMSArray,1);
|
||||
|
||||
const SVType SVT_Sampler1DShadow(SamplerType::Sampler1DShadow,1);
|
||||
const SVType SVT_Sampler2DShadow(SamplerType::Sampler2DShadow,1);
|
||||
|
||||
const SVType SVT_SamplerCubeShadow(SamplerType::SamplerCubeShadow,1);
|
||||
const SVType SVT_Sampler2DRectShadow(SamplerType::Sampler2DRectShadow,1);
|
||||
|
||||
const SVType SVT_Sampler1DArrayShadow(SamplerType::Sampler1DArrayShadow,1);
|
||||
const SVType SVT_Sampler2DArrayShadow(SamplerType::Sampler2DArrayShadow,1);
|
||||
const SVType SVT_SamplerCubeArrayShadow(SamplerType::SamplerCubeArrayShadow,1);
|
||||
|
||||
const SVType SVT_Image1D(ShaderImageType::Image1D,1);
|
||||
const SVType SVT_Image2D(ShaderImageType::Image2D,1);
|
||||
const SVType SVT_Image3D(ShaderImageType::Image3D,1);
|
||||
|
||||
const SVType SVT_ImageCube(ShaderImageType::ImageCube,1);
|
||||
const SVType SVT_Image2DRect(ShaderImageType::Image2DRect,1);
|
||||
|
||||
const SVType SVT_Image1DArray(ShaderImageType::Image1DArray,1);
|
||||
const SVType SVT_Image2DArray(ShaderImageType::Image2DArray,1);
|
||||
|
||||
const SVType SVT_ImageCubeArray(ShaderImageType::ImageCubeArray,1);
|
||||
|
||||
const SVType SVT_ImageBuffer(ShaderImageType::ImageBuffer,1);
|
||||
|
||||
const SVType SVT_Image2DMS(ShaderImageType::Image2DMS,1);
|
||||
const SVType SVT_Image2DMSArray(ShaderImageType::Image2DMSArray,1);
|
||||
|
||||
struct ShaderVariable
|
||||
{
|
||||
char name[VERTEX_ATTRIB_NAME_MAX_LENGTH];
|
||||
uint location;
|
||||
SVType type;
|
||||
Interpolation interpolation; //插值方式
|
||||
uint32 array_size;
|
||||
};
|
||||
|
||||
using SVList=List<ShaderVariable>;
|
||||
uint64 svt_code;
|
||||
};
|
||||
|
||||
struct ShaderVariableArray
|
||||
public:
|
||||
|
||||
ShaderVariableType()
|
||||
{
|
||||
svt_code=0;
|
||||
}
|
||||
|
||||
ShaderVariableType(const ShaderVariableType &svt)
|
||||
{
|
||||
svt_code=svt.svt_code;
|
||||
}
|
||||
|
||||
ShaderVariableType(const VAType &vat,const uint count)
|
||||
{
|
||||
From(vat,count);
|
||||
}
|
||||
|
||||
ShaderVariableType(const VABaseType &vabt,const uint32 count)
|
||||
{
|
||||
svt_code=0;
|
||||
|
||||
base_type=SVBaseType::Scalar;
|
||||
|
||||
scalar.type=vabt;
|
||||
|
||||
array_size=count;
|
||||
}
|
||||
|
||||
ShaderVariableType(const VABaseType &vabt,const uint8 size,const uint32 count)
|
||||
{
|
||||
svt_code=0;
|
||||
|
||||
base_type=SVBaseType::Vector;
|
||||
|
||||
vector.type=vabt;
|
||||
vector.vec_size=size;
|
||||
|
||||
array_size=count;
|
||||
}
|
||||
|
||||
ShaderVariableType(const VABaseType &vabt,const uint8 row,const uint8 col,const uint32 count)
|
||||
{
|
||||
svt_code=0;
|
||||
|
||||
base_type=SVBaseType::Matrix;
|
||||
|
||||
matrix.type=vabt;
|
||||
matrix.n=col;
|
||||
matrix.m=row;
|
||||
|
||||
array_size=count;
|
||||
}
|
||||
|
||||
ShaderVariableType(const SamplerType &st,const uint32 count)
|
||||
{
|
||||
svt_code=0;
|
||||
|
||||
base_type=SVBaseType::Sampler;
|
||||
|
||||
sampler.type=st;
|
||||
|
||||
array_size=count;
|
||||
}
|
||||
|
||||
ShaderVariableType(const ShaderImageType &sit,const uint32 count)
|
||||
{
|
||||
svt_code=0;
|
||||
|
||||
base_type=SVBaseType::Image;
|
||||
|
||||
image.type=sit;
|
||||
|
||||
array_size=count;
|
||||
}
|
||||
|
||||
const bool Check()const;
|
||||
|
||||
const int compare(const ShaderVariableType &svt)const override;
|
||||
|
||||
const char *GetTypename()const;
|
||||
|
||||
bool ParseTypeString(const char *str);
|
||||
|
||||
const uint64 ToCode()const{return svt_code;}
|
||||
const bool FromCode(const uint64 code)
|
||||
{
|
||||
svt_code=code;
|
||||
|
||||
return Check();
|
||||
}
|
||||
|
||||
const bool From(const VAType &vat,const uint16 count=1);
|
||||
|
||||
static const ShaderVariableType Scalar(const VABaseType &vabt,const uint count=1)
|
||||
{
|
||||
ShaderVariableType svt;
|
||||
|
||||
svt.base_type =SVBaseType::Scalar;
|
||||
svt.scalar.type =vabt;
|
||||
svt.array_size =count;
|
||||
|
||||
return svt;
|
||||
}
|
||||
};//struct ShaderVariableType
|
||||
#pragma pack(pop)
|
||||
|
||||
using SVType=ShaderVariableType;
|
||||
|
||||
const SVType SVT_BOOL (VABaseType::Bool, 1);
|
||||
const SVType SVT_INT (VABaseType::Int, 1);
|
||||
const SVType SVT_UINT (VABaseType::UInt, 1);
|
||||
const SVType SVT_FLOAT (VABaseType::Float, 1);
|
||||
const SVType SVT_DOUBLE(VABaseType::Double, 1);
|
||||
|
||||
const SVType SVT_BVEC2 (VABaseType::Bool, 2,1);
|
||||
const SVType SVT_BVEC3 (VABaseType::Bool, 3,1);
|
||||
const SVType SVT_BVEC4 (VABaseType::Bool, 4,1);
|
||||
|
||||
const SVType SVT_IVEC2 (VABaseType::Int, 2,1);
|
||||
const SVType SVT_IVEC3 (VABaseType::Int, 3,1);
|
||||
const SVType SVT_IVEC4 (VABaseType::Int, 4,1);
|
||||
|
||||
const SVType SVT_UVEC2 (VABaseType::UInt, 2,1);
|
||||
const SVType SVT_UVEC3 (VABaseType::UInt, 3,1);
|
||||
const SVType SVT_UVEC4 (VABaseType::UInt, 4,1);
|
||||
|
||||
const SVType SVT_VEC2 (VABaseType::Float, 2,1);
|
||||
const SVType SVT_VEC3 (VABaseType::Float, 3,1);
|
||||
const SVType SVT_VEC4 (VABaseType::Float, 4,1);
|
||||
|
||||
const SVType SVT_DVEC2 (VABaseType::Double, 2,1);
|
||||
const SVType SVT_DVEC3 (VABaseType::Double, 3,1);
|
||||
const SVType SVT_DVEC4 (VABaseType::Double, 4,1);
|
||||
|
||||
const SVType SVT_MAT2 (VABaseType::Float, 2,2,1);
|
||||
const SVType SVT_MAT3 (VABaseType::Float, 3,3,1);
|
||||
const SVType SVT_MAT4 (VABaseType::Float, 4,4,1);
|
||||
const SVType SVT_MAT2x3(VABaseType::Float, 2,3,1);
|
||||
const SVType SVT_MAT2x4(VABaseType::Float, 2,4,1);
|
||||
const SVType SVT_MAT3x2(VABaseType::Float, 3,2,1);
|
||||
const SVType SVT_MAT3x4(VABaseType::Float, 3,4,1);
|
||||
const SVType SVT_MAT4x2(VABaseType::Float, 4,2,1);
|
||||
const SVType SVT_MAT4x3(VABaseType::Float, 4,3,1);
|
||||
|
||||
const SVType SVT_Sampler1D(SamplerType::Sampler1D, 1);
|
||||
const SVType SVT_Sampler2D(SamplerType::Sampler2D, 1);
|
||||
const SVType SVT_Sampler3D(SamplerType::Sampler3D, 1);
|
||||
|
||||
const SVType SVT_SamplerCube(SamplerType::SamplerCube, 1);
|
||||
const SVType SVT_Sampler2DRect(SamplerType::Sampler2DRect, 1);
|
||||
|
||||
const SVType SVT_Sampler1DArray(SamplerType::Sampler1DArray,1);
|
||||
const SVType SVT_Sampler2DArray(SamplerType::Sampler2DArray,1);
|
||||
|
||||
const SVType SVT_SamplerCubeArray(SamplerType::SamplerCubeArray,1);
|
||||
|
||||
const SVType SVT_SamplerBuffer(SamplerType::SamplerBuffer,1);
|
||||
|
||||
const SVType SVT_Sampler2DMS(SamplerType::Sampler2DMS,1);
|
||||
const SVType SVT_Sampler2DMSArray(SamplerType::Sampler2DMSArray,1);
|
||||
|
||||
const SVType SVT_Sampler1DShadow(SamplerType::Sampler1DShadow,1);
|
||||
const SVType SVT_Sampler2DShadow(SamplerType::Sampler2DShadow,1);
|
||||
|
||||
const SVType SVT_SamplerCubeShadow(SamplerType::SamplerCubeShadow,1);
|
||||
const SVType SVT_Sampler2DRectShadow(SamplerType::Sampler2DRectShadow,1);
|
||||
|
||||
const SVType SVT_Sampler1DArrayShadow(SamplerType::Sampler1DArrayShadow,1);
|
||||
const SVType SVT_Sampler2DArrayShadow(SamplerType::Sampler2DArrayShadow,1);
|
||||
const SVType SVT_SamplerCubeArrayShadow(SamplerType::SamplerCubeArrayShadow,1);
|
||||
|
||||
const SVType SVT_Image1D(ShaderImageType::Image1D,1);
|
||||
const SVType SVT_Image2D(ShaderImageType::Image2D,1);
|
||||
const SVType SVT_Image3D(ShaderImageType::Image3D,1);
|
||||
|
||||
const SVType SVT_ImageCube(ShaderImageType::ImageCube,1);
|
||||
const SVType SVT_Image2DRect(ShaderImageType::Image2DRect,1);
|
||||
|
||||
const SVType SVT_Image1DArray(ShaderImageType::Image1DArray,1);
|
||||
const SVType SVT_Image2DArray(ShaderImageType::Image2DArray,1);
|
||||
|
||||
const SVType SVT_ImageCubeArray(ShaderImageType::ImageCubeArray,1);
|
||||
|
||||
const SVType SVT_ImageBuffer(ShaderImageType::ImageBuffer,1);
|
||||
|
||||
const SVType SVT_Image2DMS(ShaderImageType::Image2DMS,1);
|
||||
const SVType SVT_Image2DMSArray(ShaderImageType::Image2DMSArray,1);
|
||||
|
||||
struct ShaderVariable
|
||||
{
|
||||
char name[VERTEX_ATTRIB_NAME_MAX_LENGTH];
|
||||
uint location;
|
||||
SVType type;
|
||||
Interpolation interpolation; //插值方式
|
||||
};
|
||||
|
||||
using SVList=List<ShaderVariable>;
|
||||
|
||||
struct ShaderVariableArray:public Comparator<ShaderVariableArray>
|
||||
{
|
||||
uint count;
|
||||
|
||||
ShaderVariable *items;
|
||||
|
||||
public:
|
||||
|
||||
const bool IsEmpty()const{return !items||count<=0;}
|
||||
|
||||
public:
|
||||
|
||||
ShaderVariableArray()
|
||||
{
|
||||
count=0;
|
||||
items=nullptr;
|
||||
}
|
||||
|
||||
~ShaderVariableArray()
|
||||
{
|
||||
Clear();
|
||||
}
|
||||
|
||||
const int compare(const ShaderVariableArray &sva)const override
|
||||
{
|
||||
int off=count-sva.count;
|
||||
if(off)return off;
|
||||
|
||||
for(uint i=0;i<count;i++)
|
||||
{
|
||||
uint count;
|
||||
off=items[i].location-sva.items[i].location;
|
||||
if(off)
|
||||
return off;
|
||||
|
||||
ShaderVariable *items;
|
||||
if(items[i].type.ToCode()>sva.items[i].type.ToCode())
|
||||
return 1;
|
||||
|
||||
public:
|
||||
//ToCode返回的是uint64,可能差值超大,所以不能直接用-的结果
|
||||
|
||||
const bool IsEmpty()const{return !items||count<=0;}
|
||||
if(items[i].type.ToCode()<sva.items[i].type.ToCode())
|
||||
return -1;
|
||||
|
||||
public:
|
||||
off=int(items[i].interpolation)-int(sva.items[i].interpolation);
|
||||
if(off)
|
||||
return off;
|
||||
|
||||
ShaderVariableArray()
|
||||
{
|
||||
count=0;
|
||||
items=nullptr;
|
||||
}
|
||||
off=hgl::strcmp(items[i].name,sva.items[i].name);
|
||||
if(off)
|
||||
return off;
|
||||
}
|
||||
|
||||
~ShaderVariableArray()
|
||||
{
|
||||
Clear();
|
||||
}
|
||||
|
||||
int Comp(const ShaderVariableArray *sva)const
|
||||
{
|
||||
if(!sva)
|
||||
return 1;
|
||||
|
||||
int off=count-sva->count;
|
||||
if(off)return off;
|
||||
|
||||
for(uint i=0;i<count;i++)
|
||||
{
|
||||
off=items[i].location-sva->items[i].location;
|
||||
if(off)
|
||||
return off;
|
||||
|
||||
if(items[i].type.ToCode()>sva->items[i].type.ToCode())
|
||||
return 1;
|
||||
|
||||
//ToCode返回的是uint64,可能差值超大,所以不能直接用-的结果
|
||||
|
||||
if(items[i].type.ToCode()<sva->items[i].type.ToCode())
|
||||
return -1;
|
||||
|
||||
off=int(items[i].interpolation)-int(sva->items[i].interpolation);
|
||||
if(off)
|
||||
return off;
|
||||
|
||||
off=hgl::strcmp(items[i].name,sva->items[i].name);
|
||||
if(off)
|
||||
return off;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Comp(const ShaderVariableArray &sva)const{return Comp(&sva);}
|
||||
|
||||
CompOperator(const ShaderVariableArray *,Comp)
|
||||
CompOperator(const ShaderVariableArray &,Comp)
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool Init(const uint c=0)
|
||||
{
|
||||
if(items)
|
||||
return(false);
|
||||
bool Init(const uint c=0)
|
||||
{
|
||||
if(items)
|
||||
return(false);
|
||||
|
||||
if(c>0)
|
||||
{
|
||||
count=c;
|
||||
items=array_alloc<ShaderVariable>(count);
|
||||
}
|
||||
else
|
||||
{
|
||||
count=0;
|
||||
items=nullptr;
|
||||
}
|
||||
if(c>0)
|
||||
{
|
||||
count=c;
|
||||
items=array_alloc<ShaderVariable>(count);
|
||||
}
|
||||
else
|
||||
{
|
||||
count=0;
|
||||
items=nullptr;
|
||||
}
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
bool Contains(const char *name)const
|
||||
{
|
||||
if(count<=0)
|
||||
return(false);
|
||||
|
||||
for(uint i=0;i<count;i++)
|
||||
if(hgl::strcmp(items[i].name,name)==0)
|
||||
return(true);
|
||||
}
|
||||
|
||||
bool Contains(const char *name)const
|
||||
{
|
||||
if(count<=0)
|
||||
return(false);
|
||||
return(false);
|
||||
}
|
||||
|
||||
for(uint i=0;i<count;i++)
|
||||
if(hgl::strcmp(items[i].name,name)==0)
|
||||
return(true);
|
||||
bool Add(ShaderVariable &sv)
|
||||
{
|
||||
if(Contains(sv.name))
|
||||
return(false);
|
||||
|
||||
return(false);
|
||||
}
|
||||
sv.location=count;
|
||||
|
||||
bool Add(ShaderVariable &sv)
|
||||
{
|
||||
if(Contains(sv.name))
|
||||
return(false);
|
||||
|
||||
sv.location=count;
|
||||
|
||||
if(!items)
|
||||
{
|
||||
items=array_alloc<ShaderVariable>(1);
|
||||
count=1;
|
||||
}
|
||||
else
|
||||
{
|
||||
++count;
|
||||
items=array_realloc(items,count);
|
||||
}
|
||||
if(!items)
|
||||
{
|
||||
items=array_alloc<ShaderVariable>(1);
|
||||
count=1;
|
||||
}
|
||||
else
|
||||
{
|
||||
++count;
|
||||
items=array_realloc(items,count);
|
||||
}
|
||||
|
||||
hgl_cpy(items[count-1],sv);
|
||||
return(true);
|
||||
}
|
||||
hgl_cpy(items[count-1],sv);
|
||||
return(true);
|
||||
}
|
||||
|
||||
void Clear()
|
||||
{
|
||||
if(items)
|
||||
{
|
||||
array_free(items);
|
||||
items=nullptr;
|
||||
}
|
||||
void Clear()
|
||||
{
|
||||
if(items)
|
||||
{
|
||||
array_free(items);
|
||||
items=nullptr;
|
||||
}
|
||||
|
||||
count=0;
|
||||
}
|
||||
count=0;
|
||||
}
|
||||
|
||||
bool Clone(const ShaderVariableArray *src)
|
||||
{
|
||||
if(!src)
|
||||
return(false);
|
||||
bool Clone(const ShaderVariableArray *src)
|
||||
{
|
||||
if(!src)
|
||||
return(false);
|
||||
|
||||
if(!Init(src->count))
|
||||
return(false);
|
||||
if(!Init(src->count))
|
||||
return(false);
|
||||
|
||||
hgl_cpy(items,src->items,src->count);
|
||||
return(true);
|
||||
}
|
||||
hgl_cpy(items,src->items,src->count);
|
||||
return(true);
|
||||
}
|
||||
|
||||
void ToString(AnsiString &output_string)
|
||||
void ToString(AnsiString &output_string)
|
||||
{
|
||||
if(IsEmpty())
|
||||
return;
|
||||
|
||||
const ShaderVariable *sv=items;
|
||||
|
||||
for(uint i=0;i<count;i++)
|
||||
{
|
||||
output_string+=" ";
|
||||
|
||||
if(sv->interpolation!=Interpolation::Smooth)
|
||||
{
|
||||
if(IsEmpty())
|
||||
return;
|
||||
|
||||
const ShaderVariable *sv=items;
|
||||
|
||||
for(uint i=0;i<count;i++)
|
||||
if(RangeCheck(sv->interpolation))
|
||||
{
|
||||
output_string+=" ";
|
||||
|
||||
if(sv->interpolation!=Interpolation::Smooth)
|
||||
{
|
||||
if(RangeCheck(sv->interpolation))
|
||||
{
|
||||
output_string+=InterpolationName[size_t(sv->interpolation)];
|
||||
output_string+=" ";
|
||||
}
|
||||
}
|
||||
|
||||
output_string+=sv->type.GetTypename();
|
||||
output_string+=InterpolationName[size_t(sv->interpolation)];
|
||||
output_string+=" ";
|
||||
output_string+=sv->name;
|
||||
output_string+=";\n";
|
||||
|
||||
++sv;
|
||||
}
|
||||
}
|
||||
};//struct ShaderVariableArray
|
||||
|
||||
using SVArray=ShaderVariableArray;
|
||||
}//namespace graph
|
||||
}//namespace hgl
|
||||
output_string+=sv->type.GetTypename();
|
||||
output_string+=" ";
|
||||
output_string+=sv->name;
|
||||
output_string+=";\n";
|
||||
|
||||
++sv;
|
||||
}
|
||||
}
|
||||
};//struct ShaderVariableArray
|
||||
|
||||
using SVArray=ShaderVariableArray;
|
||||
|
||||
VK_NAMESPACE_END
|
||||
|
@@ -2,7 +2,7 @@
|
||||
#define HGL_GUI_LAYOUT_INCLUDE
|
||||
|
||||
#include<hgl/gui/Widget.h>
|
||||
#include<hgl/type/SortedSets.h>
|
||||
#include<hgl/type/SortedSet.h>
|
||||
namespace hgl
|
||||
{
|
||||
namespace gui
|
||||
@@ -14,7 +14,7 @@ namespace hgl
|
||||
{
|
||||
protected:
|
||||
|
||||
SortedSets<Widget *> widgets_set;
|
||||
SortedSet<Widget *> widgets_set;
|
||||
|
||||
public:
|
||||
|
||||
|
@@ -96,7 +96,7 @@ public:
|
||||
void SetMain(const AnsiString &str){main_function=str;}
|
||||
void SetMain(const char *str,const int len)
|
||||
{
|
||||
main_function.SetString(str,len);
|
||||
main_function.fromString(str,len);
|
||||
}
|
||||
|
||||
const AnsiString &GetOutputStruct()const{return output_struct;}
|
||||
|
@@ -267,7 +267,7 @@ namespace hgl
|
||||
uint vertex_count;
|
||||
uint index_count;
|
||||
|
||||
vertex_count=cci->field_count;
|
||||
vertex_count=cci->field_count+1;
|
||||
index_count=(vertex_count-2)*3;
|
||||
|
||||
if(!pc->Init("Circle",vertex_count,index_count))return(nullptr);
|
||||
|
@@ -26,22 +26,13 @@
|
||||
这样就可以保证所有的渲染操作就算要切VBO,也不需要切换INDIRECT缓冲区,定位指令也很方便。
|
||||
*/
|
||||
|
||||
template<>
|
||||
int Comparator<hgl::graph::RenderNode>::compare(const hgl::graph::RenderNode &obj_one,const hgl::graph::RenderNode &obj_two) const
|
||||
VK_NAMESPACE_BEGIN
|
||||
const int RenderNode::compare(const RenderNode &other)const
|
||||
{
|
||||
hgl::int64 off;
|
||||
|
||||
hgl::graph::Renderable *ri_one=obj_one.scene_node->GetRenderable();
|
||||
hgl::graph::Renderable *ri_two=obj_two.scene_node->GetRenderable();
|
||||
|
||||
//比较管线
|
||||
{
|
||||
off=ri_one->GetPipeline()
|
||||
-ri_two->GetPipeline();
|
||||
|
||||
if(off)
|
||||
return off;
|
||||
}
|
||||
hgl::graph::Renderable *ri_one=other.scene_node->GetRenderable();
|
||||
hgl::graph::Renderable *ri_two=scene_node->GetRenderable();
|
||||
|
||||
auto *prim_one=ri_one->GetPrimitive();
|
||||
auto *prim_two=ri_two->GetPrimitive();
|
||||
@@ -72,8 +63,8 @@ int Comparator<hgl::graph::RenderNode>::compare(const hgl::graph::RenderNode &ob
|
||||
|
||||
//比较距离。。。。。。。。。。。。。。。。。。。。。还不知道这个是正了还是反了,等测出来确认后修改下面的返回值和这里的注释
|
||||
|
||||
float foff=obj_one.to_camera_distance
|
||||
-obj_two.to_camera_distance;
|
||||
float foff=other.to_camera_distance
|
||||
-to_camera_distance;
|
||||
|
||||
if(foff>0)
|
||||
return 1;
|
||||
@@ -81,18 +72,17 @@ int Comparator<hgl::graph::RenderNode>::compare(const hgl::graph::RenderNode &ob
|
||||
return -1;
|
||||
}
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
MaterialRenderList::MaterialRenderList(GPUDevice *d,bool l2w,Material *m)
|
||||
MaterialRenderList::MaterialRenderList(GPUDevice *d,bool l2w,const RenderPipelineIndex &rpi)
|
||||
{
|
||||
device=d;
|
||||
cmd_buf=nullptr;
|
||||
material=m;
|
||||
rp_index=rpi;
|
||||
|
||||
camera_info=nullptr;
|
||||
|
||||
assign_buffer=new RenderAssignBuffer(device,material);
|
||||
assign_buffer=new RenderAssignBuffer(device,rp_index.material);
|
||||
|
||||
vab_list=new VABList(material->GetVertexInput()->GetCount());
|
||||
vab_list=new VABList(rp_index.material->GetVertexInput()->GetCount());
|
||||
|
||||
icb_draw=nullptr;
|
||||
icb_draw_indexed=nullptr;
|
||||
@@ -215,7 +205,6 @@ void MaterialRenderList::UpdateMaterialInstance(SceneNode *sn)
|
||||
|
||||
void MaterialRenderList::RenderItem::Set(Renderable *ri)
|
||||
{
|
||||
pipeline=ri->GetPipeline();
|
||||
mi =ri->GetMaterialInstance();
|
||||
pdb =ri->GetDataBuffer();
|
||||
prd =ri->GetRenderData();
|
||||
@@ -248,6 +237,7 @@ void MaterialRenderList::WriteICB(VkDrawIndirectCommand *dicp,RenderItem *ri)
|
||||
dicp->firstVertex =ri->prd->vertex_offset;
|
||||
dicp->firstInstance =ri->first_instance;
|
||||
}
|
||||
|
||||
void MaterialRenderList::WriteICB(VkDrawIndexedIndirectCommand *diicp,RenderItem *ri)
|
||||
{
|
||||
diicp->indexCount =ri->prd->index_count;
|
||||
@@ -279,7 +269,6 @@ void MaterialRenderList::Stat()
|
||||
ri->instance_count=1;
|
||||
ri->Set(ro);
|
||||
|
||||
last_pipeline =ri->pipeline;
|
||||
last_data_buffer=ri->pdb;
|
||||
last_vdm =ri->pdb->vdm;
|
||||
last_render_data=ri->prd;
|
||||
@@ -290,14 +279,13 @@ void MaterialRenderList::Stat()
|
||||
{
|
||||
ro=rn->scene_node->GetRenderable();
|
||||
|
||||
if(last_pipeline==ro->GetPipeline())
|
||||
if(last_data_buffer->Comp(ro->GetDataBuffer()))
|
||||
if(last_render_data->_Comp(ro->GetRenderData())==0)
|
||||
{
|
||||
++ri->instance_count;
|
||||
++rn;
|
||||
continue;
|
||||
}
|
||||
if(*last_data_buffer!=*ro->GetDataBuffer())
|
||||
if(*last_render_data==*ro->GetRenderData())
|
||||
{
|
||||
++ri->instance_count;
|
||||
++rn;
|
||||
continue;
|
||||
}
|
||||
|
||||
if(ri->pdb->vdm)
|
||||
{
|
||||
@@ -317,7 +305,6 @@ void MaterialRenderList::Stat()
|
||||
ri->instance_count=1;
|
||||
ri->Set(ro);
|
||||
|
||||
last_pipeline =ri->pipeline;
|
||||
last_data_buffer=ri->pdb;
|
||||
last_vdm =ri->pdb->vdm;
|
||||
last_render_data=ri->prd;
|
||||
@@ -411,17 +398,7 @@ void MaterialRenderList::ProcIndirectRender()
|
||||
|
||||
void MaterialRenderList::Render(RenderItem *ri)
|
||||
{
|
||||
if(last_pipeline!=ri->pipeline)
|
||||
{
|
||||
cmd_buf->BindPipeline(ri->pipeline);
|
||||
last_pipeline=ri->pipeline;
|
||||
|
||||
last_data_buffer=nullptr;
|
||||
|
||||
//这里未来尝试换pipeline同时不换mi/primitive是否需要重新绑定mi/primitive
|
||||
}
|
||||
|
||||
if(!ri->pdb->Comp(last_data_buffer)) //换buf了
|
||||
if(*(ri->pdb)!=*last_data_buffer) //换buf了
|
||||
{
|
||||
if(indirect_draw_count) //如果有间接绘制的数据,赶紧给画了
|
||||
ProcIndirectRender();
|
||||
@@ -432,7 +409,7 @@ void MaterialRenderList::Render(RenderItem *ri)
|
||||
BindVAB(ri->pdb,ri->first_instance);
|
||||
|
||||
if(ri->pdb->ibo)
|
||||
cmd_buf->BindIBO(ri->pdb->ibo);
|
||||
cmd_buf->BindIBO(ri->pdb->ibo);
|
||||
}
|
||||
|
||||
if(ri->pdb->vdm)
|
||||
@@ -459,15 +436,16 @@ void MaterialRenderList::Render(RenderCmdBuffer *rcb)
|
||||
|
||||
cmd_buf=rcb;
|
||||
|
||||
last_pipeline =nullptr;
|
||||
cmd_buf->BindPipeline(rp_index.pipeline);
|
||||
|
||||
last_data_buffer=nullptr;
|
||||
last_vdm =nullptr;
|
||||
last_render_data=nullptr;
|
||||
|
||||
if(assign_buffer)
|
||||
assign_buffer->Bind(material);
|
||||
assign_buffer->Bind(rp_index.material);
|
||||
|
||||
cmd_buf->BindDescriptorSets(material);
|
||||
cmd_buf->BindDescriptorSets(rp_index.material);
|
||||
|
||||
RenderItem *ri=ri_array.GetData();
|
||||
for(uint i=0;i<ri_count;i++)
|
||||
|
@@ -26,14 +26,15 @@ namespace hgl
|
||||
|
||||
if(ri)
|
||||
{
|
||||
Material *mtl=ri->GetMaterial();
|
||||
RenderPipelineIndex rpi(ri->GetMaterial(),ri->GetPipeline());
|
||||
|
||||
MaterialRenderList *mrl;
|
||||
|
||||
if(!mrl_map.Get(mtl,mrl))
|
||||
if(!mrl_map.Get(rpi,mrl))
|
||||
{
|
||||
mrl=new MaterialRenderList(device,true,mtl);
|
||||
mrl=new MaterialRenderList(device,true,rpi);
|
||||
|
||||
mrl_map.Add(mtl,mrl);
|
||||
mrl_map.Add(rpi,mrl);
|
||||
}
|
||||
|
||||
mrl->Add(sn);
|
||||
@@ -92,10 +93,10 @@ namespace hgl
|
||||
|
||||
if(!ri)return;
|
||||
|
||||
Material *mtl=ri->GetMaterial();
|
||||
RenderPipelineIndex rli(ri->GetMaterial(),ri->GetPipeline());
|
||||
MaterialRenderList *mrl;
|
||||
|
||||
if(!mrl_map.Get(mtl,mrl)) //找到对应的
|
||||
if(!mrl_map.Get(rli,mrl)) //找到对应的
|
||||
return;
|
||||
|
||||
mrl->UpdateMaterialInstance(sn);
|
||||
|
@@ -169,6 +169,35 @@ namespace
|
||||
#undef OUTPUT_PHYSICAL_DEVICE_FEATURE
|
||||
}
|
||||
|
||||
void DebugOut(const VkPhysicalDeviceVulkan14Features &features)
|
||||
{
|
||||
std::cout<<"Vulkan 1.4 features"<<std::endl;
|
||||
|
||||
#define OUTPUT_PHYSICAL_DEVICE_FEATURE(name) std::cout<<std::setw(60)<<std::right<<#name<<": "<<(features.name?"true":"false")<<std::endl;
|
||||
OUTPUT_PHYSICAL_DEVICE_FEATURE(globalPriorityQuery)
|
||||
OUTPUT_PHYSICAL_DEVICE_FEATURE(shaderSubgroupRotate)
|
||||
OUTPUT_PHYSICAL_DEVICE_FEATURE(shaderSubgroupRotateClustered)
|
||||
OUTPUT_PHYSICAL_DEVICE_FEATURE(shaderFloatControls2)
|
||||
OUTPUT_PHYSICAL_DEVICE_FEATURE(shaderExpectAssume)
|
||||
OUTPUT_PHYSICAL_DEVICE_FEATURE(rectangularLines)
|
||||
OUTPUT_PHYSICAL_DEVICE_FEATURE(bresenhamLines)
|
||||
OUTPUT_PHYSICAL_DEVICE_FEATURE(smoothLines)
|
||||
OUTPUT_PHYSICAL_DEVICE_FEATURE(stippledRectangularLines)
|
||||
OUTPUT_PHYSICAL_DEVICE_FEATURE(stippledBresenhamLines)
|
||||
OUTPUT_PHYSICAL_DEVICE_FEATURE(stippledSmoothLines)
|
||||
OUTPUT_PHYSICAL_DEVICE_FEATURE(vertexAttributeInstanceRateDivisor)
|
||||
OUTPUT_PHYSICAL_DEVICE_FEATURE(vertexAttributeInstanceRateZeroDivisor)
|
||||
OUTPUT_PHYSICAL_DEVICE_FEATURE(indexTypeUint8)
|
||||
OUTPUT_PHYSICAL_DEVICE_FEATURE(dynamicRenderingLocalRead)
|
||||
OUTPUT_PHYSICAL_DEVICE_FEATURE(maintenance5)
|
||||
OUTPUT_PHYSICAL_DEVICE_FEATURE(maintenance6)
|
||||
OUTPUT_PHYSICAL_DEVICE_FEATURE(pipelineProtectedAccess)
|
||||
OUTPUT_PHYSICAL_DEVICE_FEATURE(pipelineRobustness)
|
||||
OUTPUT_PHYSICAL_DEVICE_FEATURE(hostImageCopy)
|
||||
OUTPUT_PHYSICAL_DEVICE_FEATURE(pushDescriptor)
|
||||
#undef OUTPUT_PHYSICAL_DEVICE_FEATURE
|
||||
}
|
||||
|
||||
void DebugOutVersion(uint32_t version)
|
||||
{
|
||||
std::cout<<VK_VERSION_MAJOR(version)<<"."<<VK_VERSION_MINOR(version)<<"."<<VK_VERSION_PATCH(version)<<std::endl;
|
||||
@@ -377,5 +406,6 @@ void OutputPhysicalDeviceCaps(const GPUPhysicalDevice *pd)
|
||||
DebugOut(pd->GetFeatures11());
|
||||
DebugOut(pd->GetFeatures12());
|
||||
DebugOut(pd->GetFeatures13());
|
||||
DebugOut(pd->GetFeatures14());
|
||||
}
|
||||
VK_NAMESPACE_END
|
||||
|
@@ -5,6 +5,7 @@
|
||||
#include<hgl/graph/VKDeviceAttribute.h>
|
||||
#include<hgl/graph/VKPhysicalDevice.h>
|
||||
#include<hgl/graph/VKIndexBuffer.h>
|
||||
#include<hgl/graph/VKRenderTarget.h>
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
RenderCmdBuffer::RenderCmdBuffer(const GPUDeviceAttribute *attr,VkCommandBuffer cb):GPUCmdBuffer(attr,cb)
|
||||
@@ -15,7 +16,6 @@ RenderCmdBuffer::RenderCmdBuffer(const GPUDeviceAttribute *attr,VkCommandBuffer
|
||||
hgl_zero(render_area);
|
||||
hgl_zero(viewport);
|
||||
|
||||
fbo=nullptr;
|
||||
pipeline_layout=VK_NULL_HANDLE;
|
||||
}
|
||||
|
||||
@@ -25,13 +25,8 @@ RenderCmdBuffer::~RenderCmdBuffer()
|
||||
hgl_free(clear_values);
|
||||
}
|
||||
|
||||
void RenderCmdBuffer::SetFBO(Framebuffer *fb)
|
||||
void RenderCmdBuffer::SetClear()
|
||||
{
|
||||
if(fbo==fb)return;
|
||||
|
||||
fbo=fb;
|
||||
cv_count=fbo->GetAttachmentCount();
|
||||
|
||||
if(cv_count>0)
|
||||
{
|
||||
clear_values=hgl_align_realloc<VkClearValue>(clear_values,cv_count);
|
||||
@@ -44,11 +39,6 @@ void RenderCmdBuffer::SetFBO(Framebuffer *fb)
|
||||
hgl_free(clear_values);
|
||||
clear_values=nullptr;
|
||||
}
|
||||
|
||||
render_area.offset.x=0;
|
||||
render_area.offset.y=0;
|
||||
render_area.extent.width=0;
|
||||
render_area.extent.height=0;
|
||||
}
|
||||
|
||||
void RenderCmdBuffer::SetRenderArea(const VkExtent2D &ext2d)
|
||||
@@ -58,18 +48,19 @@ void RenderCmdBuffer::SetRenderArea(const VkExtent2D &ext2d)
|
||||
render_area.extent=ext2d;
|
||||
}
|
||||
|
||||
bool RenderCmdBuffer::BindFramebuffer(RenderPass *rp,Framebuffer *fb)
|
||||
bool RenderCmdBuffer::BindFramebuffer(Framebuffer *fbo)
|
||||
{
|
||||
if(!rp||!fb)return(false);
|
||||
if(!fbo)return(false);
|
||||
|
||||
SetFBO(fb);
|
||||
cv_count=fbo->GetAttachmentCount();
|
||||
SetClear();
|
||||
|
||||
render_area.offset.x=0;
|
||||
render_area.offset.y=0;
|
||||
render_area.extent=fb->GetExtent();
|
||||
render_area.extent=fbo->GetExtent();
|
||||
|
||||
rp_begin.renderPass = rp->GetVkRenderPass();
|
||||
rp_begin.framebuffer = *fb;
|
||||
rp_begin.renderPass = *fbo->GetRenderPass();
|
||||
rp_begin.framebuffer = *fbo;
|
||||
rp_begin.renderArea = render_area;
|
||||
rp_begin.clearValueCount = cv_count;
|
||||
rp_begin.pClearValues = clear_values;
|
||||
|
@@ -75,7 +75,7 @@ Framebuffer *GPUDevice::CreateFBO(RenderPass *rp,ImageView **color_list,const ui
|
||||
if(!fbo)
|
||||
return(nullptr);
|
||||
|
||||
return(new Framebuffer(GetDevice(),fbo,extent,rp->GetVkRenderPass(),color_count,depth));
|
||||
return(new Framebuffer(GetDevice(),fbo,extent,rp,color_count,depth));
|
||||
}
|
||||
//
|
||||
//Framebuffer *GPUDevice::CreateFBO(RenderPass *rp,List<ImageView *> &color,ImageView *depth)
|
||||
|
@@ -48,9 +48,9 @@ MaterialParameters *GPUDevice::CreateMP(const MaterialDescriptorManager *desc_ma
|
||||
if(!ds)return(nullptr);
|
||||
|
||||
#ifdef _DEBUG
|
||||
const UTF8String addr_string=HexToString<u8char,uint64_t>((uint64_t)(ds->GetDescriptorSet()));
|
||||
const U8String addr_string=HexToString<u8char,uint64_t>((uint64_t)(ds->GetDescriptorSet()));
|
||||
|
||||
LOG_INFO(U8_TEXT("Create [DescriptSets:")+addr_string+U8_TEXT("] OK! Material Name: \"")+(const UTF8String &)(desc_manager->GetMaterialName())+U8_TEXT("\" Type: ")+(u8char *)(GetDescriptorSetTypeName(desc_set_type)));
|
||||
LOG_INFO(U8_TEXT("Create [DescriptSets:")+addr_string+U8_TEXT("] OK! Material Name: \"")+(const U8String &)(desc_manager->GetMaterialName())+U8_TEXT("\" Type: ")+(u8char *)(GetDescriptorSetTypeName(desc_set_type)));
|
||||
#endif//_DEBUG
|
||||
|
||||
return(new MaterialParameters(desc_manager,desc_set_type,ds));
|
||||
|
@@ -7,15 +7,6 @@ VK_NAMESPACE_BEGIN
|
||||
void GPUDevice::InitRenderPassManage()
|
||||
{
|
||||
render_pass_manage=new DeviceRenderPassManage(attr->device,attr->pipeline_cache);
|
||||
|
||||
SwapchainRenderbufferInfo rbi(attr->surface_format.format,attr->physical_device->GetDepthFormat());
|
||||
|
||||
device_render_pass=render_pass_manage->AcquireRenderPass(&rbi);
|
||||
|
||||
#ifdef _DEBUG
|
||||
if(attr->debug_utils)
|
||||
attr->debug_utils->SetRenderPass(device_render_pass->GetVkRenderPass(),"MainDeviceRenderPass");
|
||||
#endif//_DEBUG
|
||||
}
|
||||
|
||||
void GPUDevice::ClearRenderPassManage()
|
||||
|
@@ -188,8 +188,8 @@ DeviceRenderPassManage::DeviceRenderPassManage(VkDevice dev,VkPipelineCache pc)
|
||||
{
|
||||
device=dev;
|
||||
pipeline_cache=pc;
|
||||
|
||||
hash=util::CreateSHA1LEHash();
|
||||
|
||||
hash=CreateRenderPassHash();
|
||||
}
|
||||
|
||||
DeviceRenderPassManage::~DeviceRenderPassManage()
|
||||
@@ -250,8 +250,8 @@ namespace
|
||||
// }
|
||||
|
||||
void HashRenderPass(RenderPassHASHCode *code,const RenderbufferInfo *rbi,const uint8 subpass_count)
|
||||
{
|
||||
util::Hash *hash=util::CreateSHA1LEHash();
|
||||
{
|
||||
util::Hash *hash=CreateRenderPassHash();
|
||||
|
||||
hash->Init();
|
||||
|
||||
|
@@ -1,4 +1,6 @@
|
||||
#include<hgl/graph/VKDevice.h>
|
||||
#include<hgl/graph/VKDeviceRenderPassManage.h>
|
||||
#include<hgl/graph/VKSemaphore.h>
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
RenderTarget *GPUDevice::CreateRT(const FramebufferInfo *fbi,RenderPass *rp,const uint32_t fence_count)
|
||||
@@ -33,13 +35,21 @@ RenderTarget *GPUDevice::CreateRT(const FramebufferInfo *fbi,RenderPass *rp,cons
|
||||
|
||||
if(fb)
|
||||
{
|
||||
DeviceQueue *q=CreateQueue(fence_count,false);
|
||||
Semaphore *render_complete_semaphore=CreateGPUSemaphore();
|
||||
RenderTargetData *rtd=new RenderTargetData{};
|
||||
|
||||
RenderTarget *rt=new RenderTarget(q,render_complete_semaphore,rp,fb,color_texture_list,color_count,depth_texture);
|
||||
rtd->fbo =fb;
|
||||
rtd->queue =CreateQueue(fence_count,false);
|
||||
rtd->render_complete_semaphore =CreateGPUSemaphore();
|
||||
|
||||
rtd->cmd_buf =CreateRenderCommandBuffer("");
|
||||
|
||||
rtd->color_count =color_count;
|
||||
rtd->color_textures =hgl_new_copy<Texture2D *>(color_texture_list,color_count);
|
||||
rtd->depth_texture =depth_texture;
|
||||
|
||||
color_texture_list.DiscardObject();
|
||||
return rt;
|
||||
|
||||
return(new RenderTarget(rtd));
|
||||
}
|
||||
|
||||
SAFE_CLEAR(depth_texture);
|
||||
@@ -57,24 +67,56 @@ RenderTarget *GPUDevice::CreateRT(const FramebufferInfo *fbi,const uint32_t fenc
|
||||
return CreateRT(fbi,rp,fence_count);
|
||||
}
|
||||
|
||||
RTSwapchain *GPUDevice::CreateSwapchainRenderTarget()
|
||||
namespace
|
||||
{
|
||||
struct SwapchainRenderTargetData:public RenderTargetData
|
||||
{
|
||||
void Clear() override
|
||||
{
|
||||
delete render_complete_semaphore;
|
||||
delete queue;
|
||||
|
||||
delete[] color_textures;
|
||||
}
|
||||
};//
|
||||
}//namespace
|
||||
|
||||
SwapchainRenderTarget *GPUDevice::CreateSwapchainRenderTarget()
|
||||
{
|
||||
Swapchain *sc=CreateSwapchain(attr->surface_caps.currentExtent);
|
||||
|
||||
if(!sc)
|
||||
return(nullptr);
|
||||
|
||||
DeviceQueue *q=CreateQueue(sc->color_count,false);
|
||||
Semaphore *render_complete_semaphore=CreateGPUSemaphore();
|
||||
Semaphore *present_complete_semaphore=CreateGPUSemaphore();
|
||||
RenderTarget **rt_list=new RenderTarget*[sc->image_count];
|
||||
|
||||
RTSwapchain *srt=new RTSwapchain( attr->device,
|
||||
sc,
|
||||
q,
|
||||
render_complete_semaphore,
|
||||
present_complete_semaphore,
|
||||
device_render_pass
|
||||
);
|
||||
SwapchainImage *sc_image=sc->sc_image;
|
||||
|
||||
for(uint32_t i=0;i<sc->image_count;i++)
|
||||
{
|
||||
RenderTargetData *rtd=new SwapchainRenderTargetData{};
|
||||
|
||||
rtd->fbo =sc_image->fbo;
|
||||
rtd->queue =CreateQueue(sc->image_count,false);
|
||||
rtd->render_complete_semaphore =CreateGPUSemaphore();
|
||||
|
||||
rtd->cmd_buf =sc_image->cmd_buf;
|
||||
|
||||
rtd->color_count =1;
|
||||
rtd->color_textures =new Texture2D*[1];
|
||||
rtd->color_textures[0] =sc_image->color;
|
||||
rtd->depth_texture =sc_image->depth;
|
||||
|
||||
rt_list[i]=new RenderTarget(rtd);
|
||||
|
||||
++sc_image;
|
||||
}
|
||||
|
||||
SwapchainRenderTarget *srt=new SwapchainRenderTarget( attr->device,
|
||||
sc,
|
||||
CreateGPUSemaphore(),
|
||||
rt_list
|
||||
);
|
||||
|
||||
return srt;
|
||||
}
|
||||
|
@@ -1,6 +1,7 @@
|
||||
#include<hgl/graph/VKDevice.h>
|
||||
#include<hgl/graph/VKDeviceAttribute.h>
|
||||
#include<hgl/graph/VKPhysicalDevice.h>
|
||||
#include<hgl/graph/VKDeviceRenderPassManage.h>
|
||||
#include<iostream>
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
@@ -84,49 +85,47 @@ namespace
|
||||
|
||||
bool GPUDevice::CreateSwapchainFBO(Swapchain *swapchain)
|
||||
{
|
||||
if(vkGetSwapchainImagesKHR(attr->device,swapchain->swap_chain,&(swapchain->color_count),nullptr)!=VK_SUCCESS)
|
||||
if(vkGetSwapchainImagesKHR(attr->device,swapchain->swap_chain,&(swapchain->image_count),nullptr)!=VK_SUCCESS)
|
||||
return(false);
|
||||
|
||||
AutoDeleteArray<VkImage> sc_images(swapchain->color_count);
|
||||
AutoDeleteArray<VkImage> sc_images(swapchain->image_count);
|
||||
|
||||
if(vkGetSwapchainImagesKHR(attr->device,swapchain->swap_chain,&(swapchain->color_count),sc_images)!=VK_SUCCESS)
|
||||
if(vkGetSwapchainImagesKHR(attr->device,swapchain->swap_chain,&(swapchain->image_count),sc_images)!=VK_SUCCESS)
|
||||
return(false);
|
||||
|
||||
swapchain->sc_depth =CreateTexture2D(new SwapchainDepthTextureCreateInfo(attr->physical_device->GetDepthFormat(),swapchain->extent));
|
||||
swapchain->sc_image=hgl_zero_new<SwapchainImage>(swapchain->image_count);
|
||||
|
||||
if(!swapchain->sc_depth)
|
||||
return(false);
|
||||
AnsiString num_string;
|
||||
|
||||
#ifdef _DEBUG
|
||||
if(attr->debug_utils)
|
||||
{
|
||||
attr->debug_utils->SetImage(swapchain->sc_depth->GetImage(),"SwapchainDepthImage");
|
||||
attr->debug_utils->SetImageView(swapchain->sc_depth->GetVulkanImageView(),"SwapchainDepthImageView");
|
||||
attr->debug_utils->SetDeviceMemory(swapchain->sc_depth->GetDeviceMemory(),"SwapchainDepthMemory");
|
||||
}
|
||||
#endif//_DEBUG
|
||||
|
||||
swapchain->sc_color =hgl_zero_new<Texture2D *>(swapchain->color_count);
|
||||
swapchain->sc_fbo =hgl_zero_new<Framebuffer *>(swapchain->color_count);
|
||||
|
||||
for(uint32_t i=0;i<swapchain->color_count;i++)
|
||||
for(uint32_t i=0;i<swapchain->image_count;i++)
|
||||
{
|
||||
swapchain->sc_color[i]=CreateTexture2D(new SwapchainColorTextureCreateInfo(attr->surface_format.format,swapchain->extent,sc_images[i]));
|
||||
swapchain->sc_image[i].color=CreateTexture2D(new SwapchainColorTextureCreateInfo(swapchain->surface_format.format,swapchain->extent,sc_images[i]));
|
||||
|
||||
if(!swapchain->sc_color[i])
|
||||
if(!swapchain->sc_image[i].color)
|
||||
return(false);
|
||||
|
||||
swapchain->sc_fbo[i]=CreateFBO( device_render_pass,
|
||||
swapchain->sc_color[i]->GetImageView(),
|
||||
swapchain->sc_depth->GetImageView());
|
||||
swapchain->sc_image[i].depth=CreateTexture2D(new SwapchainDepthTextureCreateInfo(swapchain->depth_format,swapchain->extent));
|
||||
|
||||
if(!swapchain->sc_image[i].depth)
|
||||
return(false);
|
||||
|
||||
swapchain->sc_image[i].fbo=CreateFBO( swapchain->render_pass,
|
||||
swapchain->sc_image[i].color->GetImageView(),
|
||||
swapchain->sc_image[i].depth->GetImageView());
|
||||
|
||||
AnsiString num_string=AnsiString::numberOf(i);
|
||||
|
||||
swapchain->sc_image[i].cmd_buf=CreateRenderCommandBuffer(AnsiString("Swapchain_RenderCmdBuffer_")+num_string);
|
||||
|
||||
#ifdef _DEBUG
|
||||
if(attr->debug_utils)
|
||||
{
|
||||
attr->debug_utils->SetImage(swapchain->sc_color[i]->GetImage(),"SwapchainColorImage_"+AnsiString::numberOf(i));
|
||||
attr->debug_utils->SetImageView(swapchain->sc_color[i]->GetVulkanImageView(),"SwapchainColorImageView_"+AnsiString::numberOf(i));
|
||||
AnsiString num=AnsiString::numberOf(i);
|
||||
|
||||
attr->debug_utils->SetFramebuffer(swapchain->sc_fbo[i]->GetFramebuffer(),"SwapchainFBO_"+AnsiString::numberOf(i));
|
||||
attr->debug_utils->SetTexture(swapchain->sc_image[i].color,"SwapchainColor_"+num_string);
|
||||
attr->debug_utils->SetTexture(swapchain->sc_image[i].depth,"SwapchainDepth_"+num_string);
|
||||
|
||||
attr->debug_utils->SetFramebuffer(swapchain->sc_image[i].fbo->GetFramebuffer(),"SwapchainFBO_"+num_string);
|
||||
}
|
||||
#endif//_DEBUG
|
||||
}
|
||||
@@ -138,10 +137,22 @@ Swapchain *GPUDevice::CreateSwapchain(const VkExtent2D &acquire_extent)
|
||||
{
|
||||
Swapchain *swapchain=new Swapchain;
|
||||
|
||||
swapchain->device =attr->device;
|
||||
swapchain->extent =acquire_extent;
|
||||
swapchain->device =attr->device;
|
||||
swapchain->extent =acquire_extent;
|
||||
swapchain->transform =attr->surface_caps.currentTransform;
|
||||
swapchain->surface_format =attr->surface_format;
|
||||
swapchain->depth_format =attr->physical_device->GetDepthFormat();
|
||||
|
||||
SwapchainRenderbufferInfo rbi(swapchain->surface_format.format,swapchain->depth_format);
|
||||
|
||||
swapchain->swap_chain =CreateSwapChain(attr,acquire_extent);
|
||||
swapchain->render_pass =render_pass_manage->AcquireRenderPass(&rbi);
|
||||
|
||||
#ifdef _DEBUG
|
||||
if(attr->debug_utils)
|
||||
attr->debug_utils->SetRenderPass(swapchain->render_pass->GetVkRenderPass(),"MainDeviceRenderPass");
|
||||
#endif//_DEBUG
|
||||
|
||||
swapchain->swap_chain =CreateSwapChain(attr,acquire_extent);
|
||||
|
||||
if(swapchain->swap_chain)
|
||||
if(CreateSwapchainFBO(swapchain))
|
||||
|
@@ -7,7 +7,7 @@
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
|
||||
Framebuffer::Framebuffer(VkDevice dev,VkFramebuffer fb,const VkExtent2D &ext,VkRenderPass rp,uint32_t cc,bool depth)
|
||||
Framebuffer::Framebuffer(VkDevice dev,VkFramebuffer fb,const VkExtent2D &ext,RenderPass *rp,uint32_t cc,bool depth)
|
||||
{
|
||||
device=dev;
|
||||
frame_buffer=fb;
|
||||
|
@@ -20,7 +20,7 @@ VulkanInstance *CreateInstance(const AnsiString &app_name,VKDebugOut *out,Create
|
||||
app_info.applicationVersion = 1;
|
||||
app_info.pEngineName = "CMGameEngine/ULRE";
|
||||
app_info.engineVersion = 1;
|
||||
app_info.apiVersion = VK_API_VERSION_1_3;
|
||||
app_info.apiVersion = VK_API_VERSION_1_4;
|
||||
|
||||
ext_list.Add(VK_KHR_SURFACE_EXTENSION_NAME);
|
||||
ext_list.Add(HGL_VK_SURFACE_EXTENSION_NAME); //此宏在VKSurfaceExtensionName.h中定义
|
||||
|
@@ -64,6 +64,7 @@ GPUPhysicalDevice::GPUPhysicalDevice(VkInstance inst,VkPhysicalDevice pd)
|
||||
hgl_zero(features11);
|
||||
hgl_zero(features12);
|
||||
hgl_zero(features13);
|
||||
hgl_zero(features14);
|
||||
|
||||
auto func=(PFN_vkGetPhysicalDeviceFeatures2KHR)vkGetInstanceProcAddr(inst,"vkGetPhysicalDeviceFeatures2KHR");
|
||||
|
||||
@@ -81,7 +82,10 @@ GPUPhysicalDevice::GPUPhysicalDevice(VkInstance inst,VkPhysicalDevice pd)
|
||||
features12.pNext=&features13;
|
||||
|
||||
features13.sType=VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_3_FEATURES;
|
||||
features13.pNext=nullptr;
|
||||
features13.pNext=&features14;
|
||||
|
||||
features14.sType=VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_4_FEATURES;
|
||||
features14.pNext=nullptr;
|
||||
|
||||
func(physical_device,&features2);
|
||||
|
||||
@@ -97,6 +101,7 @@ GPUPhysicalDevice::GPUPhysicalDevice(VkInstance inst,VkPhysicalDevice pd)
|
||||
hgl_zero(properties11);
|
||||
hgl_zero(properties12);
|
||||
hgl_zero(properties13);
|
||||
hgl_zero(properties14);
|
||||
|
||||
auto func=(PFN_vkGetPhysicalDeviceProperties2KHR)vkGetInstanceProcAddr(inst,"vkGetPhysicalDeviceProperties2KHR");
|
||||
|
||||
@@ -114,7 +119,10 @@ GPUPhysicalDevice::GPUPhysicalDevice(VkInstance inst,VkPhysicalDevice pd)
|
||||
properties12.pNext=&properties13;
|
||||
|
||||
properties13.sType=VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_3_PROPERTIES;
|
||||
properties13.pNext=nullptr;
|
||||
properties13.pNext=&properties14;
|
||||
|
||||
properties14.sType=VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_4_PROPERTIES;
|
||||
properties14.pNext=nullptr;
|
||||
|
||||
func(physical_device,&properties2);
|
||||
|
||||
@@ -163,7 +171,11 @@ GPUPhysicalDevice::GPUPhysicalDevice(VkInstance inst,VkPhysicalDevice pd)
|
||||
debug_queue_family_properties_out(debug_front.c_str(),queue_family_properties);
|
||||
}
|
||||
|
||||
support_u8_index=CheckExtensionSupport(VK_EXT_INDEX_TYPE_UINT8_EXTENSION_NAME);
|
||||
if(features14.indexTypeUint8)
|
||||
support_u8_index=true;
|
||||
else
|
||||
support_u8_index=CheckExtensionSupport(VK_EXT_INDEX_TYPE_UINT8_EXTENSION_NAME);
|
||||
|
||||
dynamic_state=CheckExtensionSupport(VK_EXT_EXTENDED_DYNAMIC_STATE_EXTENSION_NAME);
|
||||
}
|
||||
|
||||
|
@@ -3,7 +3,7 @@
|
||||
#include<hgl/graph/VK.h>
|
||||
#include<hgl/graph/VKDescriptorSetType.h>
|
||||
#include<hgl/type/Map.h>
|
||||
#include<hgl/type/SortedSets.h>
|
||||
#include<hgl/type/SortedSet.h>
|
||||
VK_NAMESPACE_BEGIN
|
||||
struct PipelineLayoutData
|
||||
{
|
||||
|
@@ -158,7 +158,7 @@ Texture2D *RenderResource::LoadTexture2D(const OSString &filename,bool auto_mipm
|
||||
|
||||
if(du)
|
||||
{
|
||||
const UTF8String name=U8_TEXT("Tex2D:")+ToUTF8String(filename);
|
||||
const U8String name=U8_TEXT("Tex2D:")+ToU8String(filename);
|
||||
|
||||
du->SetImage(tex->GetImage(),(char *)(name.c_str()));
|
||||
}
|
||||
|
@@ -1,66 +1,17 @@
|
||||
#include<hgl/graph/VKRenderTarget.h>
|
||||
#include<hgl/graph/VKDevice.h>
|
||||
#include<hgl/graph/VKSwapchain.h>
|
||||
#include<hgl/graph/VKCommandBuffer.h>
|
||||
#include<hgl/graph/VKSemaphore.h>
|
||||
#include<hgl/graph/VKFramebuffer.h>
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
RenderTarget::RenderTarget(DeviceQueue *q,Semaphore *s)
|
||||
{
|
||||
queue=q;
|
||||
render_pass=nullptr;
|
||||
fbo=nullptr;
|
||||
|
||||
color_count=0;
|
||||
color_textures=nullptr;
|
||||
depth_texture=nullptr;
|
||||
render_complete_semaphore=s;
|
||||
}
|
||||
|
||||
RenderTarget::RenderTarget(DeviceQueue *q,Semaphore *s,RenderPass *_rp,Framebuffer *_fb,Texture2D **ctl,const uint32_t cc,Texture2D *dt)
|
||||
{
|
||||
queue=q;
|
||||
render_pass=_rp;
|
||||
fbo=_fb;
|
||||
|
||||
depth_texture=dt;
|
||||
|
||||
color_count=cc;
|
||||
if(color_count>0)
|
||||
{
|
||||
color_textures=new Texture2D *[color_count];
|
||||
hgl_cpy(color_textures,ctl,color_count);
|
||||
|
||||
extent.width=color_textures[0]->GetWidth();
|
||||
extent.height=color_textures[0]->GetHeight();
|
||||
}
|
||||
else
|
||||
{
|
||||
color_textures=nullptr;
|
||||
|
||||
if(depth_texture)
|
||||
{
|
||||
extent.width=depth_texture->GetWidth();
|
||||
extent.height=depth_texture->GetHeight();
|
||||
}
|
||||
}
|
||||
|
||||
render_complete_semaphore=s;
|
||||
}
|
||||
|
||||
RenderTarget::~RenderTarget()
|
||||
void RenderTargetData::Clear()
|
||||
{
|
||||
SAFE_CLEAR(queue);
|
||||
SAFE_CLEAR(depth_texture);
|
||||
SAFE_CLEAR_OBJECT_ARRAY_OBJECT(color_textures,color_count);
|
||||
|
||||
SAFE_CLEAR(render_complete_semaphore);
|
||||
SAFE_CLEAR(fbo);
|
||||
SAFE_CLEAR_OBJECT_ARRAY_OBJECT(color_textures,color_count);
|
||||
SAFE_CLEAR(depth_texture);
|
||||
}
|
||||
|
||||
bool RenderTarget::Submit(RenderCmdBuffer *command_buffer,Semaphore *present_complete_semaphore)
|
||||
{
|
||||
return queue->Submit(*command_buffer,present_complete_semaphore,render_complete_semaphore);
|
||||
}
|
||||
VK_NAMESPACE_END
|
@@ -24,25 +24,29 @@ PrimitiveDataBuffer::~PrimitiveDataBuffer()
|
||||
delete[] vab_list;
|
||||
}
|
||||
|
||||
const bool PrimitiveDataBuffer::Comp(const PrimitiveDataBuffer *pdb)const
|
||||
const int PrimitiveDataBuffer::compare(const PrimitiveDataBuffer &pdb)const
|
||||
{
|
||||
if(!pdb)return(false);
|
||||
ptrdiff_t off;
|
||||
|
||||
if(vdm&&pdb->vdm)
|
||||
return (vdm==pdb->vdm);
|
||||
off=&vdm-&pdb.vdm;
|
||||
if(off)
|
||||
return off;
|
||||
|
||||
if(vab_count!=pdb->vab_count)return(false);
|
||||
off=vab_count-pdb.vab_count;
|
||||
if(off)
|
||||
return off;
|
||||
|
||||
for(uint32_t i=0;i<vab_count;i++)
|
||||
{
|
||||
if(vab_list[i]!=pdb->vab_list[i])return(false);
|
||||
if(vab_offset[i]!=pdb->vab_offset[i])return(false);
|
||||
}
|
||||
off=hgl_cmp(vab_list,pdb.vab_list,vab_count);
|
||||
if(off)
|
||||
return off;
|
||||
|
||||
if(ibo!=pdb->ibo)
|
||||
return(false);
|
||||
off=hgl_cmp(vab_offset,pdb.vab_offset,vab_count);
|
||||
if(off)
|
||||
return off;
|
||||
|
||||
return(true);
|
||||
off=ibo-pdb.ibo;
|
||||
|
||||
return off;
|
||||
}
|
||||
|
||||
Renderable::Renderable(Primitive *r,MaterialInstance *mi,Pipeline *p,PrimitiveDataBuffer *pdb,PrimitiveRenderData *prd)
|
||||
@@ -61,7 +65,7 @@ Renderable *CreateRenderable(Primitive *prim,MaterialInstance *mi,Pipeline *p)
|
||||
|
||||
const VIL *vil=mi->GetVIL();
|
||||
|
||||
if(vil->Comp(p->GetVIL()))
|
||||
if(*vil!=*p->GetVIL())
|
||||
return(nullptr);
|
||||
|
||||
const uint32_t input_count=vil->GetVertexAttribCount(VertexInputGroup::Basic); //不统计Bone/LocalToWorld组的
|
||||
|
@@ -1,12 +1,11 @@
|
||||
#include<hgl/graph/VKSwapchain.h>
|
||||
#include<hgl/graph/VKFramebuffer.h>
|
||||
#include<hgl/graph/VKRenderPass.h>
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
Swapchain::~Swapchain()
|
||||
{
|
||||
SAFE_CLEAR_OBJECT_ARRAY_OBJECT(sc_fbo,color_count);
|
||||
SAFE_CLEAR(sc_depth);
|
||||
SAFE_CLEAR_OBJECT_ARRAY_OBJECT(sc_color,color_count)
|
||||
SAFE_CLEAR_ARRAY(sc_image);
|
||||
|
||||
if(swap_chain)
|
||||
{
|
||||
@@ -14,6 +13,6 @@ Swapchain::~Swapchain()
|
||||
swap_chain=VK_NULL_HANDLE;
|
||||
}
|
||||
|
||||
color_count=0;
|
||||
image_count=0;
|
||||
}
|
||||
VK_NAMESPACE_END
|
||||
|
@@ -3,7 +3,7 @@
|
||||
#include<hgl/graph/VKSemaphore.h>
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
RTSwapchain::RTSwapchain(VkDevice dev,Swapchain *sc,DeviceQueue *q,Semaphore *rcs,Semaphore *pcs,RenderPass *rp):RenderTarget(q,rcs)
|
||||
SwapchainRenderTarget::SwapchainRenderTarget(VkDevice dev,Swapchain *sc,Semaphore *pcs,RenderTarget **rtl):MFRenderTarget(sc->image_count,rtl)
|
||||
{
|
||||
device=dev;
|
||||
|
||||
@@ -14,34 +14,37 @@ RTSwapchain::RTSwapchain(VkDevice dev,Swapchain *sc,DeviceQueue *q,Semaphore *rc
|
||||
present_info.swapchainCount = 1;
|
||||
present_info.pResults = nullptr;
|
||||
present_info.pSwapchains = &(swapchain->swap_chain);
|
||||
|
||||
render_pass=rp;
|
||||
|
||||
extent=swapchain->extent;
|
||||
|
||||
current_frame=0;
|
||||
|
||||
present_complete_semaphore=pcs;
|
||||
}
|
||||
|
||||
RTSwapchain::~RTSwapchain()
|
||||
SwapchainRenderTarget::~SwapchainRenderTarget()
|
||||
{
|
||||
delete present_complete_semaphore;
|
||||
delete swapchain;
|
||||
}
|
||||
|
||||
int RTSwapchain::AcquireNextImage()
|
||||
int SwapchainRenderTarget::AcquireNextImage()
|
||||
{
|
||||
if(vkAcquireNextImageKHR(device,swapchain->swap_chain,UINT64_MAX,*(this->present_complete_semaphore),VK_NULL_HANDLE,¤t_frame)==VK_SUCCESS)
|
||||
if(vkAcquireNextImageKHR(device,
|
||||
swapchain->swap_chain,
|
||||
UINT64_MAX,
|
||||
*present_complete_semaphore,
|
||||
VK_NULL_HANDLE,
|
||||
¤t_frame)==VK_SUCCESS)
|
||||
return current_frame;
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
bool RTSwapchain::PresentBackbuffer(VkSemaphore *wait_semaphores,const uint32_t count)
|
||||
bool SwapchainRenderTarget::PresentBackbuffer()
|
||||
{
|
||||
present_info.waitSemaphoreCount =count;
|
||||
present_info.pWaitSemaphores =wait_semaphores;
|
||||
DeviceQueue *queue=GetQueue();
|
||||
|
||||
VkSemaphore wait_semaphores=*GetRenderCompleteSemaphore();
|
||||
|
||||
present_info.waitSemaphoreCount =1;
|
||||
present_info.pWaitSemaphores =&wait_semaphores;
|
||||
present_info.pImageIndices =¤t_frame;
|
||||
|
||||
VkResult result=queue->Present(&present_info);
|
||||
@@ -57,21 +60,4 @@ bool RTSwapchain::PresentBackbuffer(VkSemaphore *wait_semaphores,const uint32_t
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
bool RTSwapchain::PresentBackbuffer()
|
||||
{
|
||||
VkSemaphore sem=*render_complete_semaphore;
|
||||
|
||||
return this->PresentBackbuffer(&sem,1);
|
||||
}
|
||||
|
||||
bool RTSwapchain::Submit(VkCommandBuffer cb)
|
||||
{
|
||||
return queue->Submit(cb,present_complete_semaphore,render_complete_semaphore);
|
||||
}
|
||||
|
||||
bool RTSwapchain::Submit(VkCommandBuffer cb,Semaphore *pce)
|
||||
{
|
||||
return queue->Submit(cb,pce,render_complete_semaphore);
|
||||
}
|
||||
VK_NAMESPACE_END
|
||||
|
@@ -30,7 +30,7 @@ namespace hgl
|
||||
* @param rs 每个字符在纹理中的UV坐标
|
||||
* @param chars_sets 要注册的字符合集
|
||||
*/
|
||||
bool TileFont::Registry(TileUVFloatMap &uv_map,SortedSets<u32char> &chars_sets)
|
||||
bool TileFont::Registry(TileUVFloatMap &uv_map,SortedSet<u32char> &chars_sets)
|
||||
{
|
||||
ResPoolStats stats;
|
||||
|
||||
|
@@ -35,7 +35,7 @@ const AnsiString *LoadShader(const AnsiString &shader_name)
|
||||
|
||||
shader=new AnsiString;
|
||||
|
||||
if(LoadStringFromTextFile((UTF8String &)*shader,os_fn)<=0)
|
||||
if(LoadStringFromTextFile((U8String &)*shader,os_fn)<=0)
|
||||
{
|
||||
delete shader;
|
||||
shader=nullptr;
|
||||
|
@@ -45,6 +45,90 @@ namespace
|
||||
constexpr const char AtomicCounterTypename[]="atomic_uint";
|
||||
}//namespace
|
||||
|
||||
const bool ShaderVariableType::Check()const
|
||||
{
|
||||
if(!RangeCheck(base_type))return(false);
|
||||
|
||||
RANGE_CHECK_RETURN_FALSE(base_type)
|
||||
|
||||
if(base_type==SVBaseType::Scalar)
|
||||
return(true);
|
||||
|
||||
if(base_type==SVBaseType::Vector)
|
||||
{
|
||||
if(vector.vec_size<2||vector.vec_size>4)return(false);
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
if(base_type==SVBaseType::Matrix)
|
||||
{
|
||||
if(matrix.m==0)
|
||||
{
|
||||
if(matrix.n<2||matrix.n>4)return(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(matrix.n<2||matrix.n>4)return(false);
|
||||
if(matrix.m<2||matrix.m>4)return(false);
|
||||
}
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
if(base_type==SVBaseType::Sampler)
|
||||
return RangeCheck(sampler.type);
|
||||
|
||||
if(base_type==SVBaseType::Image)
|
||||
return RangeCheck(image.type);
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
const int ShaderVariableType::compare(const ShaderVariableType &svt)const
|
||||
{
|
||||
int off=(int)base_type-(int)svt.base_type;
|
||||
|
||||
if(off)return(off);
|
||||
|
||||
if(base_type==SVBaseType::Scalar)
|
||||
return int(scalar.type)-int(svt.scalar.type);
|
||||
|
||||
if(base_type==SVBaseType::Vector)
|
||||
{
|
||||
off=int(vector.type)-int(svt.vector.type);
|
||||
|
||||
if(off)return(off);
|
||||
|
||||
off=vector.vec_size-svt.vector.vec_size;
|
||||
|
||||
if(off)return(off);
|
||||
|
||||
return int(vector.type)-int(svt.vector.type);
|
||||
}
|
||||
|
||||
if(base_type==SVBaseType::Matrix)
|
||||
{
|
||||
off=int(matrix.type)-int(svt.matrix.type);
|
||||
|
||||
if(off)return(off);
|
||||
|
||||
off=matrix.n-svt.matrix.n;
|
||||
|
||||
if(off)return(off);
|
||||
|
||||
return matrix.m-svt.matrix.m;
|
||||
}
|
||||
|
||||
if(base_type==SVBaseType::Sampler)
|
||||
return int(sampler.type)-int(svt.sampler.type);
|
||||
|
||||
if(base_type==SVBaseType::Image)
|
||||
return int(image.type)-int(svt.image.type);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
const char *ShaderVariableType::GetTypename()const
|
||||
{
|
||||
if(base_type==SVBaseType::Scalar)
|
||||
@@ -268,4 +352,28 @@ bool ShaderVariableType::ParseTypeString(const char *str)
|
||||
|
||||
return(false);
|
||||
}
|
||||
|
||||
const bool ShaderVariableType::From(const VAType &vat,const uint16 count)
|
||||
{
|
||||
array_size=count;
|
||||
|
||||
if(vat.vec_size==1)
|
||||
{
|
||||
base_type=SVBaseType::Scalar;
|
||||
scalar.type=vat.basetype;
|
||||
|
||||
return(true);
|
||||
}
|
||||
else if(vat.vec_size<=4)
|
||||
{
|
||||
base_type=SVBaseType::Vector;
|
||||
|
||||
vector.type=vat.basetype;
|
||||
vector.vec_size=vat.vec_size;
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
return(false);
|
||||
}
|
||||
VK_NAMESPACE_END
|
||||
|
Reference in New Issue
Block a user