Compare commits
41 Commits
devel_39_C
...
devel_39_C
Author | SHA1 | Date | |
---|---|---|---|
8a99a331c0 | |||
66bb363035 | |||
455cb0aa63 | |||
e778f64f00 | |||
a641c56381 | |||
4b2f344c5c | |||
014fce2c8e | |||
692eeff4a3 | |||
5a04295f17 | |||
f1972908a1 | |||
2e7c2663e0 | |||
0e789b6f47 | |||
29aa76a917 | |||
2dd60fee7f | |||
fd1a629941 | |||
4a4326826e | |||
e8e6c20305 | |||
104e5ff615 | |||
5fec0732f3 | |||
b030684cbd | |||
33976d9bf6 | |||
e88facf834 | |||
9be5de0f57 | |||
2b251f06d4 | |||
7169429ede | |||
a858fcab99 | |||
aed57437f9 | |||
10d0c2c473 | |||
0e6546b514 | |||
44b1f13048 | |||
a50c3ef10b | |||
964c17cf94 | |||
87989a8e42 | |||
efed9ff0dd | |||
f0512edb5a | |||
ab3f771455 | |||
0b172bfc81 | |||
ee5d633596 | |||
6d211b3840 | |||
b05538b501 | |||
ada6a41fc6 |
Submodule CMAssetsManage updated: 0fae462338...0244bff1b6
2
CMCore
2
CMCore
Submodule CMCore updated: b78d31d8a0...511dd86c56
Submodule CMPlatform updated: 67e8e95665...46ae04cd50
Submodule CMSceneGraph updated: f74d7045fa...76aff5d556
2
CMUtil
2
CMUtil
Submodule CMUtil updated: 57ff3a70c9...6173c16bf1
28
doc/AssetPath.md
Normal file
28
doc/AssetPath.md
Normal file
@@ -0,0 +1,28 @@
|
||||
# AssetPath
|
||||
|
||||
具体源代码参见CMAssetManage中的AssetPath.h
|
||||
|
||||
# 大致规则
|
||||
|
||||
Asset代表的资产,意味应用程序本身所拥有的资源。而AssetPath意味指向这个资产的一个字符串。
|
||||
|
||||
AssetPath的组成规和Windows/UNIX/Linux的路径原则类似,大致如下:
|
||||
|
||||
```C++
|
||||
LOCATION:/abc/123/test_material.mtl
|
||||
```
|
||||
|
||||
LOCATION 它代表资产所在的大范围位置,是可以不存在的,也就是说如下的写法也是可以的
|
||||
```C++
|
||||
:/abc/123/test_material.mtl
|
||||
```
|
||||
这个LOCATION的定义我们暂时有以下几个:
|
||||
|
||||
| LOCATION | 意义 |
|
||||
|----------|------------------|
|
||||
| 不写 | 应用程序本身的资产包 |
|
||||
| Asset | 应用程序本身的资产包 |
|
||||
| Engine | 代表引擎资产 |
|
||||
| PlugIn | 代表插件资产 |
|
||||
| ExtPack | 应用程序扩展资产包(一般用于额外安装或下载的资产包) |
|
||||
| OS | 操作系统真实路径访问 |
|
47
doc/CreateMaterialInstance.md
Normal file
47
doc/CreateMaterialInstance.md
Normal file
@@ -0,0 +1,47 @@
|
||||
# CreateMaterialInstance
|
||||
|
||||
## 1st
|
||||
|
||||
最早最根本的方法,直接在C++代码层面通过mtl::CreateVertexColor2D()函数来创建MaterialCreateInfo
|
||||
```C++
|
||||
mtl::Material2DCreateConfig cfg(GetDeviceAttribute(),"VertexColor2D",PrimitiveType::Triangles);
|
||||
|
||||
cfg.coordinate_system=CoordinateSystem2D::NDC;
|
||||
cfg.local_to_world=false;
|
||||
|
||||
AutoDelete<mtl::MaterialCreateInfo> mci=mtl::CreateVertexColor2D(&cfg);
|
||||
|
||||
material_instance=CreateMaterialInstance(mci);
|
||||
```
|
||||
|
||||
## 2nd
|
||||
注册材质系统引入后的方法,通过名称"VertexColor2D"来创建MaterialCreateInfo
|
||||
```C++
|
||||
mtl::Material2DCreateConfig cfg(GetDeviceAttribute(),"VertexColor2D",PrimitiveType::Triangles);
|
||||
|
||||
cfg.coordinate_system=CoordinateSystem2D::NDC;
|
||||
cfg.local_to_world=false;
|
||||
|
||||
AutoDelete<mtl::MaterialCreateInfo> mci=mtl::CreateMaterialCreateInfo("VertexColor2D",&cfg);
|
||||
|
||||
material_instance=CreateMaterialInstance(mci);
|
||||
```
|
||||
|
||||
## 3rd
|
||||
其实是第二种方法在WorkObject层面的封装
|
||||
```C++
|
||||
mtl::Material2DCreateConfig cfg(GetDeviceAttribute(),"VertexColor2D",PrimitiveType::Triangles);
|
||||
|
||||
cfg.coordinate_system=CoordinateSystem2D::NDC;
|
||||
cfg.local_to_world=false;
|
||||
|
||||
material_instance=CreateMaterialInstance("VertexColor2D",&cfg);
|
||||
```
|
||||
|
||||
## 4th
|
||||
是更进一步的封装,通过材质配置文件连带Material2DCreateConfig的具体配置都进行了封闭。
|
||||
```C++
|
||||
AssetPath path(":/asset/test_material.mtl");
|
||||
|
||||
material_instance=CreateMaterialInstance(path);
|
||||
```
|
20
doc/InlineMaterial.md
Normal file
20
doc/InlineMaterial.md
Normal file
@@ -0,0 +1,20 @@
|
||||
# 程序内嵌材质/Shader
|
||||
# Material/Shader embedded in program code
|
||||
|
||||
问题(Question):
|
||||
|
||||
```
|
||||
即然可以从文件中加载材质了,那为什么还需要有程序代码中内嵌的材质/Shader呢?
|
||||
|
||||
I can load a material from a file. Why do we need a few materials/shaders embedded in the code?
|
||||
```
|
||||
|
||||
这个问题很好,答案也很简单:
|
||||
|
||||
Good question, the answer is straightforward:
|
||||
|
||||
```
|
||||
我们需要在资产损坏或丢失的情况下,依然可以渲染一些内容, 比如: 一个报错对话框。
|
||||
|
||||
We need to be able to render some content, such as an error dialog box, even if the asset is damaged or lost.
|
||||
```
|
@@ -38,7 +38,7 @@ class TestApp:public VulkanApplicationFramework
|
||||
private:
|
||||
|
||||
MaterialInstance * material_instance =nullptr;
|
||||
Renderable * render_obj =nullptr;
|
||||
Mesh * render_obj =nullptr;
|
||||
|
||||
Pipeline * pipeline =nullptr;
|
||||
|
||||
@@ -46,7 +46,7 @@ private:
|
||||
|
||||
bool InitAutoMaterial()
|
||||
{
|
||||
mtl::Material2DCreateConfig cfg(device->GetDeviceAttribute(),"VertexColor2D",Prim::Lines);
|
||||
mtl::Material2DCreateConfig cfg(device->GetDevAttr(),"VertexColor2D",PrimitiveType::Lines);
|
||||
|
||||
cfg.coordinate_system=CoordinateSystem2D::NDC;
|
||||
cfg.local_to_world=false;
|
||||
@@ -60,7 +60,7 @@ private:
|
||||
|
||||
bool InitPipeline()
|
||||
{
|
||||
pipeline=CreatePipeline(material_instance,InlinePipeline::Solid2D,Prim::Lines);
|
||||
pipeline=CreatePipeline(material_instance,InlinePipeline::Solid2D,PrimitiveType::Lines);
|
||||
|
||||
return pipeline;
|
||||
}
|
||||
@@ -74,7 +74,7 @@ private:
|
||||
if(!rpc.WriteVAB(VAN::Position, PositionFormat, position_data))return(false);
|
||||
if(!rpc.WriteVAB(VAN::Color, ColorFormat, color_data ))return(false);
|
||||
|
||||
render_obj=db->CreateRenderable(&rpc,material_instance,pipeline);
|
||||
render_obj=db->CreateMesh(&rpc,material_instance,pipeline);
|
||||
return(render_obj);
|
||||
}
|
||||
|
||||
|
@@ -36,7 +36,7 @@ private:
|
||||
Camera cam;
|
||||
|
||||
MaterialInstance * material_instance =nullptr;
|
||||
Renderable * render_obj =nullptr;
|
||||
Mesh * render_obj =nullptr;
|
||||
DeviceBuffer * ubo_camera_info =nullptr;
|
||||
DeviceBuffer * ubo_color_material =nullptr;
|
||||
DeviceBuffer * ubo_line_config =nullptr;
|
||||
@@ -53,8 +53,8 @@ private:
|
||||
return(false);
|
||||
|
||||
// pipeline=db->CreatePipeline(material_instance,sc_render_target,OS_TEXT("res/pipeline/solid2d"));
|
||||
//pipeline=CreatePipeline(material_instance,OS_TEXT("res/pipeline/alpha2d"),Prim::LineStrip); //等同上一行,为Framework重载,默认使用swapchain的render target
|
||||
pipeline=CreatePipeline(material_instance,InlinePipeline::Alpha2D,Prim::LineStrip); //等同上一行,为Framework重载,默认使用swapchain的render target
|
||||
//pipeline=CreatePipeline(material_instance,OS_TEXT("res/pipeline/alpha2d"),PrimitiveType::LineStrip); //等同上一行,为Framework重载,默认使用swapchain的render target
|
||||
pipeline=CreatePipeline(material_instance,InlinePipeline::Alpha2D,PrimitiveType::LineStrip); //等同上一行,为Framework重载,默认使用swapchain的render target
|
||||
|
||||
if(!pipeline)
|
||||
return(false);
|
||||
@@ -118,7 +118,7 @@ private:
|
||||
|
||||
if(!primitive->Set(VAN::Position, db->CreateVAB(VF_V2F,VERTEX_COUNT,position_data)))return(false);
|
||||
|
||||
render_obj=db->CreateRenderable(primitive,material_instance,pipeline);
|
||||
render_obj=db->CreateMesh(primitive,material_instance,pipeline);
|
||||
return(true);
|
||||
}
|
||||
|
||||
|
@@ -42,7 +42,7 @@ private:
|
||||
Camera cam;
|
||||
|
||||
MaterialInstance * material_instance =nullptr;
|
||||
Renderable * render_obj =nullptr;
|
||||
Mesh * render_obj =nullptr;
|
||||
|
||||
DeviceBuffer * ubo_camera_info =nullptr;
|
||||
DeviceBuffer * ubo_rb_config =nullptr;
|
||||
@@ -66,7 +66,7 @@ private:
|
||||
if(!material_instance)
|
||||
return(false);
|
||||
|
||||
pipeline=CreatePipeline(material_instance,OS_TEXT("res/pipeline/alpha2d"),Prim::SolidRectangles); //等同上一行,为Framework重载,默认使用swapchain的render target
|
||||
pipeline=CreatePipeline(material_instance,OS_TEXT("res/pipeline/alpha2d"),PrimitiveType::SolidRectangles); //等同上一行,为Framework重载,默认使用swapchain的render target
|
||||
|
||||
if(!pipeline)
|
||||
return(false);
|
||||
@@ -140,7 +140,7 @@ private:
|
||||
|
||||
if(!primitive->Set(VAN::Position, db->CreateVAB(VF_V4I16,VERTEX_COUNT,position_data)))return(false);
|
||||
|
||||
render_obj=db->CreateRenderable(primitive,material_instance,pipeline);
|
||||
render_obj=db->CreateMesh(primitive,material_instance,pipeline);
|
||||
return(true);
|
||||
}
|
||||
|
||||
|
@@ -1,6 +1,6 @@
|
||||
// Billboard
|
||||
|
||||
#include"VulkanAppFramework.h"
|
||||
#include<hgl/WorkManager.h>
|
||||
#include<hgl/filesystem/FileSystem.h>
|
||||
#include<hgl/graph/InlineGeometry.h>
|
||||
#include<hgl/graph/VKRenderResource.h>
|
||||
@@ -11,6 +11,7 @@
|
||||
#include<hgl/graph/mtl/Material3DCreateConfig.h>
|
||||
#include<hgl/graph/VertexDataManager.h>
|
||||
#include<hgl/graph/VKVertexInputConfig.h>
|
||||
#include<hgl/graph/module/TextureManager.h>
|
||||
|
||||
using namespace hgl;
|
||||
using namespace hgl::graph;
|
||||
@@ -25,12 +26,16 @@ static float lumiance_data[2]={1,1};
|
||||
static Color4f white_color(1,1,1,1);
|
||||
static Color4f yellow_color(1,1,0,1);
|
||||
|
||||
class TestApp:public SceneAppFramework
|
||||
class TestApp:public WorkObject
|
||||
{
|
||||
Color4f color;
|
||||
|
||||
private:
|
||||
|
||||
AutoDelete<RenderList> render_list =nullptr;
|
||||
|
||||
SceneNode render_root;
|
||||
|
||||
Material * mtl_plane_grid =nullptr;
|
||||
MaterialInstance * mi_plane_grid =nullptr;
|
||||
Pipeline * pipeline_plane_grid =nullptr;
|
||||
@@ -38,7 +43,7 @@ private:
|
||||
|
||||
MaterialInstance * mi_billboard =nullptr;
|
||||
Pipeline * pipeline_billboard =nullptr;
|
||||
Renderable * ro_billboard =nullptr;
|
||||
Mesh * ro_billboard =nullptr;
|
||||
|
||||
Texture2D * texture =nullptr;
|
||||
Sampler * sampler =nullptr;
|
||||
@@ -47,7 +52,7 @@ private:
|
||||
|
||||
bool InitPlaneGridMP()
|
||||
{
|
||||
mtl::Material3DCreateConfig cfg(device->GetDeviceAttribute(),"VertexLuminance3D",Prim::Lines);
|
||||
mtl::Material3DCreateConfig cfg(PrimitiveType::Lines);
|
||||
|
||||
cfg.local_to_world=true;
|
||||
|
||||
@@ -64,7 +69,7 @@ private:
|
||||
mi_plane_grid=db->CreateMaterialInstance(mtl_plane_grid,&vil_config,&white_color);
|
||||
if(!mi_plane_grid)return(false);
|
||||
|
||||
pipeline_plane_grid=CreatePipeline(mi_plane_grid,InlinePipeline::Solid3D,Prim::Lines);
|
||||
pipeline_plane_grid=CreatePipeline(mi_plane_grid,InlinePipeline::Solid3D,PrimitiveType::Lines);
|
||||
if(!pipeline_plane_grid)return(false);
|
||||
}
|
||||
|
||||
@@ -73,17 +78,15 @@ private:
|
||||
|
||||
bool InitBillboardMP()
|
||||
{
|
||||
mtl::BillboardMaterialCreateConfig cfg(device->GetDeviceAttribute(),"Billboard2D",Prim::Billboard);
|
||||
mtl::BillboardMaterialCreateConfig cfg(PrimitiveType::Billboard);
|
||||
|
||||
{
|
||||
cfg.fixed_size=true;
|
||||
|
||||
AutoDelete<mtl::MaterialCreateInfo> mci=mtl::CreateBillboard2D(&cfg);
|
||||
|
||||
mi_billboard=db->CreateMaterialInstance(mci);
|
||||
mi_billboard=CreateMaterialInstance(mtl::inline_material::Billboard2D,&cfg);
|
||||
if(!mi_billboard)return(false);
|
||||
|
||||
pipeline_billboard=CreatePipeline(mi_billboard,InlinePipeline::Solid3D,Prim::Billboard);
|
||||
pipeline_billboard=CreatePipeline(mi_billboard,InlinePipeline::Solid3D,PrimitiveType::Billboard);
|
||||
if(!pipeline_billboard)return(false);
|
||||
}
|
||||
|
||||
@@ -92,7 +95,9 @@ private:
|
||||
|
||||
bool InitTexture()
|
||||
{
|
||||
texture=db->LoadTexture2D(OS_TEXT("res/image/lena.Tex2D"),true);
|
||||
TextureManager *tex_manager=GetTextureManager();
|
||||
|
||||
texture=tex_manager->LoadTexture2D(OS_TEXT("res/image/lena.Tex2D"),true);
|
||||
if(!texture)return(false);
|
||||
|
||||
sampler=db->CreateSampler();
|
||||
@@ -109,14 +114,14 @@ private:
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
Renderable *Add(Primitive *r,MaterialInstance *mi,Pipeline *p)
|
||||
|
||||
Mesh *Add(Primitive *r,MaterialInstance *mi,Pipeline *p)
|
||||
{
|
||||
Renderable *ri=db->CreateRenderable(r,mi,p);
|
||||
Mesh *ri=db->CreateMesh(r,mi,p);
|
||||
|
||||
if(!ri)
|
||||
{
|
||||
LOG_ERROR(OS_TEXT("Create Renderable failed."));
|
||||
LOG_ERROR(OS_TEXT("Create Mesh failed."));
|
||||
return(nullptr);
|
||||
}
|
||||
|
||||
@@ -128,9 +133,9 @@ private:
|
||||
bool CreateRenderObject()
|
||||
{
|
||||
using namespace inline_geometry;
|
||||
|
||||
|
||||
{
|
||||
PrimitiveCreater pc(device,mi_plane_grid->GetVIL());
|
||||
PrimitiveCreater pc(GetDevice(),mi_plane_grid->GetVIL());
|
||||
|
||||
struct PlaneGridCreateInfo pgci;
|
||||
|
||||
@@ -144,14 +149,15 @@ private:
|
||||
}
|
||||
|
||||
{
|
||||
PrimitiveCreater pc(device,mi_billboard->GetVIL());
|
||||
PrimitiveCreater pc(GetDevice(),mi_billboard->GetVIL());
|
||||
|
||||
pc.Init("Billboard",1);
|
||||
|
||||
if(!pc.WriteVAB(VAN::Position,VF_V3F,position_data))
|
||||
return(false);
|
||||
|
||||
ro_billboard=db->CreateRenderable(&pc,mi_billboard,pipeline_billboard);
|
||||
ro_billboard=db->CreateMesh(&pc,mi_billboard,pipeline_billboard);
|
||||
|
||||
if(!ro_billboard)
|
||||
return(false);
|
||||
}
|
||||
@@ -177,16 +183,15 @@ private:
|
||||
|
||||
public:
|
||||
|
||||
using WorkObject::WorkObject;
|
||||
|
||||
~TestApp()
|
||||
{
|
||||
SAFE_CLEAR(prim_plane_grid);
|
||||
}
|
||||
|
||||
bool Init(uint w,uint h)
|
||||
bool Init()
|
||||
{
|
||||
if(!SceneAppFramework::Init(w,h))
|
||||
return(false);
|
||||
|
||||
if(!InitPlaneGridMP())
|
||||
return(false);
|
||||
|
||||
@@ -204,9 +209,9 @@ public:
|
||||
|
||||
return(true);
|
||||
}
|
||||
};//class TestApp:public CameraAppFramework
|
||||
};//class TestApp:public WorkObject
|
||||
|
||||
int main(int,char **)
|
||||
int os_main(int,os_char **)
|
||||
{
|
||||
return RunApp<TestApp>(1920,1080);
|
||||
return RunFramework<TestApp>(OS_TEXT("AutoInstance"),1024,1024);
|
||||
}
|
||||
|
@@ -1,4 +1,5 @@
|
||||
macro(CreateProject name)
|
||||
|
||||
add_executable(${name} ${ARGN} ${VULKAN_APP_FRAMEWORK})
|
||||
target_link_libraries(${name} ${ULRE})
|
||||
|
||||
|
6
example/Basic/MaterialLoader/MaterialLoader.cpp
Normal file
6
example/Basic/MaterialLoader/MaterialLoader.cpp
Normal file
@@ -0,0 +1,6 @@
|
||||
#include<hgl/graph/mtl/MaterialLibrary.h>
|
||||
|
||||
STD_MTL_NAMESPACE_BEGIN
|
||||
|
||||
|
||||
STD_MTL_NAMESPACE_END
|
@@ -38,7 +38,7 @@ private:
|
||||
SceneNode render_root;
|
||||
|
||||
MaterialInstance * material_instance =nullptr;
|
||||
Renderable * render_obj =nullptr;
|
||||
Mesh * render_obj =nullptr;
|
||||
|
||||
Pipeline * pipeline =nullptr;
|
||||
|
||||
@@ -47,32 +47,29 @@ private:
|
||||
bool InitMaterial()
|
||||
{
|
||||
{
|
||||
mtl::Material2DCreateConfig cfg(GetDeviceAttribute(),"VertexColor2D",Prim::Triangles);
|
||||
|
||||
cfg.coordinate_system=CoordinateSystem2D::NDC;
|
||||
cfg.local_to_world=true;
|
||||
|
||||
AutoDelete<mtl::MaterialCreateInfo> mci=mtl::CreateVertexColor2D(&cfg);
|
||||
mtl::Material2DCreateConfig cfg(PrimitiveType::Triangles,
|
||||
CoordinateSystem2D::NDC,
|
||||
mtl::WithLocalToWorld::With);
|
||||
|
||||
VILConfig vil_config;
|
||||
|
||||
vil_config.Add(VAN::Color,VF_V4UN8);
|
||||
|
||||
material_instance=db->CreateMaterialInstance(mci,&vil_config);
|
||||
material_instance=CreateMaterialInstance(mtl::inline_material::VertexColor2D,&cfg,&vil_config);
|
||||
}
|
||||
|
||||
if(!material_instance)
|
||||
return(false);
|
||||
|
||||
// pipeline=db->CreatePipeline(material_instance,sc_render_target,OS_TEXT("res/pipeline/solid2d"));
|
||||
pipeline=CreatePipeline(material_instance,InlinePipeline::Solid2D,Prim::Triangles); //等同上一行,为Framework重载,默认使用swapchain的render target
|
||||
pipeline=CreatePipeline(material_instance,InlinePipeline::Solid2D,PrimitiveType::Triangles); //等同上一行,为Framework重载,默认使用swapchain的render target
|
||||
|
||||
return pipeline;
|
||||
}
|
||||
|
||||
bool InitVBO()
|
||||
{
|
||||
render_obj=CreateRenderable("Triangle",VERTEX_COUNT,material_instance,pipeline,
|
||||
render_obj=CreateMesh("Triangle",VERTEX_COUNT,material_instance,pipeline,
|
||||
{
|
||||
{VAN::Position, VF_V2F, position_data},
|
||||
{VAN::Color, VF_V4UN8, color_data }
|
||||
@@ -101,15 +98,22 @@ private:
|
||||
|
||||
public:
|
||||
|
||||
TestApp(RenderFramework *rf):WorkObject(rf,rf->GetSwapchainRenderTarget())
|
||||
using WorkObject::WorkObject;
|
||||
|
||||
bool Init() override
|
||||
{
|
||||
render_list=rf->CreateRenderList();
|
||||
render_list=GetRenderFramework()->CreateRenderList();
|
||||
|
||||
if(!render_list)
|
||||
return(false);
|
||||
|
||||
if(!InitMaterial())
|
||||
return;
|
||||
return(false);
|
||||
|
||||
if(!InitVBO())
|
||||
return;
|
||||
return(false);
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
void Render(double delta_time,graph::RenderCmdBuffer *cmd)override
|
||||
|
@@ -38,7 +38,7 @@ private:
|
||||
struct
|
||||
{
|
||||
MaterialInstance * mi;
|
||||
Renderable * r;
|
||||
Mesh * mesh;
|
||||
}render_obj[DRAW_OBJECT_COUNT]{};
|
||||
|
||||
Pipeline * pipeline =nullptr;
|
||||
@@ -48,10 +48,7 @@ private:
|
||||
bool InitMaterial()
|
||||
{
|
||||
{
|
||||
mtl::Material2DCreateConfig cfg(GetDeviceAttribute(),"PureColor2D",Prim::Triangles);
|
||||
|
||||
cfg.coordinate_system=CoordinateSystem2D::NDC;
|
||||
cfg.local_to_world=true;
|
||||
mtl::Material2DCreateConfig cfg(PrimitiveType::Triangles,CoordinateSystem2D::NDC,mtl::WithLocalToWorld::With);
|
||||
|
||||
#ifndef USE_MATERIAL_FILE
|
||||
AutoDelete<mtl::MaterialCreateInfo> mci=mtl::CreatePureColor2D(&cfg); //走程序内置材质创建函数
|
||||
@@ -76,7 +73,7 @@ private:
|
||||
}
|
||||
}
|
||||
|
||||
pipeline=CreatePipeline(material,InlinePipeline::Solid2D,Prim::Triangles);
|
||||
pipeline=CreatePipeline(material,InlinePipeline::Solid2D,PrimitiveType::Triangles);
|
||||
|
||||
return pipeline;
|
||||
}
|
||||
@@ -95,14 +92,14 @@ private:
|
||||
|
||||
for(uint i=0;i<DRAW_OBJECT_COUNT;i++)
|
||||
{
|
||||
render_obj[i].r=db->CreateRenderable(prim,render_obj[i].mi,pipeline);
|
||||
render_obj[i].mesh=db->CreateMesh(prim,render_obj[i].mi,pipeline);
|
||||
|
||||
if(!render_obj[i].r)
|
||||
if(!render_obj[i].mesh)
|
||||
return(false);
|
||||
|
||||
mat=rotate(deg2rad<double>(TRI_ROTATE_ANGLE*i),AxisVector::Z);
|
||||
|
||||
render_root.Add(new SceneNode(mat,render_obj[i].r));
|
||||
render_root.Add(new SceneNode(mat,render_obj[i].mesh));
|
||||
}
|
||||
|
||||
render_root.RefreshMatrix();
|
||||
@@ -114,15 +111,22 @@ private:
|
||||
|
||||
public:
|
||||
|
||||
TestApp(RenderFramework *rf):WorkObject(rf,rf->GetSwapchainRenderTarget())
|
||||
using WorkObject::WorkObject;
|
||||
|
||||
bool Init() override
|
||||
{
|
||||
render_list=rf->CreateRenderList();
|
||||
render_list=GetRenderFramework()->CreateRenderList();
|
||||
|
||||
if(!render_list)
|
||||
return(false);
|
||||
|
||||
if(!InitMaterial())
|
||||
return;
|
||||
return(false);
|
||||
|
||||
if(!InitVBOAndRenderList())
|
||||
return;
|
||||
return(false);
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
void Render(double delta_time,graph::RenderCmdBuffer *cmd)override
|
||||
@@ -133,7 +137,7 @@ public:
|
||||
render_list->Render(cmd);
|
||||
cmd->EndRenderPass();
|
||||
}
|
||||
};//class TestApp:public VulkanApplicationFramework
|
||||
};//class TestApp:public WorkObject
|
||||
|
||||
int os_main(int,os_char **)
|
||||
{
|
||||
|
@@ -68,7 +68,7 @@ private:
|
||||
#endif
|
||||
|
||||
MaterialInstance * material_instance =nullptr;
|
||||
Renderable * render_obj =nullptr;
|
||||
Mesh * render_obj =nullptr;
|
||||
|
||||
Pipeline * pipeline =nullptr;
|
||||
|
||||
@@ -87,14 +87,11 @@ private:
|
||||
|
||||
bool InitAutoMaterial()
|
||||
{
|
||||
mtl::Material2DCreateConfig cfg(GetDeviceAttribute(),"VertexColor2d",Prim::Triangles);
|
||||
mtl::Material2DCreateConfig cfg(PrimitiveType::Triangles,
|
||||
CoordinateSystem2D::NDC,
|
||||
mtl::WithLocalToWorld::Without);
|
||||
|
||||
cfg.coordinate_system=CoordinateSystem2D::NDC;
|
||||
cfg.local_to_world=false;
|
||||
|
||||
AutoDelete<mtl::MaterialCreateInfo> mci=mtl::CreateVertexColor2D(&cfg);
|
||||
|
||||
material_instance=db->CreateMaterialInstance(mci,&vil_config);
|
||||
material_instance=CreateMaterialInstance(mtl::inline_material::VertexColor2D,&cfg,&vil_config);
|
||||
|
||||
return material_instance;
|
||||
}
|
||||
@@ -102,7 +99,7 @@ private:
|
||||
bool InitPipeline()
|
||||
{
|
||||
// pipeline=db->CreatePipeline(material_instance,sc_render_target,OS_TEXT("res/pipeline/solid2d"));
|
||||
pipeline=CreatePipeline(material_instance,InlinePipeline::Solid2D,Prim::Triangles); //等同上一行,为Framework重载,默认使用swapchain的render target
|
||||
pipeline=CreatePipeline(material_instance,InlinePipeline::Solid2D,PrimitiveType::Triangles); //等同上一行,为Framework重载,默认使用swapchain的render target
|
||||
|
||||
return pipeline;
|
||||
}
|
||||
@@ -113,7 +110,7 @@ private:
|
||||
Float32toFloat16(position_data_hf,position_data_float,VERTEX_COUNT*2);
|
||||
#endif//USE_HALF_FLOAT_POSITION
|
||||
|
||||
render_obj=CreateRenderable("Triangle",VERTEX_COUNT,material_instance,pipeline,
|
||||
render_obj=CreateMesh("Triangle",VERTEX_COUNT,material_instance,pipeline,
|
||||
{
|
||||
{VAN::Position,PositionFormat,position_data},
|
||||
{VAN::Color, ColorFormat, color_data}
|
||||
@@ -122,19 +119,23 @@ private:
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
TestApp(RenderFramework *rf):WorkObject(rf,rf->GetSwapchainRenderTarget())
|
||||
|
||||
using WorkObject::WorkObject;
|
||||
|
||||
bool Init() override
|
||||
{
|
||||
InitVIL();
|
||||
|
||||
if(!InitAutoMaterial())
|
||||
return;
|
||||
return(false);
|
||||
|
||||
if(!InitPipeline())
|
||||
return;
|
||||
return(false);
|
||||
|
||||
if(!InitVBO())
|
||||
return;
|
||||
return(false);
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
void Tick(double)override{}
|
||||
|
@@ -38,7 +38,7 @@ private:
|
||||
Color4f clear_color =Color4f(0.2f,0.2f,0.2f,1.0f);
|
||||
|
||||
MaterialInstance * material_instance =nullptr;
|
||||
Renderable * render_obj =nullptr;
|
||||
Mesh * render_obj =nullptr;
|
||||
|
||||
Pipeline * pipeline =nullptr;
|
||||
|
||||
@@ -46,12 +46,12 @@ private:
|
||||
|
||||
bool InitMaterial()
|
||||
{
|
||||
mtl::Material2DCreateConfig cfg(GetDeviceAttribute(),"VertexColor2D",Prim::Triangles);
|
||||
mtl::Material2DCreateConfig cfg(PrimitiveType::Triangles,
|
||||
CoordinateSystem2D::Ortho,
|
||||
mtl::WithLocalToWorld::Without);
|
||||
|
||||
VILConfig vil_config;
|
||||
|
||||
cfg.coordinate_system =CoordinateSystem2D::Ortho;
|
||||
|
||||
cfg.position_format = POSITION_SHADER_FORMAT; //这里指定shader中使用ivec2当做顶点输入格式
|
||||
// ^
|
||||
// + 这上下两种格式要配套,否则会出错
|
||||
@@ -60,17 +60,13 @@ private:
|
||||
|
||||
vil_config.Add(VAN::Color, COLOR_DATA_FORMAT); //这里指定VAB中使用RGBA8UNorm当做颜色数据格式
|
||||
|
||||
cfg.local_to_world=false;
|
||||
|
||||
AutoDelete<mtl::MaterialCreateInfo> mci=mtl::CreateVertexColor2D(&cfg);
|
||||
|
||||
material_instance=db->CreateMaterialInstance(mci,&vil_config);
|
||||
material_instance=CreateMaterialInstance(mtl::inline_material::VertexColor2D,&cfg,&vil_config);
|
||||
|
||||
if(!material_instance)
|
||||
return(false);
|
||||
|
||||
// pipeline=db->CreatePipeline(material_instance,sc_render_target,OS_TEXT("res/pipeline/solid2d"));
|
||||
pipeline=CreatePipeline(material_instance,InlinePipeline::Solid2D,Prim::Triangles); //等同上一行,为Framework重载,默认使用swapchain的render target
|
||||
pipeline=CreatePipeline(material_instance,InlinePipeline::Solid2D,PrimitiveType::Triangles); //等同上一行,为Framework重载,默认使用swapchain的render target
|
||||
|
||||
return pipeline;
|
||||
}
|
||||
@@ -85,7 +81,7 @@ private:
|
||||
position_data[i][1]=position_data_float[i][1]*ext.height;
|
||||
}
|
||||
|
||||
render_obj=CreateRenderable("Triangle",VERTEX_COUNT,material_instance,pipeline,
|
||||
render_obj=CreateMesh("Triangle",VERTEX_COUNT,material_instance,pipeline,
|
||||
{
|
||||
{VAN::Position,POSITION_DATA_FORMAT,position_data},
|
||||
{VAN::Color, COLOR_DATA_FORMAT, color_data}
|
||||
@@ -94,14 +90,18 @@ private:
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
TestApp(RenderFramework *rf):WorkObject(rf,rf->GetSwapchainRenderTarget())
|
||||
|
||||
using WorkObject::WorkObject;
|
||||
|
||||
bool Init() override
|
||||
{
|
||||
if(!InitMaterial())
|
||||
return;
|
||||
return(false);
|
||||
|
||||
if(!InitVBO())
|
||||
return;
|
||||
return(false);
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
void Render(double delta_time,graph::RenderCmdBuffer *cmd)override
|
||||
|
@@ -3,6 +3,7 @@
|
||||
#include<hgl/graph/VKRenderResource.h>
|
||||
#include<hgl/graph/mtl/Material2DCreateConfig.h>
|
||||
#include<hgl/graph/VKMaterialInstance.h>
|
||||
#include<hgl/graph/mtl/MaterialLibrary.h>
|
||||
|
||||
using namespace hgl;
|
||||
using namespace hgl::graph;
|
||||
@@ -33,7 +34,7 @@ private:
|
||||
Color4f clear_color =Color4f(0.2f,0.2f,0.2f,1.0f);
|
||||
|
||||
MaterialInstance * material_instance =nullptr;
|
||||
Renderable * render_obj =nullptr;
|
||||
Mesh * render_obj =nullptr;
|
||||
|
||||
Pipeline * pipeline =nullptr;
|
||||
|
||||
@@ -41,14 +42,11 @@ private:
|
||||
|
||||
bool InitAutoMaterial()
|
||||
{
|
||||
mtl::Material2DCreateConfig cfg(GetDeviceAttribute(),"VertexColor2D",Prim::Triangles);
|
||||
mtl::Material2DCreateConfig cfg(PrimitiveType::Triangles,
|
||||
CoordinateSystem2D::NDC,
|
||||
mtl::WithLocalToWorld::Without);
|
||||
|
||||
cfg.coordinate_system=CoordinateSystem2D::NDC;
|
||||
cfg.local_to_world=false;
|
||||
|
||||
AutoDelete<mtl::MaterialCreateInfo> mci=mtl::CreateVertexColor2D(&cfg);
|
||||
|
||||
material_instance=CreateMaterialInstance(mci);
|
||||
material_instance=CreateMaterialInstance(mtl::inline_material::VertexColor2D,&cfg); //这个是使用名称创建
|
||||
|
||||
return material_instance;
|
||||
}
|
||||
@@ -56,14 +54,14 @@ private:
|
||||
bool InitPipeline()
|
||||
{
|
||||
// pipeline=db->CreatePipeline(material_instance,sc_render_target,OS_TEXT("res/pipeline/solid2d"));
|
||||
pipeline=CreatePipeline(material_instance,InlinePipeline::Solid2D,Prim::Triangles); //等同上一行,为Framework重载,默认使用swapchain的render target
|
||||
pipeline=CreatePipeline(material_instance,InlinePipeline::Solid2D,PrimitiveType::Triangles); //等同上一行,为Framework重载,默认使用swapchain的render target
|
||||
|
||||
return pipeline;
|
||||
}
|
||||
|
||||
bool InitVBO()
|
||||
{
|
||||
render_obj=CreateRenderable("Triangle",VERTEX_COUNT,material_instance,pipeline,
|
||||
render_obj=CreateMesh("Triangle",VERTEX_COUNT,material_instance,pipeline,
|
||||
{
|
||||
{VAN::Position,VF_V2F,position_data},
|
||||
{VAN::Color, VF_V4F,color_data}
|
||||
@@ -73,16 +71,20 @@ private:
|
||||
|
||||
public:
|
||||
|
||||
TestApp(RenderFramework *rf):WorkObject(rf,rf->GetSwapchainRenderTarget())
|
||||
using WorkObject::WorkObject;
|
||||
|
||||
bool Init() override
|
||||
{
|
||||
if(!InitAutoMaterial())
|
||||
return;
|
||||
return(false);
|
||||
|
||||
if(!InitPipeline())
|
||||
return;
|
||||
return(false);
|
||||
|
||||
if(!InitVBO())
|
||||
return;
|
||||
return(false);
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
void Tick(double)override{}
|
||||
|
@@ -15,7 +15,7 @@ private:
|
||||
TextRender * text_render =nullptr;
|
||||
|
||||
TextPrimitive * text_primitive =nullptr;
|
||||
Renderable * render_obj =nullptr;
|
||||
Mesh * render_obj =nullptr;
|
||||
|
||||
public:
|
||||
|
||||
@@ -44,7 +44,7 @@ private:
|
||||
if(!text_primitive)
|
||||
return(false);
|
||||
|
||||
render_obj=text_render->CreateRenderable(text_primitive);
|
||||
render_obj=text_render->CreateMesh(text_primitive);
|
||||
if(!render_obj)
|
||||
return(false);
|
||||
|
||||
|
@@ -34,7 +34,7 @@ enum class GizmoShape:uint
|
||||
bool InitGizmoResource(RenderResource *);
|
||||
void FreeGizmoResource();
|
||||
|
||||
Renderable *GetGizmoRenderable(const GizmoShape &shape,const GizmoColor &color);
|
||||
Mesh *GetGizmoRenderable(const GizmoShape &shape,const GizmoColor &color);
|
||||
|
||||
StaticMesh *GetGizmoMoveStaticMesh();
|
||||
StaticMesh *GetGizmoScaleStaticMesh();
|
||||
|
@@ -45,22 +45,22 @@ void ClearGizmoMoveStaticMesh()
|
||||
|
||||
bool InitGizmoMoveStaticMesh()
|
||||
{
|
||||
Renderable *sphere=GetGizmoRenderable(GizmoShape::Sphere,GizmoColor::White);
|
||||
Renderable *cylinder[3]
|
||||
Mesh *sphere=GetGizmoRenderable(GizmoShape::Sphere,GizmoColor::White);
|
||||
Mesh *cylinder[3]
|
||||
{
|
||||
GetGizmoRenderable(GizmoShape::Cylinder,GizmoColor::Red),
|
||||
GetGizmoRenderable(GizmoShape::Cylinder,GizmoColor::Green),
|
||||
GetGizmoRenderable(GizmoShape::Cylinder,GizmoColor::Blue),
|
||||
};
|
||||
|
||||
Renderable *cone[3]
|
||||
Mesh *cone[3]
|
||||
{
|
||||
GetGizmoRenderable(GizmoShape::Cone,GizmoColor::Red),
|
||||
GetGizmoRenderable(GizmoShape::Cone,GizmoColor::Green),
|
||||
GetGizmoRenderable(GizmoShape::Cone,GizmoColor::Blue),
|
||||
};
|
||||
|
||||
Renderable *circle[3]=
|
||||
Mesh *circle[3]=
|
||||
{
|
||||
GetGizmoRenderable(GizmoShape::Circle,GizmoColor::Red),
|
||||
GetGizmoRenderable(GizmoShape::Circle,GizmoColor::Green),
|
||||
|
@@ -22,7 +22,7 @@ void ClearGizmoRotateStaticMesh()
|
||||
|
||||
bool InitGizmoRotateStaticMesh()
|
||||
{
|
||||
Renderable *torus[4]
|
||||
Mesh *torus[4]
|
||||
{
|
||||
GetGizmoRenderable(GizmoShape::Torus,GizmoColor::Red),
|
||||
GetGizmoRenderable(GizmoShape::Torus,GizmoColor::Green),
|
||||
|
@@ -45,22 +45,22 @@ void ClearGizmoScaleStaticMesh()
|
||||
|
||||
bool InitGizmoScaleStaticMesh()
|
||||
{
|
||||
Renderable *center_cube=GetGizmoRenderable(GizmoShape::Cube,GizmoColor::White);
|
||||
Renderable *cylinder[3]
|
||||
Mesh *center_cube=GetGizmoRenderable(GizmoShape::Cube,GizmoColor::White);
|
||||
Mesh *cylinder[3]
|
||||
{
|
||||
GetGizmoRenderable(GizmoShape::Cylinder,GizmoColor::Red),
|
||||
GetGizmoRenderable(GizmoShape::Cylinder,GizmoColor::Green),
|
||||
GetGizmoRenderable(GizmoShape::Cylinder,GizmoColor::Blue),
|
||||
};
|
||||
|
||||
Renderable *cube[3]
|
||||
Mesh *cube[3]
|
||||
{
|
||||
GetGizmoRenderable(GizmoShape::Cube,GizmoColor::Red),
|
||||
GetGizmoRenderable(GizmoShape::Cube,GizmoColor::Green),
|
||||
GetGizmoRenderable(GizmoShape::Cube,GizmoColor::Blue),
|
||||
};
|
||||
|
||||
Renderable *square[3]=
|
||||
Mesh *square[3]=
|
||||
{
|
||||
GetGizmoRenderable(GizmoShape::Square,GizmoColor::Red),
|
||||
GetGizmoRenderable(GizmoShape::Square,GizmoColor::Green),
|
||||
|
@@ -43,7 +43,7 @@ namespace
|
||||
{
|
||||
Primitive *prim;
|
||||
|
||||
Renderable *renderable[size_t(GizmoColor::RANGE_SIZE)];
|
||||
Mesh *renderable[size_t(GizmoColor::RANGE_SIZE)];
|
||||
};
|
||||
|
||||
GizmoRenderable gizmo_rederable[size_t(GizmoShape::RANGE_SIZE)]{};
|
||||
@@ -58,7 +58,7 @@ namespace
|
||||
gr->prim=prim;
|
||||
|
||||
for(uint i=0;i<uint(GizmoColor::RANGE_SIZE);i++)
|
||||
gr->renderable[i]=CreateRenderable(prim,gizmo_triangle.mi[i],p);
|
||||
gr->renderable[i]=CreateMesh(prim,gizmo_triangle.mi[i],p);
|
||||
}
|
||||
|
||||
bool InitMI(GizmoResource *gr)
|
||||
@@ -80,7 +80,7 @@ namespace
|
||||
return(true);
|
||||
}
|
||||
|
||||
bool InitGizmoResource2D(GPUDevice *device)
|
||||
bool InitGizmoResource2D(VulkanDevice *device)
|
||||
{
|
||||
if(!gizmo_rr)
|
||||
return(false);
|
||||
@@ -88,7 +88,7 @@ namespace
|
||||
RenderPass *render_pass=device->GetRenderPass();
|
||||
|
||||
{
|
||||
mtl::Material3DCreateConfig cfg(device->GetDeviceAttribute(),"VertexLuminance3D",Prim::Lines);
|
||||
mtl::Material3DCreateConfig cfg(device->GetDevAttr(),"VertexLuminance3D",PrimitiveType::Lines);
|
||||
|
||||
cfg.mtl_name="VertexLuminance3D"; //注意必须用不同名字,未来改名材质文件名+cfg hash名
|
||||
cfg.local_to_world=true;
|
||||
@@ -107,7 +107,7 @@ namespace
|
||||
}
|
||||
|
||||
{
|
||||
gizmo_line.pipeline=render_pass->CreatePipeline(gizmo_line.mtl,InlinePipeline::Solid3D,Prim::Lines);
|
||||
gizmo_line.pipeline=render_pass->CreatePipeline(gizmo_line.mtl,InlinePipeline::Solid3D,PrimitiveType::Lines);
|
||||
|
||||
if(!gizmo_line.pipeline)
|
||||
return(false);
|
||||
@@ -134,7 +134,7 @@ namespace
|
||||
return(true);
|
||||
}
|
||||
|
||||
bool InitGizmoResource3D(GPUDevice *device)
|
||||
bool InitGizmoResource3D(VulkanDevice *device)
|
||||
{
|
||||
if(!gizmo_rr)
|
||||
return(false);
|
||||
@@ -142,7 +142,7 @@ namespace
|
||||
RenderPass *render_pass=device->GetRenderPass();
|
||||
|
||||
{
|
||||
mtl::Material3DCreateConfig cfg(device->GetDeviceAttribute(),"Gizmo3D",Prim::Triangles);
|
||||
mtl::Material3DCreateConfig cfg(device->GetDevAttr(),"Gizmo3D",PrimitiveType::Triangles);
|
||||
|
||||
cfg.local_to_world=true;
|
||||
cfg.material_instance=true;
|
||||
@@ -160,7 +160,7 @@ namespace
|
||||
}
|
||||
|
||||
{
|
||||
gizmo_triangle.pipeline=render_pass->CreatePipeline(gizmo_triangle.mtl,InlinePipeline::Solid3D,Prim::Triangles);
|
||||
gizmo_triangle.pipeline=render_pass->CreatePipeline(gizmo_triangle.mtl,InlinePipeline::Solid3D,PrimitiveType::Triangles);
|
||||
if(!gizmo_triangle.pipeline)
|
||||
return(false);
|
||||
}
|
||||
@@ -272,7 +272,7 @@ bool InitGizmoResource(RenderResource *rr)
|
||||
|
||||
gizmo_rr=rr;
|
||||
|
||||
GPUDevice *device=gizmo_rr->GetDevice();
|
||||
VulkanDevice *device=gizmo_rr->GetDevice();
|
||||
|
||||
if(!InitGizmoResource3D(device))
|
||||
return(false);
|
||||
@@ -306,7 +306,7 @@ void FreeGizmoResource()
|
||||
SAFE_CLEAR(gizmo_line.vdm);
|
||||
}
|
||||
|
||||
Renderable *GetGizmoRenderable(const GizmoShape &shape,const GizmoColor &color)
|
||||
Mesh *GetGizmoRenderable(const GizmoShape &shape,const GizmoColor &color)
|
||||
{
|
||||
if(!gizmo_rr)
|
||||
return(nullptr);
|
||||
|
@@ -35,7 +35,7 @@ constexpr const float GIZMO_CYLINDER_OFFSET =GIZMO_CYLINDER_HALF_LENGTH+GIZM
|
||||
|
||||
constexpr const float GIZMO_TWO_AXIS_OFFSET =5.0F; ///<二轴调节点偏移量(方片或圆)
|
||||
|
||||
Renderable *GetGizmoRenderable(const GizmoShape &gs,const GizmoColor &);
|
||||
Mesh *GetGizmoRenderable(const GizmoShape &gs,const GizmoColor &);
|
||||
|
||||
StaticMesh *CreateGizmoStaticMesh(SceneNode *);
|
||||
|
||||
|
@@ -49,7 +49,7 @@ private:
|
||||
|
||||
bool InitMDP()
|
||||
{
|
||||
mtl::Material3DCreateConfig cfg(device->GetDeviceAttribute(),"MetricCellsGrid",Prim::Fan);
|
||||
mtl::Material3DCreateConfig cfg(device->GetDevAttr(),"MetricCellsGrid",PrimitiveType::Fan);
|
||||
|
||||
cfg.local_to_world=true;
|
||||
|
||||
@@ -76,7 +76,7 @@ private:
|
||||
|
||||
material_instance=db->CreateMaterialInstance(material,nullptr,&mcg_data);
|
||||
|
||||
pipeline=CreatePipeline(material,InlinePipeline::Solid3D,Prim::Fan);
|
||||
pipeline=CreatePipeline(material,InlinePipeline::Solid3D,PrimitiveType::Fan);
|
||||
|
||||
return pipeline;
|
||||
}
|
||||
@@ -93,9 +93,9 @@ private:
|
||||
return ro_plane;
|
||||
}
|
||||
|
||||
Renderable *Add(MaterialInstance *mi,const Matrix4f &mat)
|
||||
Mesh *Add(MaterialInstance *mi,const Matrix4f &mat)
|
||||
{
|
||||
Renderable *ri=db->CreateRenderable(ro_plane,mi,pipeline);
|
||||
Mesh *ri=db->CreateMesh(ro_plane,mi,pipeline);
|
||||
|
||||
if(!ri)
|
||||
return(nullptr);
|
||||
|
@@ -26,7 +26,7 @@ private:
|
||||
|
||||
bool InitMDP()
|
||||
{
|
||||
mtl::Material3DCreateConfig cfg(device->GetDeviceAttribute(),"VertexLuminance3D",Prim::Lines);
|
||||
mtl::Material3DCreateConfig cfg(device->GetDevAttr(),"VertexLuminance3D",PrimitiveType::Lines);
|
||||
|
||||
cfg.local_to_world=true;
|
||||
cfg.position_format=VAT_VEC2;
|
||||
@@ -50,7 +50,7 @@ private:
|
||||
ce=COLOR((int)ce+1);
|
||||
}
|
||||
|
||||
pipeline=CreatePipeline(material_instance[0],InlinePipeline::Solid3D,Prim::Lines);
|
||||
pipeline=CreatePipeline(material_instance[0],InlinePipeline::Solid3D,PrimitiveType::Lines);
|
||||
|
||||
return pipeline;
|
||||
}
|
||||
@@ -74,9 +74,9 @@ private:
|
||||
return prim_plane_grid;
|
||||
}
|
||||
|
||||
Renderable *Add(MaterialInstance *mi,const Matrix4f &mat)
|
||||
Mesh *Add(MaterialInstance *mi,const Matrix4f &mat)
|
||||
{
|
||||
Renderable *ri=db->CreateRenderable(prim_plane_grid,mi,pipeline);
|
||||
Mesh *ri=db->CreateMesh(prim_plane_grid,mi,pipeline);
|
||||
|
||||
if(!ri)
|
||||
return(nullptr);
|
||||
|
@@ -51,7 +51,7 @@ private:
|
||||
|
||||
bool InitMaterialAndPipeline()
|
||||
{
|
||||
mtl::Material3DCreateConfig cfg(device->GetDeviceAttribute(),"VertexLuminance2D",Prim::Lines);
|
||||
mtl::Material3DCreateConfig cfg(device->GetDevAttr(),"VertexLuminance2D",PrimitiveType::Lines);
|
||||
|
||||
cfg.local_to_world=true;
|
||||
|
||||
@@ -69,7 +69,7 @@ private:
|
||||
mi_plane_grid=db->CreateMaterialInstance(mtl_plane_grid,&vil_config,&white_color);
|
||||
if(!mi_plane_grid)return(false);
|
||||
|
||||
pipeline_plane_grid=CreatePipeline(mi_plane_grid,InlinePipeline::Solid3D,Prim::Lines);
|
||||
pipeline_plane_grid=CreatePipeline(mi_plane_grid,InlinePipeline::Solid3D,PrimitiveType::Lines);
|
||||
if(!pipeline_plane_grid)return(false);
|
||||
}
|
||||
|
||||
@@ -83,7 +83,7 @@ private:
|
||||
mi_line=db->CreateMaterialInstance(mtl_line,nullptr,&yellow_color);
|
||||
if(!mi_line)return(false);
|
||||
|
||||
pipeline_line=CreatePipeline(mtl_line,InlinePipeline::Solid3D,Prim::Lines);
|
||||
pipeline_line=CreatePipeline(mtl_line,InlinePipeline::Solid3D,PrimitiveType::Lines);
|
||||
|
||||
if(!pipeline_line)
|
||||
return(false);
|
||||
@@ -92,13 +92,13 @@ private:
|
||||
return(true);
|
||||
}
|
||||
|
||||
Renderable *Add(Primitive *r,MaterialInstance *mi,Pipeline *p)
|
||||
Mesh *Add(Primitive *r,MaterialInstance *mi,Pipeline *p)
|
||||
{
|
||||
Renderable *ri=db->CreateRenderable(r,mi,p);
|
||||
Mesh *ri=db->CreateMesh(r,mi,p);
|
||||
|
||||
if(!ri)
|
||||
{
|
||||
LOG_ERROR(OS_TEXT("Create Renderable failed."));
|
||||
LOG_ERROR(OS_TEXT("Create Mesh failed."));
|
||||
return(nullptr);
|
||||
}
|
||||
|
||||
|
@@ -104,7 +104,7 @@ private:
|
||||
|
||||
bool InitVertexLumMP()
|
||||
{
|
||||
mtl::Material3DCreateConfig cfg(device->GetDeviceAttribute(),"VertexLuminance3D",Prim::Lines);
|
||||
mtl::Material3DCreateConfig cfg(device->GetDevAttr(),"VertexLuminance3D",PrimitiveType::Lines);
|
||||
|
||||
cfg.local_to_world=true;
|
||||
|
||||
@@ -114,7 +114,7 @@ private:
|
||||
mi_plane_grid=db->CreateMaterialInstance(mtl_vertex_lum,nullptr,&white_color);
|
||||
if(!mi_plane_grid)return(false);
|
||||
|
||||
p_line=CreatePipeline(mtl_vertex_lum,InlinePipeline::Solid3D,Prim::Lines);
|
||||
p_line=CreatePipeline(mtl_vertex_lum,InlinePipeline::Solid3D,PrimitiveType::Lines);
|
||||
|
||||
if(!p_line)
|
||||
return(false);
|
||||
@@ -132,7 +132,7 @@ private:
|
||||
|
||||
bool InitBlinnPhongSunLightMP()
|
||||
{
|
||||
mtl::Material3DCreateConfig cfg(device->GetDeviceAttribute(),"BlinnPhong3D",Prim::Triangles);
|
||||
mtl::Material3DCreateConfig cfg(device->GetDevAttr(),"BlinnPhong3D",PrimitiveType::Triangles);
|
||||
|
||||
cfg.local_to_world=true;
|
||||
cfg.material_instance=true;
|
||||
@@ -170,7 +170,7 @@ private:
|
||||
if(!mi_blinnphong[i])return(false);
|
||||
}
|
||||
|
||||
p_blinnphong=CreatePipeline(mtl_blinnphong,InlinePipeline::Solid3D,Prim::Triangles);
|
||||
p_blinnphong=CreatePipeline(mtl_blinnphong,InlinePipeline::Solid3D,PrimitiveType::Triangles);
|
||||
|
||||
if(!p_blinnphong)
|
||||
return(false);
|
||||
@@ -243,7 +243,7 @@ private:
|
||||
return(true);
|
||||
}
|
||||
|
||||
Renderable *Add(Primitive *r,MaterialInstance *mi,Pipeline *p,const Matrix4f &mat=Identity4f)
|
||||
Mesh *Add(Primitive *r,MaterialInstance *mi,Pipeline *p,const Matrix4f &mat=Identity4f)
|
||||
{
|
||||
if(!r)
|
||||
return(nullptr);
|
||||
@@ -252,11 +252,11 @@ private:
|
||||
if(!p)
|
||||
return(nullptr);
|
||||
|
||||
Renderable *ri=db->CreateRenderable(r,mi,p);
|
||||
Mesh *ri=db->CreateMesh(r,mi,p);
|
||||
|
||||
if(!ri)
|
||||
{
|
||||
LOG_ERROR("Create Renderable failed! Primitive: "+r->GetName());
|
||||
LOG_ERROR("Create Mesh failed! Primitive: "+r->GetName());
|
||||
return(nullptr);
|
||||
}
|
||||
|
||||
|
@@ -38,8 +38,8 @@ int main(int,char **)
|
||||
{
|
||||
Window * win =nullptr;
|
||||
VulkanInstance * inst =nullptr;
|
||||
GPUDevice * device =nullptr;
|
||||
const GPUPhysicalDevice * physical_device =nullptr;
|
||||
VulkanDevice * device =nullptr;
|
||||
const VulkanPhyDevice * physical_device =nullptr;
|
||||
|
||||
inst=InitVulkanInstance();
|
||||
|
||||
@@ -100,4 +100,4 @@ int main(int,char **)
|
||||
delete inst;
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@@ -12,7 +12,7 @@ using namespace hgl;
|
||||
using namespace hgl::graph;
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
Texture2D *CreateTexture2DFromFile(GPUDevice *device,const OSString &filename);
|
||||
Texture2D *CreateTexture2DFromFile(VulkanDevice *device,const OSString &filename);
|
||||
VK_NAMESPACE_END
|
||||
|
||||
constexpr uint32_t SCREEN_WIDTH=256;
|
||||
@@ -44,14 +44,14 @@ private:
|
||||
Sampler * sampler =nullptr;
|
||||
Material * material =nullptr;
|
||||
MaterialInstance * material_instance =nullptr;
|
||||
Renderable * render_obj =nullptr;
|
||||
Mesh * render_obj =nullptr;
|
||||
Pipeline * pipeline =nullptr;
|
||||
|
||||
private:
|
||||
|
||||
bool InitMaterial()
|
||||
{
|
||||
mtl::Material2DCreateConfig cfg(device->GetDeviceAttribute(),"PureTexture2D",Prim::Fan);
|
||||
mtl::Material2DCreateConfig cfg(device->GetDevAttr(),"PureTexture2D",PrimitiveType::Fan);
|
||||
|
||||
cfg.coordinate_system=CoordinateSystem2D::NDC;
|
||||
cfg.local_to_world=false;
|
||||
@@ -62,7 +62,7 @@ private:
|
||||
return(false);
|
||||
|
||||
// pipeline=db->CreatePipeline(material_instance,sc_render_target,OS_TEXT("res/pipeline/solid2d"));
|
||||
pipeline=CreatePipeline(material,InlinePipeline::Solid2D,Prim::Fan); //等同上一行,为Framework重载,默认使用swapchain的render target
|
||||
pipeline=CreatePipeline(material,InlinePipeline::Solid2D,PrimitiveType::Fan); //等同上一行,为Framework重载,默认使用swapchain的render target
|
||||
|
||||
if(!pipeline)
|
||||
return(false);
|
||||
@@ -92,7 +92,7 @@ private:
|
||||
if(!rpc.WriteVAB(VAN::Position, VF_V2F, position_data))return(false);
|
||||
if(!rpc.WriteVAB(VAN::TexCoord, VF_V2F, tex_coord_data))return(false);
|
||||
|
||||
render_obj=db->CreateRenderable(&rpc,material_instance,pipeline);
|
||||
render_obj=db->CreateMesh(&rpc,material_instance,pipeline);
|
||||
return(render_obj);
|
||||
}
|
||||
|
||||
|
@@ -12,7 +12,7 @@ using namespace hgl;
|
||||
using namespace hgl::graph;
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
Texture2D *CreateTexture2DFromFile(GPUDevice *device,const OSString &filename);
|
||||
Texture2D *CreateTexture2DFromFile(VulkanDevice *device,const OSString &filename);
|
||||
VK_NAMESPACE_END
|
||||
|
||||
constexpr uint32_t SCREEN_WIDTH=256;
|
||||
@@ -40,14 +40,14 @@ private:
|
||||
Sampler * sampler =nullptr;
|
||||
Material * material =nullptr;
|
||||
MaterialInstance * material_instance =nullptr;
|
||||
Renderable * render_obj =nullptr;
|
||||
Mesh * render_obj =nullptr;
|
||||
Pipeline * pipeline =nullptr;
|
||||
|
||||
private:
|
||||
|
||||
bool InitMaterial()
|
||||
{
|
||||
mtl::Material2DCreateConfig cfg(device->GetDeviceAttribute(),"RectTexture2D",Prim::SolidRectangles);
|
||||
mtl::Material2DCreateConfig cfg(device->GetDevAttr(),"RectTexture2D",PrimitiveType::SolidRectangles);
|
||||
|
||||
cfg.coordinate_system=CoordinateSystem2D::ZeroToOne;
|
||||
cfg.local_to_world=false;
|
||||
@@ -58,7 +58,7 @@ private:
|
||||
return(false);
|
||||
|
||||
// pipeline=db->CreatePipeline(material_instance,sc_render_target,OS_TEXT("res/pipeline/solid2d"));
|
||||
pipeline=CreatePipeline(material,InlinePipeline::Solid2D,Prim::SolidRectangles); //等同上一行,为Framework重载,默认使用swapchain的render target
|
||||
pipeline=CreatePipeline(material,InlinePipeline::Solid2D,PrimitiveType::SolidRectangles); //等同上一行,为Framework重载,默认使用swapchain的render target
|
||||
|
||||
if(!pipeline)
|
||||
return(false);
|
||||
@@ -88,7 +88,7 @@ private:
|
||||
if(!rpc.WriteVAB(VAN::Position,VF_V4F,position_data))return(false);
|
||||
if(!rpc.WriteVAB(VAN::TexCoord,VF_V4F,tex_coord_data))return(false);
|
||||
|
||||
render_obj=db->CreateRenderable(&rpc,material_instance,pipeline);
|
||||
render_obj=db->CreateMesh(&rpc,material_instance,pipeline);
|
||||
return(render_obj);
|
||||
}
|
||||
|
||||
|
@@ -13,7 +13,7 @@ using namespace hgl;
|
||||
using namespace hgl::graph;
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
//Texture2D *CreateTexture2DFromFile(GPUDevice *device,const OSString &filename);
|
||||
//Texture2D *CreateTexture2DFromFile(VulkanDevice *device,const OSString &filename);
|
||||
VK_NAMESPACE_END
|
||||
|
||||
constexpr uint32_t SCREEN_WIDTH=256;
|
||||
@@ -61,7 +61,7 @@ private:
|
||||
struct
|
||||
{
|
||||
MaterialInstance * mi;
|
||||
Renderable * r;
|
||||
Mesh * mesh;
|
||||
}render_obj[TexCount]{};
|
||||
|
||||
private:
|
||||
@@ -91,7 +91,7 @@ private:
|
||||
|
||||
bool InitMaterial()
|
||||
{
|
||||
mtl::Material2DCreateConfig cfg(device->GetDeviceAttribute(),"RectTexture2DArray",Prim::SolidRectangles);
|
||||
mtl::Material2DCreateConfig cfg(device->GetDevAttr(),"RectTexture2DArray",PrimitiveType::SolidRectangles);
|
||||
|
||||
cfg.coordinate_system=CoordinateSystem2D::ZeroToOne;
|
||||
cfg.local_to_world=true;
|
||||
@@ -101,7 +101,7 @@ private:
|
||||
if(!material)
|
||||
return(false);
|
||||
|
||||
pipeline=CreatePipeline(material,InlinePipeline::Solid2D,Prim::SolidRectangles); //等同上一行,为Framework重载,默认使用swapchain的render target
|
||||
pipeline=CreatePipeline(material,InlinePipeline::Solid2D,PrimitiveType::SolidRectangles); //等同上一行,为Framework重载,默认使用swapchain的render target
|
||||
|
||||
if(!pipeline)
|
||||
return(false);
|
||||
@@ -144,14 +144,14 @@ private:
|
||||
|
||||
for(uint32_t i=0;i<TexCount;i++)
|
||||
{
|
||||
render_obj[i].r=db->CreateRenderable(prim_rectangle,render_obj[i].mi,pipeline);
|
||||
render_obj[i].mesh=db->CreateMesh(prim_rectangle,render_obj[i].mi,pipeline);
|
||||
|
||||
if(!render_obj[i].r)
|
||||
if(!render_obj[i].mesh)
|
||||
return(false);
|
||||
|
||||
offset.x=position_data[2]*float(i);
|
||||
|
||||
render_root.CreateSubNode(translate(offset),render_obj[i].r);
|
||||
render_root.CreateSubNode(translate(offset),render_obj[i].mesh);
|
||||
}
|
||||
|
||||
render_root.RefreshMatrix();
|
||||
|
@@ -5,7 +5,7 @@
|
||||
#include<hgl/filesystem/FileSystem.h>
|
||||
#include<hgl/graph/InlineGeometry.h>
|
||||
#include<hgl/graph/VKRenderResource.h>
|
||||
#include<hgl/graph/VKRenderable.h>
|
||||
#include<hgl/graph/Mesh.h>
|
||||
#include<hgl/graph/RenderList.h>
|
||||
|
||||
using namespace hgl;
|
||||
|
@@ -5,7 +5,7 @@
|
||||
#include<hgl/filesystem/FileSystem.h>
|
||||
#include<hgl/graph/InlineGeometry.h>
|
||||
#include<hgl/graph/VKRenderResource.h>
|
||||
#include<hgl/graph/VKRenderable.h>
|
||||
#include<hgl/graph/Mesh.h>
|
||||
#include<hgl/graph/VKTexture.h>
|
||||
#include<hgl/graph/RenderList.h>
|
||||
|
||||
|
@@ -103,7 +103,7 @@ private:
|
||||
|
||||
const VkFormat GetCandidateFormat(const VkFormat *fmt_list, const uint count)
|
||||
{
|
||||
auto pd = device->GetPhysicalDevice();
|
||||
auto pd = device->GetPhyDevice();
|
||||
|
||||
for (uint i = 0; i < count; i++)
|
||||
if (pd->IsColorAttachmentOptimal(fmt_list[i]))
|
||||
@@ -118,7 +118,7 @@ private:
|
||||
|
||||
const VkFormat GetDepthCandidateFormat()
|
||||
{
|
||||
auto pd = device->GetPhysicalDevice();
|
||||
auto pd = device->GetPhyDevice();
|
||||
|
||||
for (VkFormat fmt : depth_candidate_format)
|
||||
if (pd->IsDepthAttachmentOptimal(fmt))
|
||||
|
@@ -4,7 +4,7 @@
|
||||
#include<hgl/filesystem/FileSystem.h>
|
||||
#include<hgl/graph/InlineGeometry.h>
|
||||
#include<hgl/graph/VKRenderResource.h>
|
||||
#include<hgl/graph/VKRenderable.h>
|
||||
#include<hgl/graph/Mesh.h>
|
||||
#include<hgl/graph/RenderList.h>
|
||||
#include<hgl/graph/VKTexture.h>
|
||||
#include<hgl/graph/VKImageView.h>
|
||||
@@ -16,7 +16,7 @@ using namespace hgl;
|
||||
using namespace hgl::graph;
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
Texture2D *CreateTexture2DFromFile(GPUDevice *device,const OSString &filename);
|
||||
Texture2D *CreateTexture2DFromFile(VulkanDevice *device,const OSString &filename);
|
||||
VK_NAMESPACE_END
|
||||
|
||||
constexpr uint32_t SCREEN_WIDTH=1280;
|
||||
@@ -139,7 +139,7 @@ private:
|
||||
|
||||
#ifdef _DEBUG
|
||||
{
|
||||
auto da=device->GetDeviceAttribute();
|
||||
auto da=device->GetDevAttr();
|
||||
|
||||
if(da->debug_maker)
|
||||
{
|
||||
@@ -172,7 +172,7 @@ private:
|
||||
|
||||
#ifdef _DEBUG
|
||||
{
|
||||
auto da=device->GetDeviceAttribute();
|
||||
auto da=device->GetDevAttr();
|
||||
|
||||
VkQueue q=*(gbuffer.rt->GetQueue());
|
||||
VkFramebuffer fbo= gbuffer.rt->GetFramebuffer()->GetFramebuffer();
|
||||
@@ -229,7 +229,7 @@ private:
|
||||
|
||||
#ifdef _DEBUG
|
||||
{
|
||||
auto da=device->GetDeviceAttribute();
|
||||
auto da=device->GetDevAttr();
|
||||
|
||||
if(da->debug_maker)
|
||||
{
|
||||
|
@@ -5,7 +5,7 @@
|
||||
#include<hgl/filesystem/FileSystem.h>
|
||||
#include<hgl/graph/InlineGeometry.h>
|
||||
#include<hgl/graph/VKRenderResource.h>
|
||||
#include<hgl/graph/VKRenderable.h>
|
||||
#include<hgl/graph/Mesh.h>
|
||||
#include<hgl/graph/VKTexture.h>
|
||||
#include<hgl/graph/RenderList.h>
|
||||
|
||||
|
@@ -5,7 +5,7 @@
|
||||
#include<hgl/filesystem/FileSystem.h>
|
||||
#include<hgl/graph/InlineGeometry.h>
|
||||
#include<hgl/graph/VKRenderResource.h>
|
||||
#include<hgl/graph/VKRenderable.h>
|
||||
#include<hgl/graph/Mesh.h>
|
||||
#include<hgl/graph/VKTexture.h>
|
||||
#include<hgl/graph/RenderList.h>
|
||||
|
||||
@@ -109,7 +109,7 @@ private:
|
||||
VK_SAMPLER_ADDRESS_MODE_REPEAT,
|
||||
0.0f,
|
||||
VK_TRUE,
|
||||
device->GetPhysicalDevice()->GetMaxSamplerAnisotropy(),
|
||||
device->GetPhyDevice()->GetMaxSamplerAnisotropy(),
|
||||
false,
|
||||
VK_COMPARE_OP_NEVER,
|
||||
0.0f,
|
||||
|
@@ -53,7 +53,7 @@ protected:
|
||||
|
||||
protected:
|
||||
|
||||
GPUDevice * device =nullptr;
|
||||
VulkanDevice * device =nullptr;
|
||||
RenderPass * device_render_pass =nullptr;
|
||||
SwapchainRenderTarget * sc_render_target =nullptr;
|
||||
|
||||
@@ -216,11 +216,11 @@ public:
|
||||
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));
|
||||
cmd_buf[i]=device->CreateRenderCommandBuffer(device->GetPhyDevice()->GetDeviceName()+AnsiString(":RenderCmdBuffer_")+AnsiString::numberOf(i));
|
||||
}
|
||||
}
|
||||
|
||||
bool BuildCommandBuffer(RenderCmdBuffer *cb,Framebuffer *fbo,Renderable *ri)
|
||||
bool BuildCommandBuffer(RenderCmdBuffer *cb,Framebuffer *fbo,Mesh *ri)
|
||||
{
|
||||
if(!ri)return(false);
|
||||
|
||||
@@ -238,7 +238,7 @@ public:
|
||||
return(true);
|
||||
}
|
||||
|
||||
bool BuildCommandBuffer(uint32_t index,Renderable *ri)
|
||||
bool BuildCommandBuffer(uint32_t index,Mesh *ri)
|
||||
{
|
||||
if(!ri)return(false);
|
||||
|
||||
@@ -246,7 +246,7 @@ public:
|
||||
sc_render_target->GetFramebuffer(),ri);
|
||||
}
|
||||
|
||||
bool BuildCommandBuffer(Renderable *ri)
|
||||
bool BuildCommandBuffer(Mesh *ri)
|
||||
{
|
||||
if(!ri)return(false);
|
||||
|
||||
@@ -256,7 +256,7 @@ public:
|
||||
return(true);
|
||||
}
|
||||
|
||||
bool BuildCurrentCommandBuffer(Renderable *ri)
|
||||
bool BuildCurrentCommandBuffer(Mesh *ri)
|
||||
{
|
||||
if(!ri)return(false);
|
||||
|
||||
@@ -461,7 +461,7 @@ public:
|
||||
|
||||
void Update()
|
||||
{
|
||||
cur_time=GetDoubleTime();
|
||||
cur_time=GetPreciseTime();
|
||||
}
|
||||
};
|
||||
|
||||
|
@@ -80,7 +80,15 @@ namespace hgl
|
||||
|
||||
SwapchainWorkManager wm(&rf);
|
||||
|
||||
wm.Run(new WO(&rf));
|
||||
WO *wo=new WO(&rf);
|
||||
|
||||
if(!wo->Init())
|
||||
{
|
||||
delete wo;
|
||||
return(-2);
|
||||
}
|
||||
|
||||
wm.Run(wo);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@@ -2,6 +2,7 @@
|
||||
#include<hgl/type/object/TickObject.h>
|
||||
#include<hgl/graph/RenderFramework.h>
|
||||
#include<hgl/graph/VKRenderResource.h>
|
||||
#include<hgl/graph/mtl/MaterialLibrary.h>
|
||||
#include<hgl/Time.h>
|
||||
//#include<iostream>
|
||||
|
||||
@@ -35,8 +36,9 @@ namespace hgl
|
||||
public:
|
||||
|
||||
graph::RenderFramework * GetRenderFramework (){return render_framework;}
|
||||
graph::GPUDevice * GetDevice (){return render_framework->GetDevice();}
|
||||
graph::GPUDeviceAttribute * GetDeviceAttribute (){return render_framework->GetDeviceAttribute();}
|
||||
graph::VulkanDevice * GetDevice (){return render_framework->GetDevice();}
|
||||
graph::VulkanDevAttr * GetDevAttr (){return render_framework->GetDevAttr();}
|
||||
graph::TextureManager * GetTextureManager (){return render_framework->GetTextureManager();}
|
||||
|
||||
const VkExtent2D & GetExtent2D (){return cur_render_target->GetExtent();}
|
||||
|
||||
@@ -52,9 +54,11 @@ namespace hgl
|
||||
|
||||
public:
|
||||
|
||||
WorkObject(graph::RenderFramework *,graph::IRenderTarget *);
|
||||
WorkObject(graph::RenderFramework *,graph::IRenderTarget *rt=nullptr);
|
||||
virtual ~WorkObject()=default;
|
||||
|
||||
virtual bool Init()=0;
|
||||
|
||||
virtual void OnRenderTargetSwitch(graph::RenderFramework *rf,graph::IRenderTarget *rt);
|
||||
|
||||
virtual void OnResize(const VkExtent2D &){}
|
||||
@@ -73,9 +77,16 @@ namespace hgl
|
||||
return render_pass->CreatePipeline(args...);
|
||||
}
|
||||
|
||||
graph::MaterialInstance *CreateMaterialInstance(const graph::mtl::MaterialCreateInfo *mci,const graph::VILConfig *vil_cfg=nullptr)
|
||||
graph::MaterialInstance *CreateMaterialInstance(const AnsiString &mi_name,const graph::mtl::MaterialCreateInfo *mci,const graph::VILConfig *vil_cfg=nullptr)
|
||||
{
|
||||
return db->CreateMaterialInstance(mci,vil_cfg);
|
||||
return db->CreateMaterialInstance(mi_name,mci,vil_cfg);
|
||||
}
|
||||
|
||||
graph::MaterialInstance *CreateMaterialInstance(const AnsiString &mtl_name,graph::mtl::MaterialCreateConfig *mtl_cfg,const graph::VILConfig *vil_cfg=nullptr)
|
||||
{
|
||||
AutoDelete<graph::mtl::MaterialCreateInfo> mci=graph::mtl::CreateMaterialCreateInfo(GetDevAttr(),mtl_name,mtl_cfg);
|
||||
|
||||
return db->CreateMaterialInstance(mtl_name,mci,vil_cfg);
|
||||
}
|
||||
|
||||
graph::Primitive *CreatePrimitive( const AnsiString &name,
|
||||
@@ -83,7 +94,7 @@ namespace hgl
|
||||
const graph::VIL *vil,
|
||||
const std::initializer_list<graph::VertexAttribDataPtr> &vad_list);
|
||||
|
||||
graph::Renderable *CreateRenderable(const AnsiString &name,
|
||||
graph::Mesh *CreateMesh(const AnsiString &name,
|
||||
const uint32_t vertices_count,
|
||||
graph::MaterialInstance *mi,
|
||||
graph::Pipeline *pipeline,
|
||||
|
141
inc/hgl/component/Component.h
Normal file
141
inc/hgl/component/Component.h
Normal file
@@ -0,0 +1,141 @@
|
||||
#pragma once
|
||||
|
||||
#include<hgl/type/DataType.h>
|
||||
#include<hgl/type/SortedSet.h>
|
||||
#include<hgl/type/ArrayList.h>
|
||||
|
||||
/**
|
||||
* Component/Data/Manager 体系设计简要说明
|
||||
*
|
||||
* 本体系参考AMD FidelityFX,但并不完全一致。
|
||||
*
|
||||
* AMD FidelityFX中,Component存放于Entity下,而我方中与其类似的定义为SceneNode。
|
||||
* 不管是Entity还是SceneNode,它们都提供空间变换,以及子节点、Component的管理。
|
||||
* 而AMD FidelityFX中的Scene,类似于我方的SceneWorld,用于储存一个场景世界的根节点及其它世界唯一数据。
|
||||
*
|
||||
* ComponentData是每个Component的数据,用于向Component或是其它模块提供数据。
|
||||
* ComponentManager是Component的管理器,用于管理Component的创建、销毁、更新等。
|
||||
*
|
||||
* 需要注意的是:同AMD FidelityFX一样,大部分ComponentManager与SceneWorld基本无关。
|
||||
* 因为同样的数据可能出现在多个World之中。
|
||||
* 仅有那些与SceneWorld密切相关的Component它对应的Manager才会出现在SceneWorld中,比如CameraManager/LightManager。
|
||||
* 而如StaticMeshComponent之类的纯资源型就会是独立存在的。
|
||||
*
|
||||
* Component是组件的基类,所有组件都从这里派生。
|
||||
*
|
||||
*
|
||||
* RenderComponent是可渲染组件的基类,所有可渲染组件都从这里派生。它继承于Component。
|
||||
*
|
||||
* PrimitiveComponent是图元组件的基类,所有图元组件都从这里派生。它继承于RenderComponent。
|
||||
* 它再度派生出的任何Component都必须是一个有3D空间的几何图元。
|
||||
* 引擎中的空间、物理、等都由PrimitiveComponent提供数据进行计算。
|
||||
*
|
||||
* StaticMeshComponent是静态网格组件,它是一个具体的PrimitiveComponent实现。
|
||||
*
|
||||
*/
|
||||
|
||||
#define COMPONENT_NAMESPACE hgl::graph
|
||||
#define COMPONENT_NAMESPACE_BEGIN namespace COMPONENT_NAMESPACE {
|
||||
#define COMPONENT_NAMESPACE_END }
|
||||
|
||||
COMPONENT_NAMESPACE_BEGIN
|
||||
|
||||
class ComponentManager;
|
||||
class SceneNode;
|
||||
|
||||
struct ComponentData{};
|
||||
|
||||
/**
|
||||
* 基础组件<br>
|
||||
* 是一切组件的基类
|
||||
*/
|
||||
class Component
|
||||
{
|
||||
SceneNode * OwnerNode;
|
||||
ComponentManager * Manager;
|
||||
ComponentData * Data;
|
||||
|
||||
public:
|
||||
|
||||
Component()=delete;
|
||||
Component(SceneNode *sn,ComponentData *cd,ComponentManager *cm)
|
||||
{
|
||||
OwnerNode=sn;
|
||||
Data=cd;
|
||||
Manager=cm;
|
||||
}
|
||||
|
||||
virtual ~Component()
|
||||
{
|
||||
SAFE_CLEAR(Data);
|
||||
}
|
||||
|
||||
virtual const size_t GetHashCode()const=0;
|
||||
|
||||
public:
|
||||
|
||||
SceneNode * GetOwnerNode()const{return OwnerNode;}
|
||||
ComponentManager * GetManager ()const{return Manager;}
|
||||
ComponentData * GetData ()const{return Data;}
|
||||
|
||||
public:
|
||||
|
||||
//virtual void Update(const double delta_time)=0;
|
||||
|
||||
public: //事件
|
||||
|
||||
virtual void OnFocusLost(){} ///<焦点丢失事件
|
||||
virtual void OnFocusGained(){} ///<焦点获得事件
|
||||
};//class Component
|
||||
|
||||
using ComponentSet=SortedSet<Component *>;
|
||||
|
||||
class ComponentManager
|
||||
{
|
||||
ComponentSet component_set;
|
||||
|
||||
public:
|
||||
|
||||
virtual const size_t GetComponentHashCode()const=0;
|
||||
virtual const size_t GetHashCode()const=0;
|
||||
|
||||
virtual ~ComponentManager()=default;
|
||||
|
||||
public:
|
||||
|
||||
virtual Component * CreateComponent(SceneNode *,ComponentData *)=0;
|
||||
|
||||
int GetComponentCount()const{return component_set.GetCount();}
|
||||
|
||||
ComponentSet & GetComponents(){return component_set;}
|
||||
|
||||
int GetComponents(ArrayList<Component *> &comp_list,SceneNode *);
|
||||
|
||||
virtual void UpdateComponents(const double delta_time);
|
||||
|
||||
virtual void AttachComponent(Component *c){if(!c)return;component_set.Add(c);}
|
||||
virtual void DetachComponent(Component *c){if(!c)return;component_set.Delete(c);}
|
||||
|
||||
public: //事件
|
||||
|
||||
virtual void OnFocusLost(){} ///<焦点丢失事件
|
||||
virtual void OnFocusGained(){} ///<焦点获得事件
|
||||
};//class ComponentManager
|
||||
|
||||
bool RegistryComponentManager(ComponentManager *);
|
||||
ComponentManager *GetComponentManager(const size_t hash_code);
|
||||
|
||||
template<typename T> inline T *GetComponentManager(bool create_default=true)
|
||||
{
|
||||
T *cm=(T *)GetComponentManager(T::StaticHashCode());
|
||||
|
||||
if(!cm&&create_default)
|
||||
{
|
||||
cm=new T;
|
||||
|
||||
RegistryComponentManager(cm);
|
||||
}
|
||||
|
||||
return cm;
|
||||
}
|
||||
COMPONENT_NAMESPACE_END
|
20
inc/hgl/component/PrimitiveComponent.h
Normal file
20
inc/hgl/component/PrimitiveComponent.h
Normal file
@@ -0,0 +1,20 @@
|
||||
#pragma once
|
||||
|
||||
#include<hgl/component/RenderComponent.h>
|
||||
|
||||
COMPONENT_NAMESPACE_BEGIN
|
||||
|
||||
/**
|
||||
* 图元组件<br>
|
||||
* 组件中的元素必须是一个可以明确描述的几何体,可以被明确标记尺寸、参与空间、物理计算等。
|
||||
*/
|
||||
class PrimitiveComponent:public RenderComponent
|
||||
{
|
||||
public:
|
||||
|
||||
PrimitiveComponent(SceneNode *psn,ComponentData *cd,ComponentManager *cm)
|
||||
:RenderComponent(psn,cd,cm){}
|
||||
virtual ~PrimitiveComponent()=default;
|
||||
};//class PrimitiveComponent
|
||||
|
||||
COMPONENT_NAMESPACE_END
|
19
inc/hgl/component/RenderComponent.h
Normal file
19
inc/hgl/component/RenderComponent.h
Normal file
@@ -0,0 +1,19 @@
|
||||
#pragma once
|
||||
|
||||
#include<hgl/component/Component.h>
|
||||
|
||||
COMPONENT_NAMESPACE_BEGIN
|
||||
|
||||
/**
|
||||
* 可渲染组件
|
||||
*/
|
||||
class RenderComponent: public Component
|
||||
{
|
||||
public:
|
||||
|
||||
RenderComponent(SceneNode *psn,ComponentData *cd,ComponentManager *cm)
|
||||
:Component(psn,cd,cm){}
|
||||
virtual ~RenderComponent()=default;
|
||||
};//class RenderComponent
|
||||
|
||||
COMPONENT_NAMESPACE_END
|
68
inc/hgl/component/StaticMeshComponent.h
Normal file
68
inc/hgl/component/StaticMeshComponent.h
Normal file
@@ -0,0 +1,68 @@
|
||||
#pragma once
|
||||
|
||||
#include<hgl/component/PrimitiveComponent.h>
|
||||
#include<hgl/graph/Mesh.h>
|
||||
|
||||
COMPONENT_NAMESPACE_BEGIN
|
||||
|
||||
struct StaticMeshComponentData:public ComponentData
|
||||
{
|
||||
Mesh *renderable;
|
||||
};//struct StaticMeshComponentData
|
||||
|
||||
class StaticMeshComponent;
|
||||
|
||||
class StaticMeshComponentManager:public ComponentManager
|
||||
{
|
||||
public:
|
||||
|
||||
static StaticMeshComponentManager *GetDefaultManager()
|
||||
{
|
||||
return GetComponentManager<StaticMeshComponentManager>(true);
|
||||
}
|
||||
|
||||
static constexpr const size_t StaticHashCode (){return hgl::GetTypeHash<StaticMeshComponentManager>();}
|
||||
static constexpr const size_t StaticComponentHashCode (){return hgl::GetTypeHash<StaticMeshComponent>();}
|
||||
|
||||
const size_t GetComponentHashCode ()const override{return StaticMeshComponentManager::StaticComponentHashCode();}
|
||||
const size_t GetHashCode ()const override{return StaticMeshComponentManager::StaticHashCode();}
|
||||
|
||||
public:
|
||||
|
||||
StaticMeshComponentManager()=default;
|
||||
|
||||
StaticMeshComponent *CreateStaticMeshComponent(SceneNode *psn,StaticMeshComponentData *data);
|
||||
|
||||
virtual Component *CreateComponent(SceneNode *psn,ComponentData *data) override;
|
||||
};//class StaticMeshComponentManager
|
||||
|
||||
class StaticMeshComponent:public PrimitiveComponent
|
||||
{
|
||||
StaticMeshComponentData *sm_data;
|
||||
|
||||
public:
|
||||
|
||||
StaticMeshComponent(SceneNode *psn,ComponentData *cd,ComponentManager *cm)
|
||||
:PrimitiveComponent(psn,cd,cm)
|
||||
{
|
||||
sm_data=reinterpret_cast<StaticMeshComponentData *>(cd);
|
||||
}
|
||||
|
||||
virtual ~StaticMeshComponent()=default;
|
||||
|
||||
static constexpr const size_t StaticHashCode()
|
||||
{
|
||||
return hgl::GetTypeHash<StaticMeshComponent>();
|
||||
}
|
||||
|
||||
const size_t GetHashCode()const override
|
||||
{
|
||||
return StaticMeshComponent::StaticHashCode();
|
||||
}
|
||||
|
||||
StaticMeshComponentData &GetData() {return *sm_data;}
|
||||
const StaticMeshComponentData &GetData()const {return *sm_data;}
|
||||
|
||||
};//class StaticMeshComponent
|
||||
|
||||
COMPONENT_NAMESPACE_END
|
@@ -1,7 +1,7 @@
|
||||
#ifndef HGL_DB_FIELD_TYPE_INCLUDE
|
||||
#define HGL_DB_FIELD_TYPE_INCLUDE
|
||||
|
||||
#include<hgl/type/List.h>
|
||||
#include<hgl/type/ArrayList.h>
|
||||
#include<hgl/type/StringList.h>
|
||||
namespace hgl
|
||||
{
|
||||
|
@@ -1,17 +1,14 @@
|
||||
#pragma once
|
||||
|
||||
#include<hgl/TypeFunc.h>
|
||||
namespace hgl
|
||||
namespace hgl::graph
|
||||
{
|
||||
namespace graph
|
||||
enum class CoordinateSystem2D
|
||||
{
|
||||
enum class CoordinateSystem2D
|
||||
{
|
||||
NDC,
|
||||
ZeroToOne, //左上角为0,0;右下角为1,1
|
||||
Ortho, //左上角为0,0;右下角为(width-1),(height-1)
|
||||
NDC,
|
||||
ZeroToOne, //左上角为0,0;右下角为1,1
|
||||
Ortho, //左上角为0,0;右下角为(width-1),(height-1)
|
||||
|
||||
ENUM_CLASS_RANGE(NDC,Ortho)
|
||||
};
|
||||
}//namespace graph
|
||||
}//namespace hgl
|
||||
ENUM_CLASS_RANGE(NDC,Ortho)
|
||||
};
|
||||
}//namespace hgl::graph
|
||||
|
@@ -46,7 +46,7 @@ public:
|
||||
*/
|
||||
class MaterialRenderList
|
||||
{
|
||||
GPUDevice *device;
|
||||
VulkanDevice *device;
|
||||
RenderCmdBuffer *cmd_buf;
|
||||
|
||||
RenderPipelineIndex rp_index;
|
||||
@@ -68,12 +68,12 @@ private:
|
||||
|
||||
MaterialInstance * mi;
|
||||
|
||||
const PrimitiveDataBuffer * pdb;
|
||||
const PrimitiveRenderData * prd;
|
||||
const MeshDataBuffer * pdb;
|
||||
const MeshRenderData * prd;
|
||||
|
||||
public:
|
||||
|
||||
void Set(Renderable *);
|
||||
void Set(Mesh *);
|
||||
};
|
||||
|
||||
IndirectDrawBuffer *icb_draw;
|
||||
@@ -92,21 +92,21 @@ protected:
|
||||
|
||||
VABList * vab_list;
|
||||
|
||||
const PrimitiveDataBuffer * last_data_buffer;
|
||||
const MeshDataBuffer * last_data_buffer;
|
||||
const VDM * last_vdm;
|
||||
const PrimitiveRenderData * last_render_data;
|
||||
const MeshRenderData * last_render_data;
|
||||
|
||||
int first_indirect_draw_index=-1;
|
||||
uint indirect_draw_count=0;
|
||||
int first_indirect_draw_index;
|
||||
uint indirect_draw_count;
|
||||
|
||||
bool BindVAB(const PrimitiveDataBuffer *,const uint);
|
||||
bool BindVAB(const MeshDataBuffer *,const uint);
|
||||
|
||||
void ProcIndirectRender();
|
||||
void Render(RenderItem *);
|
||||
|
||||
public:
|
||||
|
||||
MaterialRenderList(GPUDevice *d,bool l2w,const RenderPipelineIndex &rpi);
|
||||
MaterialRenderList(VulkanDevice *d,bool l2w,const RenderPipelineIndex &rpi);
|
||||
~MaterialRenderList();
|
||||
|
||||
void Add(SceneNode *);
|
||||
|
@@ -12,7 +12,7 @@ VK_NAMESPACE_BEGIN
|
||||
* 原始图元数据缓冲区<Br>
|
||||
* 提供在渲染之前的数据绑定信息
|
||||
*/
|
||||
struct PrimitiveDataBuffer:public Comparator<PrimitiveDataBuffer>
|
||||
struct MeshDataBuffer:public Comparator<MeshDataBuffer>
|
||||
{
|
||||
uint32_t vab_count;
|
||||
VkBuffer * vab_list;
|
||||
@@ -29,17 +29,17 @@ struct PrimitiveDataBuffer:public Comparator<PrimitiveDataBuffer>
|
||||
|
||||
public:
|
||||
|
||||
PrimitiveDataBuffer(const uint32_t,IndexBuffer *,VertexDataManager *_v=nullptr);
|
||||
~PrimitiveDataBuffer();
|
||||
MeshDataBuffer(const uint32_t,IndexBuffer *,VertexDataManager *_v=nullptr);
|
||||
~MeshDataBuffer();
|
||||
|
||||
const int compare(const PrimitiveDataBuffer &pdb)const override;
|
||||
};//struct PrimitiveDataBuffer
|
||||
const int compare(const MeshDataBuffer &pdb)const override;
|
||||
};//struct MeshDataBuffer
|
||||
|
||||
/**
|
||||
* 原始图元渲染数据<Br>
|
||||
* 提供在渲染时的数据
|
||||
*/
|
||||
struct PrimitiveRenderData:public ComparatorData<PrimitiveRenderData>
|
||||
struct MeshRenderData:public ComparatorData<MeshRenderData>
|
||||
{
|
||||
//因为要VAB是流式访问,所以我们这个结构会被用做排序依据
|
||||
//也因此,把vertex_offset放在最前面
|
||||
@@ -52,7 +52,7 @@ struct PrimitiveRenderData:public ComparatorData<PrimitiveRenderData>
|
||||
|
||||
public:
|
||||
|
||||
PrimitiveRenderData(const uint32_t vc,const uint32_t ic,const int32_t vo=0,const uint32_t fi=0)
|
||||
MeshRenderData(const uint32_t vc,const uint32_t ic,const int32_t vo=0,const uint32_t fi=0)
|
||||
{
|
||||
vertex_count =vc;
|
||||
index_count =ic;
|
||||
@@ -62,31 +62,31 @@ public:
|
||||
};
|
||||
|
||||
/**
|
||||
* 原始可渲染对象(即仅一个模型一个材质)
|
||||
* 网格体(网格中的最小渲染单位)
|
||||
*/
|
||||
class Renderable ///可渲染对象实例
|
||||
class Mesh
|
||||
{
|
||||
Pipeline * pipeline;
|
||||
MaterialInstance * mat_inst;
|
||||
Primitive * primitive;
|
||||
|
||||
PrimitiveDataBuffer * primitive_data_buffer;
|
||||
PrimitiveRenderData * primitive_render_data;
|
||||
MeshDataBuffer * data_buffer;
|
||||
MeshRenderData * render_data;
|
||||
|
||||
private:
|
||||
|
||||
friend Renderable *CreateRenderable(Primitive *,MaterialInstance *,Pipeline *);
|
||||
friend Mesh *CreateMesh(Primitive *,MaterialInstance *,Pipeline *);
|
||||
|
||||
Renderable(Primitive *,MaterialInstance *,Pipeline *,PrimitiveDataBuffer *,PrimitiveRenderData *);
|
||||
Mesh(Primitive *,MaterialInstance *,Pipeline *,MeshDataBuffer *,MeshRenderData *);
|
||||
|
||||
public:
|
||||
|
||||
virtual ~Renderable()
|
||||
virtual ~Mesh()
|
||||
{
|
||||
//需要在这里添加删除pipeline/desc_sets/primitive引用计数的代码
|
||||
|
||||
SAFE_CLEAR(primitive_data_buffer);
|
||||
SAFE_CLEAR(primitive_render_data);
|
||||
SAFE_CLEAR(data_buffer);
|
||||
SAFE_CLEAR(render_data);
|
||||
}
|
||||
|
||||
void UpdatePipeline (Pipeline *p){pipeline=p;}
|
||||
@@ -98,8 +98,8 @@ public:
|
||||
Primitive * GetPrimitive (){return primitive;}
|
||||
const AABB & GetBoundingBox ()const{return primitive->GetBoundingBox();}
|
||||
|
||||
const PrimitiveDataBuffer *GetDataBuffer ()const{return primitive_data_buffer;}
|
||||
const PrimitiveRenderData *GetRenderData ()const{return primitive_render_data;}
|
||||
const MeshDataBuffer * GetDataBuffer ()const{return data_buffer;}
|
||||
const MeshRenderData * GetRenderData ()const{return render_data;}
|
||||
|
||||
public:
|
||||
|
||||
@@ -114,7 +114,7 @@ public:
|
||||
mat_inst=mi;
|
||||
return(true);
|
||||
}
|
||||
};//class Renderable
|
||||
};//class Mesh
|
||||
|
||||
Renderable *CreateRenderable(Primitive *,MaterialInstance *,Pipeline *);
|
||||
Mesh *CreateMesh(Primitive *,MaterialInstance *,Pipeline *);
|
||||
VK_NAMESPACE_END
|
@@ -13,7 +13,7 @@ class PrimitiveCreater
|
||||
{
|
||||
protected:
|
||||
|
||||
GPUDevice * device;
|
||||
VulkanDevice * device;
|
||||
VertexDataManager * vdm;
|
||||
|
||||
const VIL * vil;
|
||||
@@ -36,7 +36,7 @@ protected:
|
||||
|
||||
public:
|
||||
|
||||
PrimitiveCreater(GPUDevice *,const VIL *);
|
||||
PrimitiveCreater(VulkanDevice *,const VIL *);
|
||||
PrimitiveCreater(VertexDataManager *);
|
||||
virtual ~PrimitiveCreater();
|
||||
|
||||
|
@@ -17,6 +17,9 @@ class RenderTargetManager;
|
||||
|
||||
class RenderModule;
|
||||
|
||||
class CameraComponentManager{/*现阶段测试使用*/};
|
||||
class LightComponentManager{/*现阶段测试使用*/};
|
||||
|
||||
class RenderFramework:public io::WindowEvent
|
||||
{
|
||||
OSString app_name;
|
||||
@@ -24,7 +27,7 @@ class RenderFramework:public io::WindowEvent
|
||||
Window * win =nullptr;
|
||||
VulkanInstance * inst =nullptr;
|
||||
|
||||
GPUDevice * device =nullptr;
|
||||
VulkanDevice * device =nullptr;
|
||||
|
||||
RenderResource * render_resource =nullptr;
|
||||
|
||||
@@ -39,13 +42,18 @@ protected:
|
||||
|
||||
SwapchainModule * sc_module =nullptr;
|
||||
|
||||
protected:
|
||||
|
||||
CameraComponentManager *camera_component_manager=nullptr;
|
||||
LightComponentManager *light_component_manager =nullptr;
|
||||
|
||||
public:
|
||||
|
||||
Window * GetWindow ()const{return win;}
|
||||
GPUDevice * GetDevice ()const{return device;}
|
||||
VulkanDevice * GetDevice ()const{return device;}
|
||||
VkDevice GetVkDevice ()const{return device->GetDevice();}
|
||||
const GPUPhysicalDevice * GetPhysicalDevice ()const{return device->GetPhysicalDevice();}
|
||||
GPUDeviceAttribute * GetDeviceAttribute ()const{return device->GetDeviceAttribute();}
|
||||
const VulkanPhyDevice * GetPhyDevice ()const{return device->GetPhyDevice();}
|
||||
VulkanDevAttr * GetDevAttr ()const{return device->GetDevAttr();}
|
||||
|
||||
RenderResource * GetRenderResource ()const{return render_resource;}
|
||||
|
||||
@@ -67,7 +75,13 @@ public:
|
||||
|
||||
virtual bool Init(uint w,uint h);
|
||||
|
||||
public:
|
||||
public: // event
|
||||
|
||||
virtual void OnResize(uint w,uint h);
|
||||
virtual void OnActive(bool);
|
||||
virtual void OnClose();
|
||||
|
||||
public: // other
|
||||
|
||||
RenderList *CreateRenderList()
|
||||
{
|
||||
@@ -76,12 +90,22 @@ public:
|
||||
|
||||
TileFont *CreateTileFont(FontSource *fs,int limit_count=-1); ///<创建只使用一种字符的Tile字符管理对象
|
||||
|
||||
public: // event
|
||||
public: // ComponentManager
|
||||
|
||||
virtual void OnResize(uint w,uint h);
|
||||
virtual void OnActive(bool);
|
||||
virtual void OnClose();
|
||||
template<typename T> T *GetComponentManager()
|
||||
{
|
||||
return COMPONENT_NAMESPACE::GetComponentManager<T>(true);
|
||||
}
|
||||
|
||||
template<> CameraComponentManager *GetComponentManager<CameraComponentManager>()
|
||||
{
|
||||
return camera_component_manager;
|
||||
}
|
||||
|
||||
template<> LightComponentManager *GetComponentManager<LightComponentManager>()
|
||||
{
|
||||
return light_component_manager;
|
||||
}
|
||||
};//class RenderFramework
|
||||
|
||||
VK_NAMESPACE_END
|
||||
|
@@ -18,7 +18,7 @@ namespace hgl
|
||||
{
|
||||
protected:
|
||||
|
||||
GPUDevice * device;
|
||||
VulkanDevice * device;
|
||||
|
||||
CameraInfo * camera_info; ///<相机信息
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace hgl
|
||||
|
||||
public:
|
||||
|
||||
RenderList(GPUDevice *);
|
||||
RenderList(VulkanDevice *);
|
||||
virtual ~RenderList()=default;
|
||||
|
||||
virtual void SetCamera(CameraInfo *ci){camera_info=ci;} ///<设置相机信息
|
||||
|
@@ -1,13 +1,13 @@
|
||||
#ifndef HGL_GRAPH_RENDER_NODE_INCLUDE
|
||||
#define HGL_GRAPH_RENDER_NODE_INCLUDE
|
||||
#pragma once
|
||||
|
||||
#include<hgl/graph/VK.h>
|
||||
#include<hgl/type/SortedSet.h>
|
||||
|
||||
namespace hgl
|
||||
{
|
||||
namespace graph
|
||||
{
|
||||
class Renderable;
|
||||
class Mesh;
|
||||
class MaterialInstance;
|
||||
class SceneNode;
|
||||
|
||||
@@ -29,8 +29,8 @@ namespace hgl
|
||||
const int compare(const RenderNode &)const override;
|
||||
};
|
||||
|
||||
using RenderNodeList=List<RenderNode>;
|
||||
using RenderNodePointerList=List<RenderNode *>;
|
||||
using RenderNodeList=ArrayList<RenderNode>;
|
||||
using RenderNodePointerList=ArrayList<RenderNode *>;
|
||||
|
||||
using MaterialInstanceSets=SortedSet<MaterialInstance *>; ///<材质实例集合
|
||||
}//namespace graph
|
||||
@@ -40,4 +40,3 @@ namespace hgl
|
||||
return a.compare(b);
|
||||
}
|
||||
}//namespace hgl
|
||||
#endif//HGL_GRAPH_RENDER_NODE_INCLUDE
|
||||
|
@@ -4,110 +4,122 @@
|
||||
#include<hgl/type/IDName.h>
|
||||
#include<hgl/graph/SceneOrient.h>
|
||||
#include<hgl/graph/AABB.h>
|
||||
#include<hgl/component/Component.h>
|
||||
|
||||
namespace hgl
|
||||
namespace hgl::graph
|
||||
{
|
||||
namespace graph
|
||||
using SceneNodeID =uint64;
|
||||
using SceneNodeName =U16IDName;
|
||||
|
||||
/**
|
||||
* 场景节点数据类<br>
|
||||
* 从场景坐标变换(SceneOrient)类继承,
|
||||
* 每个场景节点中可能包括一个可渲染数据实例,或是完全不包含(用于坐标变换的父节点,或是灯光/摄像机之类)。
|
||||
*/
|
||||
class SceneNode:public SceneOrient ///场景节点类
|
||||
{
|
||||
using SceneNodeID =uint64;
|
||||
using SceneNodeName =U16IDName;
|
||||
SceneNode *ParentNode; ///<上级节点
|
||||
|
||||
/**
|
||||
* 场景节点数据类<br>
|
||||
* 从场景坐标变换(SceneOrient)类继承,
|
||||
* 每个场景节点中可能包括一个可渲染数据实例,或是完全不包含(用于坐标变换的父节点,或是灯光/摄像机之类)。
|
||||
*/
|
||||
class SceneNode:public SceneOrient ///场景节点类
|
||||
SceneNodeID NodeID; ///<节点ID
|
||||
SceneNodeName NodeName; ///<节点名称
|
||||
|
||||
protected:
|
||||
|
||||
AABB BoundingBox; ///<绑定盒
|
||||
AABB LocalBoundingBox; ///<本地坐标绑定盒
|
||||
//AABB WorldBoundingBox; ///<世界坐标绑定盒
|
||||
|
||||
Mesh *render_obj=nullptr; ///<可渲染实例
|
||||
|
||||
protected:
|
||||
|
||||
ObjectList<SceneNode> ChildNode; ///<子节点
|
||||
ObjectList<Component> ComponentList; ///<组件列表
|
||||
|
||||
public:
|
||||
|
||||
const SceneNodeID & GetNodeID ()const { return NodeID; } ///<取得节点ID
|
||||
const SceneNodeName & GetNodeName ()const { return NodeName; } ///<取得节点名称
|
||||
|
||||
const ObjectList<SceneNode> &GetChildNode()const { return ChildNode; } ///<取得子节点列表
|
||||
|
||||
public:
|
||||
|
||||
SceneNode()=default;
|
||||
SceneNode(const SceneNode &)=delete;
|
||||
SceneNode(const SceneNode *)=delete;
|
||||
SceneNode(const SceneOrient &so ):SceneOrient(so) {}
|
||||
SceneNode( Mesh *ri ) {render_obj=ri;}
|
||||
SceneNode(const Matrix4f &mat ):SceneOrient(mat) {}
|
||||
SceneNode(const Matrix4f &mat, Mesh *ri ):SceneOrient(mat) {render_obj=ri;}
|
||||
|
||||
public:
|
||||
|
||||
virtual ~SceneNode()=default;
|
||||
|
||||
void Clear() override
|
||||
{
|
||||
SceneNode *Owner; ///<上级节点
|
||||
SceneOrient::Clear();
|
||||
|
||||
SceneNodeID NodeID; ///<节点ID
|
||||
SceneNodeName NodeName; ///<节点名称
|
||||
ParentNode=nullptr;
|
||||
|
||||
protected:
|
||||
BoundingBox.SetZero();
|
||||
LocalBoundingBox.SetZero();
|
||||
|
||||
AABB BoundingBox; ///<绑定盒
|
||||
AABB LocalBoundingBox; ///<本地坐标绑定盒
|
||||
//AABB WorldBoundingBox; ///<世界坐标绑定盒
|
||||
ChildNode.Clear();
|
||||
ComponentList.Clear();
|
||||
render_obj=nullptr;
|
||||
}
|
||||
|
||||
Renderable *render_obj=nullptr; ///<可渲染实例
|
||||
const bool ChildNodeIsEmpty()const
|
||||
{
|
||||
if(render_obj)return(false);
|
||||
if(ChildNode.GetCount())return(false);
|
||||
|
||||
protected:
|
||||
return(true);
|
||||
}
|
||||
|
||||
ObjectList<SceneNode> ChildNode; ///<子节点
|
||||
void SetParent(SceneNode *sn) {ParentNode=sn;}
|
||||
SceneNode * GetParent() noexcept{return ParentNode;}
|
||||
const SceneNode * GetParent()const noexcept{return ParentNode;}
|
||||
|
||||
public:
|
||||
void SetRenderable(Mesh *);
|
||||
Mesh * GetRenderable() noexcept{return render_obj;}
|
||||
const Mesh * GetRenderable()const noexcept{return render_obj;}
|
||||
|
||||
const SceneNodeID & GetNodeID ()const { return NodeID; } ///<取得节点ID
|
||||
const SceneNodeName & GetNodeName ()const { return NodeName; } ///<取得节点名称
|
||||
SceneNode *Add(SceneNode *sn)
|
||||
{
|
||||
if(!sn)
|
||||
return(nullptr);
|
||||
|
||||
const ObjectList<SceneNode> &GetChildNode()const { return ChildNode; } ///<取得子节点列表
|
||||
ChildNode.Add(sn);
|
||||
sn->SetParent(this);
|
||||
return sn;
|
||||
}
|
||||
|
||||
public:
|
||||
public: //坐标相关方法
|
||||
|
||||
SceneNode()=default;
|
||||
SceneNode(const SceneNode &)=delete;
|
||||
SceneNode(const SceneNode *)=delete;
|
||||
SceneNode(const SceneOrient &so ):SceneOrient(so) {}
|
||||
SceneNode( Renderable *ri ) {render_obj=ri;}
|
||||
SceneNode(const Matrix4f &mat ):SceneOrient(mat) {}
|
||||
SceneNode(const Matrix4f &mat, Renderable *ri ):SceneOrient(mat) {render_obj=ri;}
|
||||
virtual void SetBoundingBox (const AABB &bb){BoundingBox=bb;} ///<设置绑定盒
|
||||
|
||||
public:
|
||||
virtual void RefreshMatrix () override; ///<刷新世界变换
|
||||
virtual void RefreshBoundingBox (); ///<刷新绑定盒
|
||||
|
||||
virtual ~SceneNode()=default;
|
||||
|
||||
void Clear() override
|
||||
{
|
||||
SceneOrient::Clear();
|
||||
|
||||
Owner=nullptr;
|
||||
|
||||
BoundingBox.SetZero();
|
||||
LocalBoundingBox.SetZero();
|
||||
|
||||
ChildNode.Clear();
|
||||
render_obj=nullptr;
|
||||
}
|
||||
|
||||
const bool IsEmpty()const
|
||||
{
|
||||
if(render_obj)return(false);
|
||||
if(ChildNode.GetCount())return(false);
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
if(!sn)
|
||||
return(nullptr);
|
||||
|
||||
ChildNode.Add(sn);
|
||||
sn->SetOwner(this);
|
||||
return sn;
|
||||
}
|
||||
|
||||
public: //坐标相关方法
|
||||
|
||||
virtual void SetBoundingBox (const AABB &bb){BoundingBox=bb;} ///<设置绑定盒
|
||||
|
||||
virtual void RefreshMatrix () override; ///<刷新世界变换
|
||||
virtual void RefreshBoundingBox (); ///<刷新绑定盒
|
||||
|
||||
virtual const AABB & GetBoundingBox ()const{return BoundingBox;} ///<取得绑定盒
|
||||
virtual const AABB & GetLocalBoundingBox ()const{return LocalBoundingBox;} ///<取得本地坐标绑定盒
|
||||
virtual const AABB & GetBoundingBox ()const{return BoundingBox;} ///<取得绑定盒
|
||||
virtual const AABB & GetLocalBoundingBox ()const{return LocalBoundingBox;} ///<取得本地坐标绑定盒
|
||||
// virtual const AABB & GetWorldBoundingBox ()const{return WorldBoundingBox;} ///<取得世界坐标绑定盒
|
||||
};//class SceneNode
|
||||
|
||||
SceneNode *Duplication(SceneNode *); ///<复制一个场景节点
|
||||
}//namespace graph
|
||||
}//namespace hgl
|
||||
public: //组件相关方法
|
||||
|
||||
bool ComponentIsEmpty ()const {return ComponentList.GetCount()==0;} ///<是否没有组件
|
||||
virtual int GetComponentCount ()const {return ComponentList.GetCount();} ///<取得组件数量
|
||||
virtual void AddComponent (Component *comp) {ComponentList.Add(comp);} ///<添加一个组件
|
||||
virtual void RemoveComponent (Component *comp) {ComponentList.DeleteByValue(comp);} ///<删除一个组件
|
||||
bool Contains (Component *comp) {return ComponentList.Contains(comp);} ///<是否包含指定组件
|
||||
|
||||
bool HasComponent (const ComponentManager *); ///<是否有指定组件管理器的组件
|
||||
virtual int GetComponents (ArrayList<Component *> &comp_list,const ComponentManager *); ///<取得所有组件
|
||||
|
||||
};//class SceneNode
|
||||
|
||||
SceneNode *Duplication(SceneNode *); ///<复制一个场景节点
|
||||
}//namespace hgl::graph
|
||||
|
@@ -2,51 +2,48 @@
|
||||
|
||||
#include<hgl/graph/VK.h>
|
||||
#include<hgl/graph/SceneMatrix.h>
|
||||
namespace hgl
|
||||
namespace hgl::graph
|
||||
{
|
||||
namespace graph
|
||||
/**
|
||||
* 方向定位数据基类<br>
|
||||
*/
|
||||
class SceneOrient ///场景定位类
|
||||
{
|
||||
/**
|
||||
* 方向定位数据基类<br>
|
||||
*/
|
||||
class SceneOrient ///场景定位类
|
||||
protected:
|
||||
|
||||
SceneMatrix scene_matrix;
|
||||
|
||||
public:
|
||||
|
||||
SceneOrient()=default;
|
||||
SceneOrient(const SceneOrient &);
|
||||
SceneOrient(const Matrix4f &);
|
||||
virtual ~SceneOrient()=default;
|
||||
|
||||
virtual void Clear()
|
||||
{
|
||||
protected:
|
||||
scene_matrix.Clear();
|
||||
}
|
||||
|
||||
SceneMatrix scene_matrix;
|
||||
void SetLocalNormal(const Vector3f &nor) {scene_matrix.SetLocalNormal(nor);} ///<设置本地法线
|
||||
void SetLocalMatrix (const Matrix4f &mat){scene_matrix.SetLocalMatrix(mat);} ///<设置本地矩阵
|
||||
void SetParentMatrix(const Matrix4f &mat){scene_matrix.SetParentMatrix(mat);} ///<设置上级到世界空间变换矩阵
|
||||
|
||||
public:
|
||||
public:
|
||||
|
||||
SceneOrient()=default;
|
||||
SceneOrient(const SceneOrient &);
|
||||
SceneOrient(const Matrix4f &);
|
||||
virtual ~SceneOrient()=default;
|
||||
const uint32 GetLocalToWorldMatrixVersion()const {return scene_matrix.GetNewestVersion();} ///<取得版本号
|
||||
|
||||
virtual void Clear()
|
||||
{
|
||||
scene_matrix.Clear();
|
||||
}
|
||||
const Vector3f & GetWorldPosition() const {return scene_matrix.GetWorldPosition();} ///<取得世界坐标
|
||||
const Matrix4f & GetLocalMatrix ()const {return scene_matrix.GetLocalMatrix();} ///<取得本地矩阵
|
||||
|
||||
void SetLocalNormal(const Vector3f &nor) {scene_matrix.SetLocalNormal(nor);} ///<设置本地法线
|
||||
void SetLocalMatrix (const Matrix4f &mat){scene_matrix.SetLocalMatrix(mat);} ///<设置本地矩阵
|
||||
void SetParentMatrix(const Matrix4f &mat){scene_matrix.SetParentMatrix(mat);} ///<设置上级到世界空间变换矩阵
|
||||
TransformManager & GetTransform () {return scene_matrix.GetTransform();} ///<取得变换管理器
|
||||
|
||||
public:
|
||||
const Matrix4f & GetLocalToWorldMatrix () {return scene_matrix.GetLocalToWorldMatrix();} ///<取得本地到世界矩阵
|
||||
const Matrix4f & GetInverseLocalToWorldMatrix () {return scene_matrix.GetInverseLocalToWorldMatrix();}
|
||||
const Matrix4f & GetInverseTransposeLocalToWorldMatrix () {return scene_matrix.GetInverseTransposeLocalToWorldMatrix();}
|
||||
|
||||
const uint32 GetLocalToWorldMatrixVersion()const {return scene_matrix.GetNewestVersion();} ///<取得版本号
|
||||
public:
|
||||
|
||||
const Vector3f & GetWorldPosition() const {return scene_matrix.GetWorldPosition();} ///<取得世界坐标
|
||||
const Matrix4f & GetLocalMatrix ()const {return scene_matrix.GetLocalMatrix();} ///<取得本地矩阵
|
||||
|
||||
TransformManager & GetTransform () {return scene_matrix.GetTransform();} ///<取得变换管理器
|
||||
|
||||
const Matrix4f & GetLocalToWorldMatrix () {return scene_matrix.GetLocalToWorldMatrix();} ///<取得本地到世界矩阵
|
||||
const Matrix4f & GetInverseLocalToWorldMatrix () {return scene_matrix.GetInverseLocalToWorldMatrix();}
|
||||
const Matrix4f & GetInverseTransposeLocalToWorldMatrix () {return scene_matrix.GetInverseTransposeLocalToWorldMatrix();}
|
||||
|
||||
public:
|
||||
|
||||
virtual void RefreshMatrix();
|
||||
};//class SceneOrient
|
||||
}//namespace graph
|
||||
}//namespace hgl
|
||||
virtual void RefreshMatrix();
|
||||
};//class SceneOrient
|
||||
}//namespace hgl::graph
|
||||
|
@@ -1,26 +1,38 @@
|
||||
#pragma once
|
||||
|
||||
#include<hgl/graph/SceneNode.h>
|
||||
|
||||
namespace hgl
|
||||
namespace hgl::graph
|
||||
{
|
||||
namespace graph
|
||||
class CameraData
|
||||
{
|
||||
/**
|
||||
* 场景管理器<Br>
|
||||
* 管理一个场景中的所有资源与场景节点
|
||||
*/
|
||||
class SceneWorld
|
||||
};
|
||||
|
||||
class CameraManager
|
||||
{
|
||||
public:
|
||||
};
|
||||
|
||||
/**
|
||||
* 世界场景管理器<Br>
|
||||
* 管理一个世界场景中的所有资源与场景节点
|
||||
*/
|
||||
class SceneWorld
|
||||
{
|
||||
SceneNode *root_node; ///<世界根节点
|
||||
|
||||
public:
|
||||
|
||||
SceneWorld()
|
||||
{
|
||||
SceneNode *root_node;
|
||||
root_node=new SceneNode;
|
||||
}
|
||||
|
||||
public:
|
||||
virtual ~SceneWorld()
|
||||
{
|
||||
SAFE_CLEAR(root_node);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public:
|
||||
|
||||
|
||||
|
||||
};//class SceneWorld
|
||||
}//namespace graph
|
||||
}//namespace hgl
|
||||
SceneNode *GetRootNode(){return root_node;}
|
||||
};//class SceneWorld
|
||||
}//namespace hgl::graph
|
||||
|
@@ -1,46 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include<hgl/graph/VKNamespace.h>
|
||||
#include<hgl/graph/StaticMeshLODPolicy.h>
|
||||
#include<hgl/graph/ShadowPolicy.h>
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
|
||||
class SceneNode;
|
||||
|
||||
class StaticMesh
|
||||
{
|
||||
protected:
|
||||
|
||||
StaticMeshLODPolicy lod_policy; ///<LOD策略
|
||||
|
||||
SceneNode *root_node;
|
||||
|
||||
StaticMesh *shadow_proxy_static_mesh; ///<阴影代理静态网格
|
||||
StaticMesh *physic_proxy_static_mesh; ///<物理代理静态网格
|
||||
|
||||
protected:
|
||||
|
||||
bool two_side; ///<双面渲染
|
||||
|
||||
ObjectDynamicShadowPolicy recommend_dynamic_shadow_policy; ///<动态阴影策略(推荐项,最终可被取代)
|
||||
|
||||
public:
|
||||
|
||||
const StaticMeshLODPolicy GetLODPolicy()const { return lod_policy; } ///<取得LOD策略
|
||||
const ObjectDynamicShadowPolicy GetRecommendDynamicShadowPolicy()const { return recommend_dynamic_shadow_policy; } ///<取得推荐的动态阴影策略
|
||||
|
||||
public:
|
||||
|
||||
StaticMesh(SceneNode *);
|
||||
virtual ~StaticMesh();
|
||||
|
||||
public:
|
||||
|
||||
SceneNode *GetScene(){return root_node;}
|
||||
|
||||
SceneNode *GetShadowNode() { return shadow_proxy_static_mesh?shadow_proxy_static_mesh->GetScene():root_node; } ///<取得阴影渲染节点
|
||||
SceneNode *GetPhysicNode() { return physic_proxy_static_mesh?physic_proxy_static_mesh->GetScene():root_node; } ///<取得物理渲染节点
|
||||
|
||||
};//class StaticMesh
|
||||
VK_NAMESPACE_END
|
@@ -1,30 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include<hgl/graph/VKNamespace.h>
|
||||
#include<hgl/TypeFunc.h>
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
|
||||
/**
|
||||
* 静态模型LOD策略
|
||||
*/
|
||||
enum class StaticMeshLODPolicy:uint8
|
||||
{
|
||||
None=0, ///<无LOD
|
||||
|
||||
DiscardDetail, ///<丢弃细节
|
||||
|
||||
AnotherMesh, ///<另一个模型
|
||||
|
||||
Billboard, ///<广告牌
|
||||
|
||||
//Voxel, ///<体素
|
||||
|
||||
//MeshSDF, ///<网格SDF
|
||||
|
||||
//MeshCard, ///<网格卡片
|
||||
|
||||
ENUM_CLASS_RANGE(None,Billboard)
|
||||
};//enum class StaticMeshLODPolicy
|
||||
|
||||
VK_NAMESPACE_END
|
@@ -1,25 +0,0 @@
|
||||
#ifndef HGL_GRAPH_STATIC_RENDER_MANAGER_INCLUDE
|
||||
#define HGL_GRAPH_STATIC_RENDER_MANAGER_INCLUDE
|
||||
|
||||
#include<hgl/graph/VK.h>
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
|
||||
class RawMesh
|
||||
{
|
||||
};
|
||||
|
||||
/**
|
||||
* 静态渲染管理器<br>
|
||||
* 静态渲染指的是不会产生资源变动的内容,而不是指不会动的内容。
|
||||
*/
|
||||
class StaticRenderManager
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
virtual ~StaticRenderManager()=default;
|
||||
|
||||
};//class StaticRenderManager
|
||||
VK_NAMESPACE_END
|
||||
#endif//HGL_GRAPH_STATIC_RENDER_MANAGER_INCLUDE
|
@@ -37,7 +37,7 @@ namespace hgl
|
||||
|
||||
DeviceBuffer *tile_buffer; ///<Tile暂存缓冲区
|
||||
|
||||
List<Image2DRegion> commit_list;
|
||||
ArrayList<Image2DRegion> commit_list;
|
||||
uint8 *commit_ptr;
|
||||
|
||||
bool CommitTile(TileObject *,const void *,const uint,const int,const int); ///<提交一个Tile数据
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include<hgl/type/List.h>
|
||||
#include<hgl/type/ArrayList.h>
|
||||
#include<hgl/math/Math.h>
|
||||
#include<hgl/type/String.h>
|
||||
#include<hgl/type/Map.h>
|
||||
@@ -41,9 +41,9 @@ class GraphModule;
|
||||
class RenderFramework;
|
||||
|
||||
class VulkanInstance;
|
||||
class GPUPhysicalDevice;
|
||||
class GPUDevice;
|
||||
struct GPUDeviceAttribute;
|
||||
class VulkanPhyDevice;
|
||||
class VulkanDevice;
|
||||
struct VulkanDevAttr;
|
||||
class DeviceQueue;
|
||||
class ImageView;
|
||||
class Framebuffer;
|
||||
@@ -73,8 +73,8 @@ class DeviceBuffer;
|
||||
struct DeviceBufferData;
|
||||
template<typename T> class DeviceBufferMap;
|
||||
|
||||
struct PrimitiveDataBuffer;
|
||||
struct PrimitiveRenderData;
|
||||
struct MeshDataBuffer;
|
||||
struct MeshRenderData;
|
||||
|
||||
class VertexAttribBuffer;
|
||||
using VAB=VertexAttribBuffer;
|
||||
@@ -84,7 +84,7 @@ class IndexBuffer;
|
||||
class VABMap;
|
||||
class IBMap;
|
||||
|
||||
class GPUCmdBuffer;
|
||||
class VulkanCmdBuffer;
|
||||
class RenderCmdBuffer;
|
||||
class TextureCmdBuffer;
|
||||
|
||||
@@ -123,7 +123,7 @@ using VIL=VertexInputLayout;
|
||||
|
||||
class PrimitiveData;
|
||||
class Primitive;
|
||||
class Renderable;
|
||||
class Mesh;
|
||||
|
||||
class VertexDataManager;
|
||||
using VDM=VertexDataManager;
|
||||
|
@@ -1,5 +1,4 @@
|
||||
#ifndef HGL_GRAPH_VULKAN_ARRAY_BUFFER_INCLUDE
|
||||
#define HGL_GRAPH_VULKAN_ARRAY_BUFFER_INCLUDE
|
||||
#pragma once
|
||||
|
||||
#include<hgl/graph/VK.h>
|
||||
#include<hgl/graph/VKDynamicBufferAccess.h>
|
||||
@@ -15,7 +14,7 @@ namespace hgl
|
||||
* GPU数据阵列缓冲区<br>
|
||||
* 它用于储存多份相同格式的数据,常用于多物件渲染,instance等
|
||||
*/
|
||||
class GPUArrayBuffer
|
||||
class VulkanArrayBuffer
|
||||
{
|
||||
protected:
|
||||
|
||||
@@ -33,13 +32,13 @@ namespace hgl
|
||||
|
||||
private:
|
||||
|
||||
GPUArrayBuffer(VKMemoryAllocator *,const uint,const uint);
|
||||
VulkanArrayBuffer(VKMemoryAllocator *,const uint,const uint);
|
||||
|
||||
friend class GPUDevice;
|
||||
friend class VulkanDevice;
|
||||
|
||||
public:
|
||||
|
||||
virtual ~GPUArrayBuffer();
|
||||
virtual ~VulkanArrayBuffer();
|
||||
|
||||
const uint32_t GetAlignSize()const{return align_size;} ///<数据对齐字节数
|
||||
const uint32_t GetRangeSize()const{return range_size;} ///<单次渲染访问最大字节数
|
||||
@@ -71,7 +70,6 @@ namespace hgl
|
||||
|
||||
dba->Restart();
|
||||
}
|
||||
};//class GPUArrayBuffer
|
||||
};//class VulkanArrayBuffer
|
||||
}//namespace graph
|
||||
}//namespace hgl
|
||||
#endif//HGL_GRAPH_VULKAN_ARRAY_BUFFER_INCLUDE
|
||||
|
@@ -20,7 +20,7 @@ protected:
|
||||
|
||||
private:
|
||||
|
||||
friend class GPUDevice;
|
||||
friend class VulkanDevice;
|
||||
friend class VertexAttribBuffer;
|
||||
friend class IndexBuffer;
|
||||
template<typename T> friend class IndirectCommandBuffer;
|
||||
|
@@ -1,18 +1,17 @@
|
||||
#ifndef HGL_GRAPH_VULKAN_COMMAND_BUFFER_INCLUDE
|
||||
#define HGL_GRAPH_VULKAN_COMMAND_BUFFER_INCLUDE
|
||||
#pragma once
|
||||
|
||||
#include<hgl/graph/VK.h>
|
||||
#include<hgl/graph/VKVABList.h>
|
||||
#include<hgl/graph/VKPipeline.h>
|
||||
#include<hgl/graph/VKDescriptorSet.h>
|
||||
#include<hgl/graph/VKRenderable.h>
|
||||
#include<hgl/graph/Mesh.h>
|
||||
#include<hgl/color/Color4f.h>
|
||||
VK_NAMESPACE_BEGIN
|
||||
class GPUCmdBuffer
|
||||
class VulkanCmdBuffer
|
||||
{
|
||||
protected:
|
||||
|
||||
const GPUDeviceAttribute *dev_attr;
|
||||
const VulkanDevAttr *dev_attr;
|
||||
|
||||
VkCommandBuffer cmd_buf;
|
||||
|
||||
@@ -20,8 +19,8 @@ protected:
|
||||
|
||||
public:
|
||||
|
||||
GPUCmdBuffer(const GPUDeviceAttribute *attr,VkCommandBuffer cb);
|
||||
virtual ~GPUCmdBuffer();
|
||||
VulkanCmdBuffer(const VulkanDevAttr *attr,VkCommandBuffer cb);
|
||||
virtual ~VulkanCmdBuffer();
|
||||
|
||||
operator VkCommandBuffer(){return cmd_buf;}
|
||||
operator const VkCommandBuffer()const{return cmd_buf;}
|
||||
@@ -48,11 +47,11 @@ public:
|
||||
void BeginRegion(const AnsiString &,const Color4f &){}
|
||||
void EndRegion(){}
|
||||
#endif//_DEBUG
|
||||
};//class GPUCmdBuffer
|
||||
};//class VulkanCmdBuffer
|
||||
|
||||
class DescriptorBinding;
|
||||
|
||||
class RenderCmdBuffer:public GPUCmdBuffer
|
||||
class RenderCmdBuffer:public VulkanCmdBuffer
|
||||
{
|
||||
uint32_t cv_count;
|
||||
VkClearValue *clear_values;
|
||||
@@ -70,7 +69,7 @@ private:
|
||||
|
||||
public:
|
||||
|
||||
RenderCmdBuffer(const GPUDeviceAttribute *attr,VkCommandBuffer cb);
|
||||
RenderCmdBuffer(const VulkanDevAttr *attr,VkCommandBuffer cb);
|
||||
~RenderCmdBuffer();
|
||||
|
||||
void SetDescriptorBinding(DescriptorBinding *db) { desc_binding=db; }
|
||||
@@ -79,7 +78,7 @@ public:
|
||||
{
|
||||
desc_binding=nullptr;
|
||||
|
||||
return GPUCmdBuffer::End();
|
||||
return VulkanCmdBuffer::End();
|
||||
}
|
||||
|
||||
void SetRenderArea(const VkRect2D &ra){render_area=ra;}
|
||||
@@ -203,7 +202,7 @@ public:
|
||||
|
||||
void BindIBO(IndexBuffer *,const VkDeviceSize byte_offset=0);
|
||||
|
||||
bool BindDataBuffer(const PrimitiveDataBuffer *);
|
||||
bool BindDataBuffer(const MeshDataBuffer *);
|
||||
|
||||
void SetViewport (uint32_t first,uint32_t count,const VkViewport *vp) {vkCmdSetViewport(cmd_buf,first,count,vp);}
|
||||
void SetScissor (uint32_t first,uint32_t count,const VkRect2D *sci) {vkCmdSetScissor(cmd_buf,first,count,sci);}
|
||||
@@ -240,13 +239,13 @@ public: //draw
|
||||
void DrawIndirect (VkBuffer buf, uint32_t drawCount,uint32_t stride=sizeof(VkDrawIndirectCommand )){return DrawIndirect( buf,0,drawCount,stride);}
|
||||
void DrawIndexedIndirect(VkBuffer buf, uint32_t drawCount,uint32_t stride=sizeof(VkDrawIndexedIndirectCommand )){return DrawIndexedIndirect( buf,0,drawCount,stride);}
|
||||
|
||||
void Draw (const PrimitiveDataBuffer *prb,const PrimitiveRenderData *prd,const uint32_t instance_count=1,const uint32_t first_instance=0);
|
||||
void Draw (const MeshDataBuffer *prb,const MeshRenderData *prd,const uint32_t instance_count=1,const uint32_t first_instance=0);
|
||||
|
||||
public: //dynamic state
|
||||
|
||||
public:
|
||||
|
||||
void Render(Renderable *ri)
|
||||
void Render(Mesh *ri)
|
||||
{
|
||||
if(!ri)return;
|
||||
|
||||
@@ -256,15 +255,15 @@ public:
|
||||
|
||||
Draw(ri->GetDataBuffer(),ri->GetRenderData());
|
||||
}
|
||||
};//class RenderCmdBuffer:public GPUCmdBuffer
|
||||
};//class RenderCmdBuffer:public VulkanCmdBuffer
|
||||
|
||||
class TextureCmdBuffer:public GPUCmdBuffer
|
||||
class TextureCmdBuffer:public VulkanCmdBuffer
|
||||
{
|
||||
VkImageMemoryBarrier imageMemoryBarrier;
|
||||
|
||||
public:
|
||||
|
||||
TextureCmdBuffer(const GPUDeviceAttribute *attr,VkCommandBuffer cb):GPUCmdBuffer(attr,cb)
|
||||
TextureCmdBuffer(const VulkanDevAttr *attr,VkCommandBuffer cb):VulkanCmdBuffer(attr,cb)
|
||||
{
|
||||
imageMemoryBarrier.sType=VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER;
|
||||
imageMemoryBarrier.pNext=nullptr;
|
||||
@@ -301,6 +300,5 @@ public:
|
||||
0, nullptr,
|
||||
1, &imageMemoryBarrier);
|
||||
}
|
||||
};//class TextureCmdBuffer:public GPUCmdBuffer
|
||||
};//class TextureCmdBuffer:public VulkanCmdBuffer
|
||||
VK_NAMESPACE_END
|
||||
#endif//HGL_GRAPH_VULKAN_COMMAND_BUFFER_INCLUDE
|
||||
|
@@ -18,7 +18,7 @@ class DescriptorSet
|
||||
|
||||
ObjectList<VkDescriptorBufferInfo> vab_list;
|
||||
ObjectList<VkDescriptorImageInfo> image_list;
|
||||
List<VkWriteDescriptorSet> wds_list;
|
||||
ArrayList<VkWriteDescriptorSet> wds_list;
|
||||
|
||||
SortedSet<uint32_t> binded_sets;
|
||||
|
||||
|
@@ -1,7 +1,6 @@
|
||||
#ifndef HGL_GRAPH_VULKAN_DEVICE_INCLUDE
|
||||
#define HGL_GRAPH_VULKAN_DEVICE_INCLUDE
|
||||
#pragma once
|
||||
|
||||
#include<hgl/type/List.h>
|
||||
#include<hgl/type/ArrayList.h>
|
||||
#include<hgl/type/String.h>
|
||||
#include<hgl/type/Map.h>
|
||||
#include<hgl/type/RectScope.h>
|
||||
@@ -21,16 +20,16 @@ VK_NAMESPACE_BEGIN
|
||||
class TileData;
|
||||
class TileFont;
|
||||
class FontSource;
|
||||
class GPUArrayBuffer;
|
||||
class VulkanArrayBuffer;
|
||||
class IndirectDrawBuffer;
|
||||
class IndirectDrawIndexedBuffer;
|
||||
class IndirectDispatchBuffer;
|
||||
|
||||
struct CopyBufferToImageInfo;
|
||||
|
||||
class GPUDevice
|
||||
class VulkanDevice
|
||||
{
|
||||
GPUDeviceAttribute *attr;
|
||||
VulkanDevAttr *attr;
|
||||
|
||||
private:
|
||||
|
||||
@@ -40,18 +39,18 @@ private:
|
||||
|
||||
friend class VulkanDeviceCreater;
|
||||
|
||||
GPUDevice(GPUDeviceAttribute *da);
|
||||
VulkanDevice(VulkanDevAttr *da);
|
||||
|
||||
public:
|
||||
|
||||
virtual ~GPUDevice();
|
||||
virtual ~VulkanDevice();
|
||||
|
||||
operator VkDevice () {return attr->device;}
|
||||
GPUDeviceAttribute *GetDeviceAttribute () {return attr;}
|
||||
VulkanDevAttr * GetDevAttr () {return attr;}
|
||||
|
||||
VkSurfaceKHR GetSurface () {return attr->surface;}
|
||||
VkDevice GetDevice ()const {return attr->device;}
|
||||
const GPUPhysicalDevice * GetPhysicalDevice ()const {return attr->physical_device;}
|
||||
const VulkanPhyDevice * GetPhyDevice ()const {return attr->physical_device;}
|
||||
|
||||
VkDescriptorPool GetDescriptorPool () {return attr->desc_pool;}
|
||||
VkPipelineCache GetPipelineCache () {return attr->pipeline_cache;}
|
||||
@@ -132,8 +131,8 @@ public: //Buffer相关
|
||||
|
||||
#undef CREATE_BUFFER_OBJECT
|
||||
|
||||
GPUArrayBuffer *CreateArrayInUBO(const VkDeviceSize &uint_size);
|
||||
GPUArrayBuffer *CreateArrayInSSBO(const VkDeviceSize &uint_size);
|
||||
VulkanArrayBuffer *CreateArrayInUBO(const VkDeviceSize &uint_size);
|
||||
VulkanArrayBuffer *CreateArrayInSSBO(const VkDeviceSize &uint_size);
|
||||
|
||||
public: //间接绘制
|
||||
|
||||
@@ -173,6 +172,5 @@ public:
|
||||
TileData *CreateTileData(const VkFormat video_format,const uint width,const uint height,const uint count); ///<创建一个Tile数据集
|
||||
|
||||
TileFont *CreateTileFont(FontSource *fs,int limit_count=-1); ///<创建一个Tile字体
|
||||
};//class GPUDevice
|
||||
};//class VulkanDevice
|
||||
VK_NAMESPACE_END
|
||||
#endif//HGL_GRAPH_VULKAN_DEVICE_INCLUDE
|
||||
|
@@ -11,10 +11,10 @@ VK_NAMESPACE_BEGIN
|
||||
|
||||
constexpr uint32_t ERROR_FAMILY_INDEX=UINT32_MAX;
|
||||
|
||||
struct GPUDeviceAttribute
|
||||
struct VulkanDevAttr
|
||||
{
|
||||
VulkanInstance * instance =nullptr;
|
||||
const GPUPhysicalDevice * physical_device =nullptr;
|
||||
const VulkanPhyDevice * physical_device =nullptr;
|
||||
|
||||
VkPhysicalDeviceDriverPropertiesKHR driver_properties;
|
||||
|
||||
@@ -34,7 +34,7 @@ struct GPUDeviceAttribute
|
||||
VkQueue present_queue =VK_NULL_HANDLE;
|
||||
|
||||
VkSurfaceFormatKHR surface_format;
|
||||
List<VkPresentModeKHR> present_modes;
|
||||
ArrayList<VkPresentModeKHR> present_modes;
|
||||
|
||||
VkSurfaceTransformFlagBitsKHR preTransform;
|
||||
VkCompositeAlphaFlagBitsKHR compositeAlpha =VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR;
|
||||
@@ -55,8 +55,8 @@ struct GPUDeviceAttribute
|
||||
|
||||
public:
|
||||
|
||||
GPUDeviceAttribute(VulkanInstance *inst,const GPUPhysicalDevice *pd,VkSurfaceKHR s);
|
||||
~GPUDeviceAttribute();
|
||||
VulkanDevAttr(VulkanInstance *inst,const VulkanPhyDevice *pd,VkSurfaceKHR s);
|
||||
~VulkanDevAttr();
|
||||
|
||||
int GetMemoryType(uint32_t typeBits,VkMemoryPropertyFlags properties) const;
|
||||
|
||||
@@ -75,5 +75,5 @@ public:
|
||||
{
|
||||
return instance->GetDeviceProc<T>(device,name);
|
||||
}
|
||||
};//class GPUDeviceAttribute
|
||||
};//class VulkanDevAttr
|
||||
VK_NAMESPACE_END
|
||||
|
@@ -238,7 +238,7 @@ protected:
|
||||
|
||||
VulkanInstance *instance;
|
||||
Window *window;
|
||||
const GPUPhysicalDevice *physical_device;
|
||||
const VulkanPhyDevice *physical_device;
|
||||
|
||||
VulkanHardwareRequirement require;
|
||||
|
||||
@@ -274,14 +274,14 @@ public:
|
||||
|
||||
virtual void ChooseSurfaceFormat();
|
||||
|
||||
virtual GPUDevice *CreateRenderDevice();
|
||||
virtual VulkanDevice *CreateRenderDevice();
|
||||
|
||||
public:
|
||||
|
||||
virtual GPUDevice *Create();
|
||||
virtual VulkanDevice *Create();
|
||||
};//class VulkanDeviceCreater
|
||||
|
||||
inline GPUDevice *CreateRenderDevice( VulkanInstance *vi,
|
||||
inline VulkanDevice *CreateRenderDevice( VulkanInstance *vi,
|
||||
Window *win,
|
||||
const VulkanHardwareRequirement *req=nullptr,
|
||||
const PreferFormats * spf_color =&PreferSDR,
|
||||
@@ -293,35 +293,35 @@ inline GPUDevice *CreateRenderDevice( VulkanInstance *vi,
|
||||
return vdc.Create();
|
||||
}
|
||||
|
||||
inline GPUDevice *CreateRenderDeviceLDR(VulkanInstance *vi,
|
||||
inline VulkanDevice *CreateRenderDeviceLDR(VulkanInstance *vi,
|
||||
Window *win,
|
||||
const VulkanHardwareRequirement *req=nullptr)
|
||||
{
|
||||
return CreateRenderDevice(vi,win,req,&PreferLDR,&PreferNonlinear,&PreferDepth);
|
||||
}
|
||||
|
||||
inline GPUDevice *CreateRenderDeviceSDR(VulkanInstance *vi,
|
||||
inline VulkanDevice *CreateRenderDeviceSDR(VulkanInstance *vi,
|
||||
Window *win,
|
||||
const VulkanHardwareRequirement *req=nullptr)
|
||||
{
|
||||
return CreateRenderDevice(vi,win,req,&PreferSDR,&PreferNonlinear,&PreferDepth);
|
||||
}
|
||||
|
||||
inline GPUDevice *CreateRenderDeviceHDR16( VulkanInstance *vi,
|
||||
inline VulkanDevice *CreateRenderDeviceHDR16( VulkanInstance *vi,
|
||||
Window *win,
|
||||
const VulkanHardwareRequirement *req=nullptr)
|
||||
{
|
||||
return CreateRenderDevice(vi,win,req,&PreferHDR16,&PreferLinear,&PreferDepth);
|
||||
}
|
||||
|
||||
inline GPUDevice *CreateRenderDeviceHDR32( VulkanInstance *vi,
|
||||
inline VulkanDevice *CreateRenderDeviceHDR32( VulkanInstance *vi,
|
||||
Window *win,
|
||||
const VulkanHardwareRequirement *req=nullptr)
|
||||
{
|
||||
return CreateRenderDevice(vi,win,req,&PreferHDR32,&PreferLinear,&PreferDepth);
|
||||
}
|
||||
|
||||
inline GPUDevice *CreateRenderDeviceHDR(VulkanInstance *vi,
|
||||
inline VulkanDevice *CreateRenderDeviceHDR(VulkanInstance *vi,
|
||||
Window *win,
|
||||
const VulkanHardwareRequirement *req=nullptr)
|
||||
{
|
||||
|
@@ -37,7 +37,7 @@ private:
|
||||
index=0;
|
||||
}
|
||||
|
||||
friend class GPUArrayBuffer;
|
||||
friend class VulkanArrayBuffer;
|
||||
|
||||
public:
|
||||
|
||||
|
@@ -10,7 +10,7 @@ class Fence
|
||||
|
||||
private:
|
||||
|
||||
friend class GPUDevice;
|
||||
friend class VulkanDevice;
|
||||
|
||||
Fence(VkDevice d,VkFence f)
|
||||
{
|
||||
|
@@ -12,7 +12,7 @@ class IndexBuffer:public DeviceBuffer
|
||||
|
||||
private:
|
||||
|
||||
friend class GPUDevice;
|
||||
friend class VulkanDevice;
|
||||
|
||||
IndexBuffer(VkDevice d,const DeviceBufferData &vb,IndexType it,uint32_t _count):DeviceBuffer(d,vb)
|
||||
{
|
||||
|
@@ -19,7 +19,7 @@ public:
|
||||
|
||||
private:
|
||||
|
||||
friend class GPUDevice;
|
||||
friend class VulkanDevice;
|
||||
|
||||
IndirectCommandBuffer(VkDevice d,const DeviceBufferData &vb,const uint32_t mc):DeviceBuffer(d,vb)
|
||||
{
|
||||
@@ -46,7 +46,7 @@ public:
|
||||
|
||||
class IndirectDrawBuffer:public IndirectCommandBuffer<VkDrawIndirectCommand>
|
||||
{
|
||||
friend class GPUDevice;
|
||||
friend class VulkanDevice;
|
||||
|
||||
public:
|
||||
|
||||
@@ -64,7 +64,7 @@ public:
|
||||
|
||||
class IndirectDrawIndexedBuffer:public IndirectCommandBuffer<VkDrawIndexedIndirectCommand>
|
||||
{
|
||||
friend class GPUDevice;
|
||||
friend class VulkanDevice;
|
||||
|
||||
public:
|
||||
|
||||
@@ -82,7 +82,7 @@ public:
|
||||
|
||||
class IndirectDispatchBuffer:public IndirectCommandBuffer<VkDispatchIndirectCommand>
|
||||
{
|
||||
friend class GPUDevice;
|
||||
friend class VulkanDevice;
|
||||
|
||||
public:
|
||||
|
||||
|
@@ -62,7 +62,7 @@ VK_NAMESPACE_BEGIN
|
||||
|
||||
VKDebugOut *debug_out;
|
||||
|
||||
ObjectList<GPUPhysicalDevice> physical_devices;
|
||||
ObjectList<VulkanPhyDevice> physical_devices;
|
||||
|
||||
private:
|
||||
|
||||
@@ -80,8 +80,8 @@ VK_NAMESPACE_BEGIN
|
||||
|
||||
operator VkInstance (){return inst;}
|
||||
|
||||
const ObjectList<GPUPhysicalDevice> &GetDeviceList ()const {return physical_devices;}
|
||||
const GPUPhysicalDevice * GetDevice (VkPhysicalDeviceType)const;
|
||||
const ObjectList<VulkanPhyDevice> &GetDeviceList ()const {return physical_devices;}
|
||||
const VulkanPhyDevice * GetDevice (VkPhysicalDeviceType)const;
|
||||
|
||||
template<typename T>
|
||||
T *GetInstanceProc(const char *name)
|
||||
@@ -101,8 +101,8 @@ VK_NAMESPACE_BEGIN
|
||||
};//class VulkanInstance
|
||||
|
||||
void InitVulkanInstanceProperties();
|
||||
const List<VkLayerProperties> & GetInstanceLayerProperties();
|
||||
const List<VkExtensionProperties> & GetInstanceExtensionProperties();
|
||||
const ArrayList<VkLayerProperties> & GetInstanceLayerProperties();
|
||||
const ArrayList<VkExtensionProperties> & GetInstanceExtensionProperties();
|
||||
const bool CheckInstanceLayerSupport(const AnsiString &);
|
||||
const bool GetInstanceLayerVersion(const AnsiString &,uint32_t &spec,uint32_t &impl);
|
||||
const bool CheckInstanceExtensionSupport(const AnsiString &);
|
||||
|
@@ -11,8 +11,10 @@ namespace hgl
|
||||
{
|
||||
class ActiveMemoryBlockManager;
|
||||
}
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
using ShaderStageCreateInfoList=List<VkPipelineShaderStageCreateInfo>;
|
||||
|
||||
using ShaderStageCreateInfoList=ArrayList<VkPipelineShaderStageCreateInfo>;
|
||||
|
||||
/**
|
||||
* 材质类<br>
|
||||
|
@@ -16,7 +16,7 @@ class DeviceMemory
|
||||
|
||||
private:
|
||||
|
||||
friend class GPUDevice;
|
||||
friend class VulkanDevice;
|
||||
|
||||
DeviceMemory(VkDevice dev,VkDeviceMemory dm,const VkMemoryRequirements &mr,const uint32 i,const uint32_t p,const VkDeviceSize cas);
|
||||
|
||||
|
@@ -7,7 +7,7 @@
|
||||
VK_NAMESPACE_BEGIN
|
||||
class VKMemoryAllocator:public AbstractMemoryAllocator
|
||||
{
|
||||
GPUDevice *device;
|
||||
VulkanDevice *device;
|
||||
|
||||
uint32_t buffer_usage_flag_bits;
|
||||
|
||||
@@ -29,7 +29,7 @@ public:
|
||||
|
||||
public:
|
||||
|
||||
VKMemoryAllocator(GPUDevice *,const uint32_t flags,const VkDeviceSize r);
|
||||
VKMemoryAllocator(VulkanDevice *,const uint32_t flags,const VkDeviceSize r);
|
||||
~VKMemoryAllocator();
|
||||
|
||||
void Free() override {/* DON'T RUN ANY OPERATION.*/}
|
||||
|
@@ -5,7 +5,7 @@
|
||||
#include<hgl/type/SortedSet.h>
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
class GPUPhysicalDevice
|
||||
class VulkanPhyDevice
|
||||
{
|
||||
VkInstance instance=nullptr;
|
||||
VkPhysicalDevice physical_device=nullptr;
|
||||
@@ -23,9 +23,10 @@ class GPUPhysicalDevice
|
||||
VkPhysicalDeviceVulkan14Properties properties14;
|
||||
|
||||
VkPhysicalDeviceMemoryProperties memory_properties;
|
||||
List<VkLayerProperties> layer_properties;
|
||||
List<VkExtensionProperties> extension_properties;
|
||||
List<VkQueueFamilyProperties> queue_family_properties;
|
||||
|
||||
ArrayList<VkLayerProperties> layer_properties;
|
||||
ArrayList<VkExtensionProperties> extension_properties;
|
||||
ArrayList<VkQueueFamilyProperties> queue_family_properties;
|
||||
|
||||
private:
|
||||
|
||||
@@ -46,8 +47,8 @@ public:
|
||||
|
||||
public:
|
||||
|
||||
GPUPhysicalDevice(VkInstance,VkPhysicalDevice);
|
||||
~GPUPhysicalDevice()=default;
|
||||
VulkanPhyDevice(VkInstance,VkPhysicalDevice);
|
||||
~VulkanPhyDevice()=default;
|
||||
|
||||
operator VkPhysicalDevice() {return physical_device;}
|
||||
operator const VkPhysicalDevice()const {return physical_device;}
|
||||
@@ -207,5 +208,5 @@ public:
|
||||
}
|
||||
|
||||
const bool SupportDynamicState() const {return dynamic_state;}
|
||||
};//class GPUPhysicalDevice
|
||||
};//class VulkanPhyDevice
|
||||
VK_NAMESPACE_END
|
||||
|
@@ -33,7 +33,7 @@ public:
|
||||
const AnsiString & GetName ()const{ return prim_name; }
|
||||
|
||||
const VkDeviceSize GetVertexCount ()const;
|
||||
const int GetVABCount ()const;
|
||||
const uint32_t GetVABCount ()const;
|
||||
const int GetVABIndex (const AnsiString &name)const;
|
||||
VAB * GetVAB (const int);
|
||||
VAB * GetVAB (const AnsiString &name){return GetVAB(GetVABIndex(name));}
|
||||
|
@@ -19,7 +19,7 @@ protected:
|
||||
|
||||
private:
|
||||
|
||||
friend class GPUDevice;
|
||||
friend class VulkanDevice;
|
||||
|
||||
DeviceQueue(VkDevice dev,VkQueue q,Fence **,const uint32_t fc);
|
||||
|
||||
@@ -42,7 +42,7 @@ public:
|
||||
bool WaitFence(const bool wait_all=true,const uint64_t time_out=HGL_NANO_SEC_PER_SEC);
|
||||
|
||||
bool Submit(const VkCommandBuffer *cmd_buf,const uint32_t count,Semaphore *wait_sem,Semaphore *complete_sem);
|
||||
bool Submit(GPUCmdBuffer *cmd_buf,Semaphore *wait_sem,Semaphore *complete_sem);
|
||||
bool Submit(VulkanCmdBuffer *cmd_buf,Semaphore *wait_sem,Semaphore *complete_sem);
|
||||
};//class DeviceQueue
|
||||
VK_NAMESPACE_END
|
||||
#endif//HGL_GRAPH_VULKAN_SUBMIT_QUEUE_INCLUDE
|
||||
|
@@ -11,13 +11,13 @@ class RenderContext
|
||||
{
|
||||
protected:
|
||||
|
||||
GPUDevice *device;
|
||||
VulkanDevice *device;
|
||||
|
||||
VkExtent2D extent;
|
||||
|
||||
public:
|
||||
|
||||
RenderContext(GPUDevice *,const VkExtent2D &);
|
||||
RenderContext(VulkanDevice *,const VkExtent2D &);
|
||||
virtual ~RenderContext();
|
||||
|
||||
void Prepare(
|
||||
|
@@ -16,7 +16,7 @@ class RenderPass
|
||||
VkPipelineCache pipeline_cache;
|
||||
VkRenderPass render_pass;
|
||||
|
||||
List<VkFormat> color_formats;
|
||||
ArrayList<VkFormat> color_formats;
|
||||
VkFormat depth_format;
|
||||
|
||||
VkExtent2D granularity;
|
||||
@@ -31,7 +31,7 @@ private:
|
||||
|
||||
friend class RenderPassManager;
|
||||
|
||||
RenderPass(VkDevice d,VkPipelineCache pc,VkRenderPass rp,const List<VkFormat> &cf,VkFormat df);
|
||||
RenderPass(VkDevice d,VkPipelineCache pc,VkRenderPass rp,const ArrayList<VkFormat> &cf,VkFormat df);
|
||||
|
||||
public:
|
||||
|
||||
@@ -43,7 +43,7 @@ public:
|
||||
const VkPipelineCache GetPipelineCache()const{return pipeline_cache;}
|
||||
|
||||
const uint GetColorCount()const{return color_formats.GetCount();}
|
||||
const List<VkFormat> & GetColorFormat()const{return color_formats;}
|
||||
const ArrayList<VkFormat> & GetColorFormat()const{return color_formats;}
|
||||
const VkFormat GetColorFormat(int index)const
|
||||
{
|
||||
if(index<0||index>=color_formats.GetCount())return VK_FORMAT_UNDEFINED;
|
||||
@@ -56,15 +56,15 @@ public:
|
||||
|
||||
public:
|
||||
|
||||
Pipeline *CreatePipeline(Material *,const VIL *,const PipelineData *, const Prim &,const bool prim_restart=false);
|
||||
Pipeline *CreatePipeline(Material *,const VIL *,const InlinePipeline &, const Prim &,const bool prim_restart=false);
|
||||
Pipeline *CreatePipeline(Material *,const VIL *,const PipelineData *, const PrimitiveType &,const bool prim_restart=false);
|
||||
Pipeline *CreatePipeline(Material *,const VIL *,const InlinePipeline &, const PrimitiveType &,const bool prim_restart=false);
|
||||
|
||||
Pipeline *CreatePipeline(Material *mtl, const PipelineData *, const Prim &,const bool prim_restart=false);
|
||||
Pipeline *CreatePipeline(Material *mtl, const InlinePipeline &, const Prim &,const bool prim_restart=false);
|
||||
Pipeline *CreatePipeline(Material *mtl, const PipelineData *, const PrimitiveType &,const bool prim_restart=false);
|
||||
Pipeline *CreatePipeline(Material *mtl, const InlinePipeline &, const PrimitiveType &,const bool prim_restart=false);
|
||||
|
||||
Pipeline *CreatePipeline(MaterialInstance *, const InlinePipeline &, const Prim &,const bool prim_restart=false);
|
||||
Pipeline *CreatePipeline(MaterialInstance *, const PipelineData *, const Prim &,const bool prim_restart=false);
|
||||
Pipeline *CreatePipeline(MaterialInstance *, const OSString &, const Prim &,const bool prim_restart=false);
|
||||
Pipeline *CreatePipeline(MaterialInstance *, const InlinePipeline &, const PrimitiveType &,const bool prim_restart=false);
|
||||
Pipeline *CreatePipeline(MaterialInstance *, const PipelineData *, const PrimitiveType &,const bool prim_restart=false);
|
||||
Pipeline *CreatePipeline(MaterialInstance *, const OSString &, const PrimitiveType &,const bool prim_restart=false);
|
||||
};//class RenderPass
|
||||
VK_NAMESPACE_END
|
||||
#endif//HGL_GRAPH_VULKAN_RENDER_PASS_INCLUDE
|
||||
|
@@ -11,9 +11,8 @@
|
||||
#include<hgl/graph/VKTexture.h>
|
||||
#include<hgl/graph/VKMaterialParameters.h>
|
||||
#include<hgl/graph/VKMaterialInstance.h>
|
||||
#include<hgl/graph/VKRenderable.h>
|
||||
#include<hgl/graph/Mesh.h>
|
||||
#include<hgl/graph/font/TextPrimitive.h>
|
||||
#include<hgl/graph/StaticMesh.h>
|
||||
#include<hgl/type/ObjectManage.h>
|
||||
#include<hgl/shadergen/MaterialCreateInfo.h>
|
||||
#include<hgl/graph/VKDescriptorBindingManage.h>
|
||||
@@ -44,7 +43,7 @@ constexpr const size_t VK_SHADER_STAGE_TYPE_COUNT=20;//GetBitOffset((uint32_t)VK
|
||||
*/
|
||||
class RenderResource
|
||||
{
|
||||
GPUDevice *device;
|
||||
VulkanDevice *device;
|
||||
|
||||
ShaderModuleMapByName shader_module_by_name[VK_SHADER_STAGE_TYPE_COUNT];
|
||||
Map<AnsiString,Material *> material_by_name;
|
||||
@@ -55,9 +54,7 @@ class RenderResource
|
||||
IDObjectManage<PrimitiveID, Primitive> rm_primitives; ///<图元合集
|
||||
IDObjectManage<BufferID, DeviceBuffer> rm_buffers; ///<顶点缓冲区合集
|
||||
IDObjectManage<SamplerID, Sampler> rm_samplers; ///<采样器合集
|
||||
IDObjectManage<RenderableID, Renderable> rm_renderables; ///<渲染实例集合集
|
||||
|
||||
IDObjectManage<StaticMeshID, StaticMesh> rm_static_mesh; ///<静态网格合集
|
||||
IDObjectManage<RenderableID, Mesh> rm_renderables; ///<渲染实例集合集
|
||||
|
||||
private:
|
||||
|
||||
@@ -78,7 +75,7 @@ private:
|
||||
|
||||
public:
|
||||
|
||||
GPUDevice *GetDevice(){return device;}
|
||||
VulkanDevice *GetDevice(){return device;}
|
||||
|
||||
//注:并非一定要走这里,这里只是提供一个注册和自动绑定的机制
|
||||
DescriptorBinding static_descriptor; ///<静态属性描述符绑定管理
|
||||
@@ -86,7 +83,7 @@ public:
|
||||
|
||||
public:
|
||||
|
||||
RenderResource(GPUDevice *dev):device(dev),
|
||||
RenderResource(VulkanDevice *dev):device(dev),
|
||||
static_descriptor(DescriptorSetType::Static),
|
||||
global_descriptor(DescriptorSetType::Global)
|
||||
{}
|
||||
@@ -100,8 +97,7 @@ public: //添加数据到管理器(如果指针为nullptr会返回-1)
|
||||
PrimitiveID Add(Primitive * p ){return rm_primitives.Add(p);}
|
||||
BufferID Add(DeviceBuffer * buf ){return rm_buffers.Add(buf);}
|
||||
SamplerID Add(Sampler * s ){return rm_samplers.Add(s);}
|
||||
RenderableID Add(Renderable * r ){return rm_renderables.Add(r);}
|
||||
StaticMeshID Add(StaticMesh * sm ){return rm_static_mesh.Add(sm);}
|
||||
RenderableID Add(Mesh * r ){return rm_renderables.Add(r);}
|
||||
|
||||
public: // VAB/VAO
|
||||
|
||||
@@ -131,9 +127,9 @@ public: //Material
|
||||
|
||||
const ShaderModule *CreateShaderModule(const AnsiString &shader_module_name,const ShaderCreateInfo *);
|
||||
|
||||
Material * CreateMaterial(const mtl::MaterialCreateInfo *);
|
||||
Material * LoadMaterial(const AnsiString &,mtl::Material2DCreateConfig *);
|
||||
Material * LoadMaterial(const AnsiString &,mtl::Material3DCreateConfig *);
|
||||
Material * CreateMaterial (const AnsiString &,const mtl::MaterialCreateInfo *);
|
||||
Material * LoadMaterial (const AnsiString &,mtl::Material2DCreateConfig *);
|
||||
Material * LoadMaterial (const AnsiString &,mtl::Material3DCreateConfig *);
|
||||
|
||||
MaterialInstance * CreateMaterialInstance(Material *,const VILConfig *vil_cfg=nullptr);
|
||||
|
||||
@@ -145,37 +141,33 @@ public: //Material
|
||||
return CreateMaterialInstance(mtl,vil_cfg,data,sizeof(T));
|
||||
}
|
||||
|
||||
MaterialInstance * CreateMaterialInstance(const mtl::MaterialCreateInfo *,const VILConfig *vil_cfg=nullptr);
|
||||
MaterialInstance * CreateMaterialInstance(const AnsiString &mtl_name,const mtl::MaterialCreateInfo *,const VILConfig *vil_cfg=nullptr);
|
||||
|
||||
Renderable * CreateRenderable(Primitive *r,MaterialInstance *mi,Pipeline *p);
|
||||
Renderable * CreateRenderable(PrimitiveCreater *pc,MaterialInstance *mi,Pipeline *p);
|
||||
Mesh * CreateMesh(Primitive *r,MaterialInstance *mi,Pipeline *p);
|
||||
Mesh * CreateMesh(PrimitiveCreater *pc,MaterialInstance *mi,Pipeline *p);
|
||||
|
||||
Sampler * CreateSampler(VkSamplerCreateInfo *sci=nullptr);
|
||||
Sampler * CreateSampler(Texture *);
|
||||
|
||||
public: //Get
|
||||
|
||||
Material * GetMaterial (const MaterialID &id){return rm_material.Get(id);}
|
||||
MaterialInstance * GetMaterialInstance (const MaterialInstanceID &id){return rm_material_instance.Get(id);}
|
||||
DescriptorSet * GetDescSets (const DescriptorSetID &id){return rm_desc_sets.Get(id);}
|
||||
Primitive * GetPrimitive (const PrimitiveID &id){return rm_primitives.Get(id);}
|
||||
DeviceBuffer * GetBuffer (const BufferID &id){return rm_buffers.Get(id);}
|
||||
Sampler * GetSampler (const SamplerID &id){return rm_samplers.Get(id);}
|
||||
Renderable * GetRenderable (const RenderableID &id){return rm_renderables.Get(id);}
|
||||
|
||||
StaticMesh * GetStaticMesh (const StaticMeshID &id){return rm_static_mesh.Get(id);}
|
||||
Material * GetMaterial (const MaterialID &id){return rm_material.Get(id);}
|
||||
MaterialInstance * GetMaterialInstance (const MaterialInstanceID &id){return rm_material_instance.Get(id);}
|
||||
DescriptorSet * GetDescSets (const DescriptorSetID &id){return rm_desc_sets.Get(id);}
|
||||
Primitive * GetPrimitive (const PrimitiveID &id){return rm_primitives.Get(id);}
|
||||
DeviceBuffer * GetBuffer (const BufferID &id){return rm_buffers.Get(id);}
|
||||
Sampler * GetSampler (const SamplerID &id){return rm_samplers.Get(id);}
|
||||
Mesh * GetRenderable (const RenderableID &id){return rm_renderables.Get(id);}
|
||||
|
||||
public: //Release
|
||||
|
||||
void Release(Material * mtl ){rm_material.Release(mtl);}
|
||||
void Release(MaterialInstance * mi ){rm_material_instance.Release(mi);}
|
||||
void Release(DescriptorSet * ds ){rm_desc_sets.Release(ds);}
|
||||
void Release(Primitive * p ){rm_primitives.Release(p);}
|
||||
void Release(DeviceBuffer * buf ){rm_buffers.Release(buf);}
|
||||
void Release(Sampler * s ){rm_samplers.Release(s);}
|
||||
void Release(Renderable * r ){rm_renderables.Release(r);}
|
||||
|
||||
void Release(StaticMesh * sm ){rm_static_mesh.Release(sm);}
|
||||
void Release(Material * mtl ){rm_material.Release(mtl);}
|
||||
void Release(MaterialInstance * mi ){rm_material_instance.Release(mi);}
|
||||
void Release(DescriptorSet * ds ){rm_desc_sets.Release(ds);}
|
||||
void Release(Primitive * p ){rm_primitives.Release(p);}
|
||||
void Release(DeviceBuffer * buf ){rm_buffers.Release(buf);}
|
||||
void Release(Sampler * s ){rm_samplers.Release(s);}
|
||||
void Release(Mesh * r ){rm_renderables.Release(r);}
|
||||
};//class RenderResource
|
||||
|
||||
/**
|
||||
|
@@ -29,7 +29,7 @@ class IRenderTarget
|
||||
public:
|
||||
|
||||
RenderFramework * GetRenderFramework ()const{return render_framework;}
|
||||
GPUDevice * GetDevice ()const;
|
||||
VulkanDevice * GetDevice ()const;
|
||||
VkDevice GetVkDevice ()const;
|
||||
DescriptorBinding * GetDescriptorBinding(){return &desc_binding;}
|
||||
|
||||
|
@@ -12,7 +12,7 @@ class Sampler
|
||||
|
||||
protected:
|
||||
|
||||
friend class GPUDevice;
|
||||
friend class VulkanDevice;
|
||||
|
||||
Sampler(VkDevice dev,VkSampler s)
|
||||
{
|
||||
|
@@ -10,7 +10,7 @@ class Semaphore
|
||||
|
||||
private:
|
||||
|
||||
friend class GPUDevice;
|
||||
friend class VulkanDevice;
|
||||
|
||||
Semaphore(VkDevice d,VkSemaphore s)
|
||||
{
|
||||
|
@@ -9,7 +9,7 @@ class VkTextureLoader:public L
|
||||
{
|
||||
protected:
|
||||
|
||||
GPUDevice *device;
|
||||
VulkanDevice *device;
|
||||
GPUBuffer *buf;
|
||||
|
||||
T *tex;
|
||||
@@ -18,7 +18,7 @@ protected:
|
||||
|
||||
public:
|
||||
|
||||
VkTextureLoader(GPUDevice *dev,const bool am)
|
||||
VkTextureLoader(VulkanDevice *dev,const bool am)
|
||||
{
|
||||
device =dev;
|
||||
buf =nullptr;
|
||||
|
@@ -12,7 +12,7 @@ class VertexAttribBuffer:public DeviceBuffer
|
||||
|
||||
private:
|
||||
|
||||
friend class GPUDevice;
|
||||
friend class VulkanDevice;
|
||||
|
||||
VertexAttribBuffer(VkDevice d,const DeviceBufferData &vb,VkFormat fmt,uint32_t _stride,uint32_t _count):DeviceBuffer(d,vb)
|
||||
{
|
||||
|
@@ -8,7 +8,7 @@ VK_NAMESPACE_BEGIN
|
||||
|
||||
class VertexDataManager
|
||||
{
|
||||
GPUDevice *device;
|
||||
VulkanDevice *device;
|
||||
|
||||
protected:
|
||||
|
||||
@@ -30,10 +30,10 @@ protected:
|
||||
|
||||
public:
|
||||
|
||||
VertexDataManager(GPUDevice *dev,const VIL *_vil);
|
||||
VertexDataManager(VulkanDevice *dev,const VIL *_vil);
|
||||
~VertexDataManager();
|
||||
|
||||
GPUDevice * GetDevice ()const{return device;} ///<取得GPU设备
|
||||
VulkanDevice * GetDevice ()const{return device;} ///<取得GPU设备
|
||||
|
||||
const VIL * GetVIL ()const{return vil;} ///<取得顶点输入格式列表
|
||||
|
||||
|
@@ -11,7 +11,7 @@ namespace hgl
|
||||
*/
|
||||
class TextPrimitive:public Primitive
|
||||
{
|
||||
GPUDevice * device;
|
||||
VulkanDevice * device;
|
||||
Material * mtl;
|
||||
|
||||
uint max_count; ///<缓冲区最大容量
|
||||
@@ -36,7 +36,7 @@ namespace hgl
|
||||
|
||||
public:
|
||||
|
||||
TextPrimitive(GPUDevice *,Material *,uint mc=1024);
|
||||
TextPrimitive(VulkanDevice *,Material *,uint mc=1024);
|
||||
|
||||
public:
|
||||
|
||||
@@ -44,7 +44,7 @@ namespace hgl
|
||||
|
||||
bool WriteVertex (const int16 *fp);
|
||||
bool WriteTexCoord (const float *fp);
|
||||
};//class TextPrimitive:public Renderable
|
||||
};//class TextPrimitive:public Mesh
|
||||
}//namespace graph
|
||||
}//namespace hgl
|
||||
#endif//HGL_GRAPH_FONT_PRIMITIVE_INCLUDE
|
||||
|
@@ -15,7 +15,7 @@ namespace hgl
|
||||
|
||||
class TextRender
|
||||
{
|
||||
GPUDevice * device;
|
||||
VulkanDevice * device;
|
||||
RenderResource * db;
|
||||
|
||||
Material * material;
|
||||
@@ -37,8 +37,8 @@ namespace hgl
|
||||
|
||||
private:
|
||||
|
||||
friend TextRender *CreateTextRender(GPUDevice *,FontSource *,RenderPass *,DeviceBuffer *,int limit=-1);
|
||||
TextRender(GPUDevice *dev,FontSource *);
|
||||
friend TextRender *CreateTextRender(VulkanDevice *,FontSource *,RenderPass *,DeviceBuffer *,int limit=-1);
|
||||
TextRender(VulkanDevice *dev,FontSource *);
|
||||
|
||||
bool InitTileFont(int limit);
|
||||
bool InitTextLayoutEngine();
|
||||
@@ -58,7 +58,7 @@ namespace hgl
|
||||
|
||||
bool Layout(TextPrimitive *tr,const U16String &str);
|
||||
|
||||
Renderable *CreateRenderable(TextPrimitive *text_primitive);
|
||||
Mesh *CreateMesh(TextPrimitive *text_primitive);
|
||||
|
||||
void Release(TextPrimitive *);
|
||||
};//class TextRender
|
||||
@@ -82,7 +82,7 @@ namespace hgl
|
||||
* 创建一个文本渲染器
|
||||
* @param limit 节数限制(-1表示自动)
|
||||
*/
|
||||
TextRender *CreateTextRender(GPUDevice *,FontSource *,RenderPass *,DeviceBuffer *,int limit);
|
||||
TextRender *CreateTextRender(VulkanDevice *,FontSource *,RenderPass *,DeviceBuffer *,int limit);
|
||||
}//namespace graph
|
||||
}//namespace hgl
|
||||
#endif//HGL_GRAPH_TEXT_RENDER_INCLUDE
|
||||
|
@@ -38,7 +38,7 @@ namespace hgl
|
||||
virtual ~TileFont();
|
||||
|
||||
bool Registry(TileUVFloatMap &,SortedSet<u32char> &chars_sets); ///<注册要使用的字符
|
||||
void Unregistry(const List<u32char> &); ///<注销要使用的字符
|
||||
void Unregistry(const ArrayList<u32char> &); ///<注销要使用的字符
|
||||
};//class TileFont
|
||||
}//namespace graph
|
||||
}//namespace hgl
|
||||
|
@@ -16,10 +16,10 @@ class GraphModule
|
||||
public:
|
||||
|
||||
RenderFramework * GetRenderFramework ()const{return render_framework;} ///<取得渲染框架
|
||||
GPUDevice * GetDevice (); ///<取得GPU设备
|
||||
VulkanDevice * GetDevice (); ///<取得GPU设备
|
||||
VkDevice GetVkDevice ()const; ///<取得VkDevice
|
||||
const GPUPhysicalDevice * GetPhysicalDevice ()const; ///<取得物理设备
|
||||
GPUDeviceAttribute *GetDeviceAttribute ()const; ///<取得设备属性
|
||||
const VulkanPhyDevice * GetPhyDevice ()const; ///<取得物理设备
|
||||
VulkanDevAttr *GetDevAttr ()const; ///<取得设备属性
|
||||
VkPipelineCache GetPipelineCache ()const; ///<取得PipelineCache
|
||||
|
||||
public:
|
||||
|
@@ -11,7 +11,7 @@ class GraphModuleManager
|
||||
|
||||
protected:
|
||||
|
||||
List<GraphModule *> module_list;
|
||||
ArrayList<GraphModule *> module_list;
|
||||
Map<size_t,GraphModule *> module_map;
|
||||
|
||||
public:
|
||||
@@ -23,7 +23,7 @@ public:
|
||||
public:
|
||||
|
||||
RenderFramework * GetRenderFramework ()const{return render_framework;} ///<取得渲染框架
|
||||
GPUDevice * GetDevice ()const; ///<取得GPU设备
|
||||
VulkanDevice * GetDevice ()const; ///<取得GPU设备
|
||||
|
||||
public:
|
||||
|
||||
|
@@ -22,6 +22,6 @@ public:
|
||||
|
||||
#define RENDER_MODULE_CLASS(class_name) class class_name:public GraphModuleInherit<class_name,RenderModule>
|
||||
|
||||
#define RENDER_MODULE_CONSTRUCT(class_name) class_name::class_name(GPUDevice *dev):GraphModuleInherit<class_name,RenderModule>(dev,#class_name)
|
||||
#define RENDER_MODULE_CONSTRUCT(class_name) class_name::class_name(VulkanDevice *dev):GraphModuleInherit<class_name,RenderModule>(dev,#class_name)
|
||||
|
||||
VK_NAMESPACE_END
|
||||
|
@@ -28,9 +28,9 @@ private:
|
||||
|
||||
private:
|
||||
|
||||
RenderPass * CreateRenderPass( const List<VkAttachmentDescription> &desc_list,
|
||||
const List<VkSubpassDescription> &subpass,
|
||||
const List<VkSubpassDependency> &dependency,
|
||||
RenderPass * CreateRenderPass( const ArrayList<VkAttachmentDescription> &desc_list,
|
||||
const ArrayList<VkSubpassDescription> &subpass,
|
||||
const ArrayList<VkSubpassDependency> &dependency,
|
||||
const RenderbufferInfo *);
|
||||
|
||||
public:
|
||||
|
@@ -20,7 +20,7 @@ public:
|
||||
public: //FrameBuffer相关
|
||||
|
||||
Framebuffer *CreateFBO(RenderPass *rp,ImageView **color_list,const uint image_count,ImageView *depth);
|
||||
// Framebuffer *CreateFBO(RenderPass *,List<ImageView *> &color,ImageView *depth);
|
||||
// Framebuffer *CreateFBO(RenderPass *,ArrayList<ImageView *> &color,ImageView *depth);
|
||||
Framebuffer *CreateFBO(RenderPass *,ImageView *color,ImageView *depth);
|
||||
Framebuffer *CreateFBO(RenderPass *,ImageView *);
|
||||
|
||||
|
@@ -91,11 +91,11 @@ public: //Create/Chagne
|
||||
|
||||
void Clear(TextureCreateInfo *);
|
||||
|
||||
bool ChangeTexture2D(Texture2D *,DeviceBuffer *buf, const List<Image2DRegion> &,VkPipelineStageFlags=VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT);
|
||||
bool ChangeTexture2D(Texture2D *,DeviceBuffer *buf, const ArrayList<Image2DRegion> &,VkPipelineStageFlags=VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT);
|
||||
bool ChangeTexture2D(Texture2D *,DeviceBuffer *buf, const RectScope2ui &, VkPipelineStageFlags=VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT);
|
||||
bool ChangeTexture2D(Texture2D *,const void *data,const VkDeviceSize size, const RectScope2ui &, VkPipelineStageFlags=VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT);
|
||||
|
||||
// bool ChangeTexture2DArray(Texture2DArray *,DeviceBuffer *buf, const List<Image2DRegion> &, const uint32_t base_layer,const uint32_t layer_count,VkPipelineStageFlags=VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT);
|
||||
// bool ChangeTexture2DArray(Texture2DArray *,DeviceBuffer *buf, const ArrayList<Image2DRegion> &, const uint32_t base_layer,const uint32_t layer_count,VkPipelineStageFlags=VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT);
|
||||
bool ChangeTexture2DArray(Texture2DArray *,DeviceBuffer *buf, const RectScope2ui &, const uint32_t base_layer,const uint32_t layer_count,VkPipelineStageFlags=VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT);
|
||||
bool ChangeTexture2DArray(Texture2DArray *,const void *data,const VkDeviceSize size,const RectScope2ui &, const uint32_t base_layer,const uint32_t layer_count,VkPipelineStageFlags=VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT);
|
||||
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#ifndef HGL_GRAPH_MTL_2D_CREATE_CONFIG_INCLUDE
|
||||
#define HGL_GRAPH_MTL_2D_CREATE_CONFIG_INCLUDE
|
||||
#pragma once
|
||||
|
||||
#include<hgl/graph/mtl/MaterialLibrary.h>
|
||||
#include<hgl/graph/mtl/MaterialConfig.h>
|
||||
#include<hgl/graph/CoordinateSystem.h>
|
||||
#include<hgl/graph/VertexAttrib.h>
|
||||
@@ -16,17 +16,20 @@ struct Material2DCreateConfig:public MaterialCreateConfig,public Comparator<Mate
|
||||
|
||||
public:
|
||||
|
||||
Material2DCreateConfig(const GPUDeviceAttribute *da,const AnsiString &name,const Prim &p):MaterialCreateConfig(da,name,p)
|
||||
Material2DCreateConfig(const PrimitiveType &p,
|
||||
const CoordinateSystem2D &cs=CoordinateSystem2D::NDC,
|
||||
const WithLocalToWorld &l2w=WithLocalToWorld::Without)
|
||||
:MaterialCreateConfig(p)
|
||||
{
|
||||
rt_output.color=1; //输出一个颜色
|
||||
rt_output.depth=false; //不输出深度
|
||||
rt_output.stencil=false; //不输出stencil
|
||||
|
||||
coordinate_system=CoordinateSystem2D::NDC;
|
||||
local_to_world=false;
|
||||
coordinate_system=cs;
|
||||
local_to_world=(l2w==WithLocalToWorld::With);
|
||||
|
||||
if(prim==Prim::SolidRectangles
|
||||
||prim==Prim::WireRectangles)
|
||||
if(prim==PrimitiveType::SolidRectangles
|
||||
||prim==PrimitiveType::WireRectangles)
|
||||
position_format=VAT_VEC4;
|
||||
else
|
||||
position_format=VAT_VEC2;
|
||||
@@ -50,20 +53,13 @@ public:
|
||||
}
|
||||
};//struct Material2DCreateConfig:public MaterialCreateConfig
|
||||
|
||||
MaterialCreateInfo *CreateVertexColor2D(const Material2DCreateConfig *);
|
||||
MaterialCreateInfo *CreatePureColor2D(const Material2DCreateConfig *);
|
||||
DEFINE_MATERIAL_FACTORY_CLASS(VertexColor2D, const Material2DCreateConfig)
|
||||
DEFINE_MATERIAL_FACTORY_CLASS(PureColor2D, const Material2DCreateConfig)
|
||||
//DEFINE_MATERIAL_FACTORY_CLASS(LerpLine2D, const Material2DCreateConfig);
|
||||
|
||||
|
||||
struct MaterialLerpLineConfig
|
||||
{
|
||||
|
||||
};
|
||||
|
||||
MaterialCreateInfo *CreateLerpLine2D(const Material2DCreateConfig *);
|
||||
|
||||
MaterialCreateInfo *CreatePureTexture2D(const Material2DCreateConfig *);
|
||||
MaterialCreateInfo *CreateRectTexture2D(Material2DCreateConfig *);
|
||||
MaterialCreateInfo *CreateRectTexture2DArray(Material2DCreateConfig *);
|
||||
DEFINE_MATERIAL_FACTORY_CLASS(PureTexture2D, const Material2DCreateConfig);
|
||||
DEFINE_MATERIAL_FACTORY_CLASS(RectTexture2D, Material2DCreateConfig);
|
||||
DEFINE_MATERIAL_FACTORY_CLASS(RectTexture2DArray, Material2DCreateConfig);
|
||||
|
||||
// 为什么有了LoadMaterialFromFile,还需要保留以上Create系列函数?
|
||||
|
||||
@@ -72,10 +68,11 @@ MaterialCreateInfo *CreateRectTexture2DArray(Material2DCreateConfig *);
|
||||
|
||||
/**
|
||||
* 从文件加载材质
|
||||
* @param dev_attr 设备属性
|
||||
* @param mtl_name 材质名称
|
||||
* @param cfg 材质创建参数
|
||||
* @return 材质创建信息
|
||||
*/
|
||||
MaterialCreateInfo *LoadMaterialFromFile(const AnsiString &mtl_name,Material2DCreateConfig *cfg); ///<从文件加载材质
|
||||
MaterialCreateInfo *LoadMaterialFromFile(const VulkanDevAttr *dev_attr,const AnsiString &mtl_name,Material2DCreateConfig *cfg); ///<从文件加载材质
|
||||
|
||||
STD_MTL_NAMESPACE_END
|
||||
#endif//HGL_GRAPH_MTL_2D_CREATE_CONFIG_INCLUDE
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user