43 Commits

Author SHA1 Message Date
89b9735f99 improved sample. 2024-03-15 01:38:47 +08:00
7f744d1207 updated test codes. 2024-03-13 00:13:58 +08:00
b9f5c69f85 optimized to get normal in AutoShader 2024-03-12 23:29:38 +08:00
c469fde84a adjusted order of codes in Std2DMaterialLoader.cpp and Std3DMaterialLoader.cpp 2024-03-12 23:29:06 +08:00
dd6b2f4fb3 add "hasInput(const char *name)" in ShaderDescriptorInfo and ShaderCreateInfoVertex classes. 2024-03-12 23:28:23 +08:00
ba8b44659b resume GetNormalMatrix/GetNormal in auto shader. 2024-03-12 23:04:12 +08:00
13b2ca0575 fixed Viewport UBO bug. 2024-03-12 22:54:33 +08:00
9d704eb33d updated comments. 2024-03-12 22:31:58 +08:00
86c3b65a42 fixed -normal bug in InlineGeometry.cpp 2024-03-12 21:53:41 +08:00
f6e61e70ce 更改了specular算法,但是有点问题。。。而且高光区有点象是VS算的一样,怀疑是NORMAL在VS算的原因。但fs没有GetLocalToWorld函数,需要尝试修复。 2024-03-12 00:42:32 +08:00
5347ac7091 specular OK in BlinnPhongDirectionLight sample. but direction error. 2024-03-10 22:45:38 +08:00
f56928d734 Fixed bug about SunLightPureColor.mtl 2024-03-10 01:00:42 +08:00
f3a59c1bb3 test sunlight UBO ok! 2024-03-10 00:35:35 +08:00
5188d4149c added Unknow and Static in DescriptorSetType 2024-03-09 23:35:56 +08:00
d4096735f5 adjusted order of codes in MaterialCreateInfo.h 2024-03-09 23:23:34 +08:00
4fafd938b1 new function, MaterialFileData load UBO OK! to make shader OK. 2024-03-09 22:26:45 +08:00
f0848541c2 added a newly AddUBO() in MaterialCreateInfo 2024-03-09 22:25:03 +08:00
cc9e756ece fixed Load of ubo codes. 2024-03-09 21:23:02 +08:00
cdedc81f9f save codes of UBO in AccumMemoryManager 2024-03-09 20:48:30 +08:00
c229259623 added comments 2024-03-09 19:49:44 +08:00
2c2f11f47e added little safe check of filename in MaterialFileLoader.cpp 2024-03-07 23:04:54 +08:00
c8b3ed0286 preparing blinnphong light sample. added codes of to load ubo. 2024-03-07 13:59:28 +08:00
2ce36ec26c fixed a bug in ShaderCreateInfoVertex.cpp, put "C-style string" in function that it's a bug. 2024-03-07 00:07:49 +08:00
5ba3c1790d removed standalone ".glsl" files ,merge to c++ codes. 2024-03-06 23:24:57 +08:00
3874d771d3 aligned codes, append CreateIBO8 functions in VKRenderResource.h 2024-03-06 22:51:07 +08:00
49eb8f42f0 updated DescriptorBinding::BindUBO, to support dynamic param. 2024-03-06 22:40:51 +08:00
c355f96f9b little codes 2024-03-06 13:54:05 +08:00
dc3d7b7792 removed BindingMapping 2024-03-06 00:29:17 +08:00
5f1c60a24a Improved VKDescriptorBindingManage 2024-03-06 00:26:23 +08:00
ff6a644e8f added BlinnPhong.h 2024-03-04 13:13:33 +08:00
b9e70426a1 removed sun.ubo, next step is UBO in C++ 2024-03-04 13:12:29 +08:00
a7af276a44 updated SunLightPureColor.mtl 2024-03-04 12:58:22 +08:00
8b82c6c25c support the new other codes. 2024-03-02 10:35:27 +08:00
a8d68c295d renamed many values. 2024-02-13 22:27:12 +08:00
f666d5b248 renamed values of BlinnPhongDirectionLight.cpp 2024-02-12 08:23:31 +08:00
55c27a883b init empty BlinnPhongDirectionLight example 2024-02-12 08:20:24 +08:00
6a7f8e7754 fixed access method 2024-02-03 19:53:19 +08:00
1dbf8ae5c7 renamed values. 2023-12-24 01:35:30 +08:00
8dbc1d899c added to Check ubolist in MaterialFileLoader.cpp 2023-12-05 02:24:09 +08:00
d010ee4278 I updated two sub-modules, Platform and Util. 2023-12-05 02:13:21 +08:00
4aeb28c571 added a parse in MaterialFileLoader.cpp that it's UBOParse 2023-12-05 02:08:18 +08:00
775e031422 added VK_LAYER_AMD_switchable_graphics in VKInstance.h/VKProperties.cpp 2023-12-05 02:07:25 +08:00
deefdf1416 used uint instead of int in Size of viewport 2023-11-10 04:24:10 +08:00
57 changed files with 910 additions and 356 deletions

2
CMCore

Submodule CMCore updated: 1141f37cc4...2f93a1bb00

2
CMUtil

Submodule CMUtil updated: c0990c52eb...953ecf8079

View File

@@ -1,4 +0,0 @@
mat4 GetLocalToWorld()
{
return l2w.mats[Assign.x];
}

View File

@@ -1,8 +0,0 @@
MaterialInstance GetMI()
{
#if ShaderStage == VertexShader
return mtl.mi[Assign.y];
#else
return mtl.mi[Input.MaterialInstanceID];
#endif
}

View File

@@ -1,10 +0,0 @@
void HandoverMI()
{
#if ShaderStage == VertexShader
Output.MaterialInstanceID=Assign.y;
#elif ShaderStage == GeometryShader
Output.MaterialInstanceID=Input[0].MaterialInstanceID;
#else
Output.MaterialInstanceID=Input.MaterialInstanceID;
#endif
}

View File

@@ -1,10 +0,0 @@
#version 460 core
#define VertexShader 0x01
#define TessControlShader 0x02
#define TeseEvalShader 0x04
#define GeometryShader 0x08
#define FragmentShader 0x10
#define ComputeShader 0x20
#define TaskShader 0x40
#define MeshShader 0x80

View File

@@ -0,0 +1,2 @@
vec4 direction;
vec4 color;

View File

@@ -0,0 +1,92 @@
#Material
Name BlinnPhong+HalfLambert shading model only color
Reference https://zhuanlan.zhihu.com/p/442023993
Base Std3D/BlinnPhong
//某些Require并不真的存在.ubo文件写成一行一个是为了方便未来改成带路径的
Require LocalToWorld
Require Camera
define HAVE_SPECULAR off //默认不定义HAVE_SPECULAR
UBO
{
File BlinnPhongSun.ubo //文件名,如果/开头表示从ShaderLibrary根目录开始没有则表示同一目录
Struct BlinnPhongSun //结构名称
Name sun //在代码中的变量名
Stage Fragment //会引用的shader
Set Global //Descriptor Set
}
#MaterialInstance
Length 16
Stage Fragment
Code
{
vec3 Color;
float Gloss;
}
#VertexInput
vec3 Normal
#Vertex
Output
{
vec4 Position;
vec3 Normal;
}
Code
{
void main()
{
Output.Normal =GetNormal();
Output.Position =GetPosition3D();
HandoverMI();
gl_Position =Output.Position;
}
}
#Fragment
Output
{
vec4 FragColor;
}
Code
{
#define HAVE_SPECULAR
void main()
{
MaterialInstance mi=GetMI();
//点乘法线和光照
float intensity=0.5*max(dot(Input.Normal,sun.direction.xyz),0.0)+0.5;
//直接光颜色
vec3 direct_color =intensity*sun.color.rgb*mi.Color.rgb;
#ifndef HAVE_SPECULAR
FragColor=vec4(direct_color,1.0);
#else
vec3 spec_color=vec3(0.0);
if(intensity>0.0)
{
vec3 half_vector=normalize(sun.direction.xyz+normalize(Input.Position.xyz+camera.pos));
float specular=max(dot(half_vector,Input.Normal),0.0);
spec_color=specular*pow(specular,mi.Gloss)*sun.color.rgb;
}
FragColor=vec4(direct_color+spec_color,1.0);
#endif//HAVE_SPECULAR
}
}

View File

@@ -1,64 +0,0 @@
#Material
Name BlinnPhong+HalfLambert shading model only color
Reference https://zhuanlan.zhihu.com/p/442023993
Base Std3D
Require LocalToWorld,Camera,Sun
#MaterialInstance
#VertexInput
vec3 Normal
#Vertex
Output
{
vec3 Normal;
}
Code
{
void main()
{
gl_Position=GetPosition3D();
}
}
#Fragment
Output
{
vec4 FragColor;
}
Code
{
void main()
{
//将法线归一化
vec3 world_normal =normalize(Input.Normal);
//对世界坐标下的灯光方法归一化
vec3 world_light_direction =normalize(sun.direction);
//点乘法线和光照
vec3 diffuse =0.5*dot(world_light_direction,world_normal)+0.5;
//直接光颜色
vec3 direct_color =sun.diffuse*diffuse*sun.color;
#ifndef HAVE_SPECULAR
FragColor=vec4(direct_color,1.0);
#else
//归一代视角方向
vec3 view_direction =normalize(camera.pos-world_position);
//世界坐标下的反射光方向
vec3 reflect_direction =normalize(reflect(-world_light_direction,world_normal));
//高光
vec3 specular =sun.specular*pow(saturate(dot(reflect_direction,view_direction)),gloss);
FragColor=vec4(direct_color+specular,1.0);
#endif//HAVE_SPECULAR
}
}

Binary file not shown.

View File

@@ -143,7 +143,7 @@ public:
return(true);
}
void Resize(int w,int h)override
void Resize(uint w,uint h)override
{
cam.width=w;
cam.height=h;

View File

@@ -165,7 +165,7 @@ public:
return(true);
}
void Resize(int w,int h)override
void Resize(uint w,uint h)override
{
cam.width=w;
cam.height=h;

View File

@@ -116,7 +116,7 @@ public:
return(true);
}
void Resize(int w,int h)override
void Resize(uint w,uint h)override
{
VulkanApplicationFramework::Resize(w,h);

View File

@@ -130,7 +130,7 @@ public:
return(true);
}
void Resize(int w,int h)override
void Resize(uint w,uint h)override
{
VulkanApplicationFramework::Resize(w,h);

View File

@@ -145,7 +145,7 @@ public:
return(true);
}
void Resize(int w,int h)override
void Resize(uint w,uint h)override
{
VulkanApplicationFramework::Resize(w,h);

View File

@@ -120,7 +120,7 @@ public:
return(true);
}
void Resize(int w,int h)override
void Resize(uint w,uint h)override
{
VulkanApplicationFramework::Resize(w,h);

View File

@@ -26,7 +26,7 @@ private:
Material * mtl_vtx_lum =nullptr;
MaterialInstance * mi_plane_grid =nullptr;
Pipeline * pipeline_vtx_lum =nullptr;
Primitive * ro_plane_grid =nullptr;
Primitive * prim_plane_grid =nullptr;
Material * mtl_vtx_color =nullptr;
MaterialInstance * mi_line =nullptr;
@@ -151,16 +151,14 @@ private:
{
struct PlaneGridCreateInfo pgci;
pgci.grid_size.width =32;
pgci.grid_size.height=32;
pgci.grid_size.Set(32,32);
pgci.sub_count.width =8;
pgci.sub_count.height=8;
pgci.sub_count.Set(8,8);
pgci.lum=0.5;
pgci.sub_lum=0.75;
ro_plane_grid=CreatePlaneGrid(db,mtl_vtx_lum->GetDefaultVIL(),&pgci);
prim_plane_grid=CreatePlaneGrid(db,mtl_vtx_lum->GetDefaultVIL(),&pgci);
}
{
@@ -191,7 +189,7 @@ private:
bool InitScene()
{
Add(ro_plane_grid,mi_plane_grid,pipeline_vtx_lum);
Add(prim_plane_grid,mi_plane_grid,pipeline_vtx_lum);
Add(ro_line,mi_line,pipeline_vtx_color);
camera->pos=Vector3f(32,32,32);
@@ -206,7 +204,7 @@ private:
public:
bool Init(int w,int h) override
bool Init(uint w,uint h) override
{
if(!SceneAppFramework::Init(w,h))
return(false);

View File

@@ -104,7 +104,7 @@ private:
{
Add(material_instance,scale(PLANE_SIZE,PLANE_SIZE,1));
camera->pos=Vector3f(PLANE_SIZE/2,PLANE_SIZE/2,PLANE_SIZE/2);
camera->pos=Vector3f(PLANE_SIZE/2,PLANE_SIZE/2,PLANE_SIZE/4);
camera_control->SetTarget(Vector3f(0,0,0));
camera_control->Refresh();

View File

@@ -19,7 +19,7 @@ private:
Material * material =nullptr;
Pipeline * pipeline =nullptr;
Primitive * ro_plane_grid =nullptr;
Primitive * prim_plane_grid =nullptr;
MaterialInstance * material_instance[3]{};
private:
@@ -56,23 +56,20 @@ private:
struct PlaneGridCreateInfo pgci;
pgci.grid_size.width =32;
pgci.grid_size.height=32;
pgci.grid_size.Set(32,32);
pgci.sub_count.Set(8,8);
pgci.sub_count.width =8;
pgci.sub_count.height=8;
pgci.lum=0.5;
pgci.lum=0.75;
pgci.sub_lum=1.0;
ro_plane_grid=CreatePlaneGrid(db,material->GetDefaultVIL(),&pgci);
prim_plane_grid=CreatePlaneGrid(db,material->GetDefaultVIL(),&pgci);
return ro_plane_grid;
return prim_plane_grid;
}
Renderable *Add(MaterialInstance *mi,const Matrix4f &mat)
{
Renderable *ri=db->CreateRenderable(ro_plane_grid,mi,pipeline);
Renderable *ri=db->CreateRenderable(prim_plane_grid,mi,pipeline);
if(!ri)
return(nullptr);

View File

@@ -38,7 +38,7 @@ private:
Pipeline * pipeline =nullptr;
Primitive * ro_plane_grid =nullptr;
Primitive * prim_plane_grid =nullptr;
Primitive * ro_line =nullptr;
@@ -93,16 +93,13 @@ private:
{
struct PlaneGridCreateInfo pgci;
pgci.grid_size.width =32;
pgci.grid_size.height=32;
pgci.sub_count.width =8;
pgci.sub_count.height=8;
pgci.grid_size.Set(32,32);
pgci.sub_count.Set(8,8);
pgci.lum=0.5;
pgci.sub_lum=0.75;
ro_plane_grid=CreatePlaneGrid(db,material->GetDefaultVIL(),&pgci);
prim_plane_grid=CreatePlaneGrid(db,material->GetDefaultVIL(),&pgci);
}
{
@@ -118,7 +115,7 @@ private:
bool InitScene()
{
Add(ro_plane_grid,mi_plane_grid);
Add(prim_plane_grid,mi_plane_grid);
Add(ro_line,mi_line);
camera->pos=Vector3f(32,32,32);

View File

@@ -0,0 +1,217 @@
// BlinnPhong direction light
#include"VulkanAppFramework.h"
#include<hgl/filesystem/FileSystem.h>
#include<hgl/graph/InlineGeometry.h>
#include<hgl/graph/VKRenderResource.h>
#include<hgl/graph/RenderList.h>
#include<hgl/graph/Camera.h>
#include<hgl/graph/Ray.h>
#include<hgl/graph/VKVertexAttribBuffer.h>
#include<hgl/graph/mtl/Material3DCreateConfig.h>
#include<hgl/graph/mtl/BlinnPhong.h>
using namespace hgl;
using namespace hgl::graph;
static float lumiance_data[2]={1,1};
static Color4f white_color(1,1,1,1);
static mtl::blinnphong::SunLight sun_light=
{
Vector4f(1,1,1,0), //direction
Vector4f(1,0.95,0.9,1) //color
};
class TestApp:public SceneAppFramework
{
private: //plane grid
Material * mtl_vertex_lum =nullptr;
MaterialInstance * mi_plane_grid =nullptr;
Pipeline * p_line =nullptr;
Primitive * prim_plane_grid =nullptr;
private:
DeviceBuffer * ubo_sun =nullptr;
private: //sphere
Material * mtl_blinnphong =nullptr;
MaterialInstance * mi_blinnphong =nullptr;
Pipeline * p_blinnphong =nullptr;
Primitive * prim_sphere =nullptr;
Primitive * prim_cone =nullptr;
Primitive * prim_cylinder =nullptr;
private:
bool InitVertexLumMP()
{
mtl::Material3DCreateConfig cfg(device->GetDeviceAttribute(),"VertexLuminance3D",Prim::Lines);
cfg.local_to_world=true;
mtl_vertex_lum=db->LoadMaterial("Std3D/VertexLum3D",&cfg);
if(!mtl_vertex_lum)return(false);
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);
if(!p_line)
return(false);
return(true);
}
bool CreateBlinnPhongUBO()
{
ubo_sun=db->CreateUBO("sun",sizeof(sun_light),&sun_light);
if(!ubo_sun)return(false);
return(true);
}
bool InitBlinnPhongSunLightMP()
{
mtl::Material3DCreateConfig cfg(device->GetDeviceAttribute(),"BlinnPhong3D",Prim::Triangles);
cfg.local_to_world=true;
mtl_blinnphong=db->LoadMaterial("Std3D/BlinnPhong/SunLightPureColor",&cfg);
if(!mtl_blinnphong)return(false);
mtl_blinnphong->BindUBO(DescriptorSetType::Global,"sun",ubo_sun);
mtl_blinnphong->Update();
float mi_data[4]=
{
1,0,0, //color
4 //gloss
};
mi_blinnphong=db->CreateMaterialInstance(mtl_blinnphong,nullptr,&mi_data);
if(!mi_blinnphong)return(false);
p_blinnphong=CreatePipeline(mtl_blinnphong,InlinePipeline::Solid3D,Prim::Triangles);
if(!p_blinnphong)
return(false);
return(true);
}
bool CreateRenderObject()
{
using namespace inline_geometry;
//Plane Grid
{
struct PlaneGridCreateInfo pgci;
pgci.grid_size.Set(32,32);
pgci.sub_count.Set(8,8);
pgci.lum=0.5;
pgci.sub_lum=0.75;
prim_plane_grid=CreatePlaneGrid(db,mtl_vertex_lum->GetDefaultVIL(),&pgci);
}
//Sphere
prim_sphere=CreateSphere(db,mi_blinnphong->GetVIL(),16);
//Cone
{
struct ConeCreateInfo cci;
cci.radius =1; //圆锥半径
cci.halfExtend =1; //圆锤一半高度
cci.numberSlices=16; //圆锥底部分割数
cci.numberStacks=8; //圆锥高度分割数
prim_cone=CreateCone(db,mi_blinnphong->GetVIL(),&cci);
}
//Cyliner
{
struct CylinderCreateInfo cci;
cci.halfExtend =4; //圆柱一半高度
cci.numberSlices=16; //圆柱底部分割数
cci.radius =0.25f; //圆柱半径
prim_cylinder=CreateCylinder(db,mi_blinnphong->GetVIL(),&cci);
}
return(true);
}
Renderable *Add(Primitive *r,MaterialInstance *mi,Pipeline *p,const Matrix4f &mat)
{
Renderable *ri=db->CreateRenderable(r,mi,p);
if(!ri)
{
LOG_ERROR(OS_TEXT("Create Renderable failed."));
return(nullptr);
}
render_root.CreateSubNode(mat,ri);
return ri;
}
bool InitScene()
{
Add(prim_plane_grid,mi_plane_grid,p_line,Identity4f);
Add(prim_sphere, mi_blinnphong,p_blinnphong,translate(Vector3f(0,0,2)));
Add(prim_cone, mi_blinnphong,p_blinnphong,Identity4f);
Add(prim_cylinder, mi_blinnphong,p_blinnphong,translate(Vector3f(0,0,-5)));
camera->pos=Vector3f(32,32,32);
camera_control->SetTarget(Vector3f(0,0,0));
camera_control->Refresh();
render_root.RefreshMatrix();
render_list->Expend(&render_root);
return(true);
}
public:
bool Init(uint w,uint h)
{
if(!SceneAppFramework::Init(w,h))
return(false);
if(!InitVertexLumMP())
return(false);
if(!CreateBlinnPhongUBO())
return(false);
if(!InitBlinnPhongSunLightMP())
return(false);
if(!CreateRenderObject())
return(false);
if(!InitScene())
return(false);
return(true);
}
};//class TestApp:public CameraAppFramework
int main(int,char **)
{
return RunApp<TestApp>(1280,720);
}

View File

@@ -112,7 +112,7 @@ public:
return(true);
}
void Resize(int w,int h)override
void Resize(uint w,uint h)override
{
VulkanApplicationFramework::Resize(w,h);

View File

@@ -108,7 +108,7 @@ public:
return(true);
}
void Resize(int w,int h)override
void Resize(uint w,uint h)override
{
VulkanApplicationFramework::Resize(w,h);

View File

@@ -184,7 +184,7 @@ public:
return(true);
}
void Resize(int w,int h)override
void Resize(uint w,uint h)override
{
VulkanApplicationFramework::Resize(w,h);

View File

@@ -90,7 +90,7 @@ public:
SAFE_CLEAR(inst);
}
virtual bool Init(int w,int h)
virtual bool Init(uint w,uint h)
{
logger::InitLogger(OS_TEXT("VulkanTest"));
@@ -153,13 +153,13 @@ public:
ubo_vp_info=db->CreateUBO("Viewport",sizeof(ViewportInfo),&vp_info);
db->global_descriptor.AddUBO(mtl::SBS_ViewportInfo.name,ubo_vp_info);
db->static_descriptor.AddUBO(mtl::SBS_ViewportInfo.name,ubo_vp_info);
}
return(true);
}
virtual void Resize(int w,int h)
virtual void Resize(uint w,uint h)
{
vp_info.Set(w,h);
ubo_vp_info->Write(&vp_info);
@@ -494,7 +494,7 @@ public:
SAFE_CLEAR(camera);
}
virtual bool Init(int w,int h) override
virtual bool Init(uint w,uint h) override
{
if(!VulkanApplicationFramework::Init(w,h))
return(false);
@@ -526,7 +526,7 @@ public:
db->global_descriptor.AddUBO(mtl::SBS_CameraInfo.name,ubo_camera_info);
}
void Resize(int w,int h)override
void Resize(uint w,uint h)override
{
vp_info.Set(w,h);
@@ -580,7 +580,7 @@ public:
SAFE_CLEAR(render_list);
}
virtual bool Init(int width,int height) override
virtual bool Init(uint width,uint height) override
{
if(!CameraAppFramework::Init(width,height))
return(false);
@@ -595,7 +595,7 @@ public:
VulkanApplicationFramework::BuildCommandBuffer(index,render_list);
}
virtual void Resize(int w,int h) override
virtual void Resize(uint w,uint h) override
{
CameraAppFramework::Resize(w,h);

View File

@@ -2,7 +2,7 @@
#define HGL_GRAPH_LIGHT_INCLUDE
#include<hgl/math/Math.h>
#include<hgl/type/Color4f.h>
#include<hgl/color/Color4f.h>
namespace hgl
{
namespace graph

View File

@@ -26,7 +26,9 @@ constexpr size_t VK_DESCRIPTOR_TYPE_RANGE_SIZE=VK_DESCRIPTOR_TYPE_END_RANGE-VK_D
#endif//VK_DESCRIPTOR_TYPE_RANGE_SIZE
using CharPointerList=hgl::List<const char *>;
using BindingMapping=Map<uint32_t,int>;
using BindingMap =Map<AnsiString,int>;
using BindingMapArray =BindingMap[VK_DESCRIPTOR_TYPE_RANGE_SIZE];
class VulkanInstance;
class GPUPhysicalDevice;
@@ -144,19 +146,10 @@ enum IndexType:uint
U8=VK_INDEX_TYPE_UINT8_EXT,
};
/**
* max-lengths:
*
256 bytes: nvidia,arm
128 bytes: amd,intel,powervr,adreno
*/
struct PushConstant
{
Matrix4f local_to_world;
Matrix4f normal;
};
constexpr uint32_t MAX_PUSH_CONSTANT_BYTES=sizeof(PushConstant);
//Push Constant max-lengths:
//
// 256 bytes: nvidia,arm
// 128 bytes: amd,intel,powervr,adreno
inline void copy(VkExtent3D &e3d,const VkExtent2D &e2d,const uint32 depth=1)
{

View File

@@ -1,8 +1,9 @@
#ifndef HGL_GRAPH_DESCRIPTOR_BINDING_MANAGE_INCLUDE
#ifndef HGL_GRAPH_DESCRIPTOR_BINDING_MANAGE_INCLUDE
#define HGL_GRAPH_DESCRIPTOR_BINDING_MANAGE_INCLUDE
#include<hgl/type/Map.h>
#include<hgl/type/String.h>
#include<hgl/graph/VK.h>
#include<hgl/graph/VKDescriptorSetType.h>
namespace hgl
{
@@ -11,10 +12,15 @@ namespace hgl
class DeviceBuffer;
class Texture;
class Material;
class MaterialParameters;
/**
* 描述符绑定器<Br>
* 一般用于注册通用数据,为材质进行自动绑定。
*/
class DescriptorBinding
{
DescriptorSetType set_type;
DescriptorSetType set_type; ///<描述符合集类型
Map<AnsiString,DeviceBuffer *> ubo_map;
Map<AnsiString,DeviceBuffer *> ssbo_map;
@@ -93,6 +99,12 @@ namespace hgl
texture_map.DeleteByValue(tex);
}
private:
void BindUBO(MaterialParameters *,const BindingMap &,bool dynamic);
public:
bool Bind(Material *);
};//class DescriptorBinding
}//namespace graph

View File

@@ -28,6 +28,11 @@ VK_NAMESPACE_BEGIN
VK_BOOL1BIT(profiles)
}khronos;
struct
{
VK_BOOL1BIT(switchable_graphics)
}amd;
struct
{
VK_BOOL1BIT(optimus)

View File

@@ -49,15 +49,15 @@ public:
virtual ~Material();
const UTF8String & GetName ()const{return name;}
const AnsiString & GetName ()const{return name;}
const VertexInput * GetVertexInput ()const{return vertex_input;}
const ShaderStageCreateInfoList & GetStageList ()const{return shader_stage_list;}
const MaterialDescriptorManager * GetDescriptorSets ()const{return desc_manager;}
// const MaterialDescriptorManager * GetDescriptorManager ()const{return desc_manager;}
const VkPipelineLayout GetPipelineLayout ()const;
const PipelineLayoutData * GetPipelineLayoutData ()const{return pipeline_layout_data;}
// const PipelineLayoutData * GetPipelineLayoutData ()const{return pipeline_layout_data;}
public:

View File

@@ -5,9 +5,6 @@
#include<hgl/graph/VKShaderDescriptorSet.h>
VK_NAMESPACE_BEGIN
using BindingMap=Map<AnsiString,int>;
using BindingMapArray=BindingMap[VK_DESCRIPTOR_TYPE_RANGE_SIZE];
class MaterialDescriptorManager
{
UTF8String mtl_name;

View File

@@ -80,11 +80,15 @@ private:
public:
//注:并非一定要走这里,这里只是提供一个注册和自动绑定的机制
DescriptorBinding global_descriptor; ///<全局属性描述符绑定管理
DescriptorBinding static_descriptor; ///<静态属性描述符绑定管理
DescriptorBinding global_descriptor; ///<全局属性描述符绑定管理
public:
RenderResource(GPUDevice *dev):device(dev),global_descriptor(DescriptorSetType::Global){}
RenderResource(GPUDevice *dev):device(dev),
static_descriptor(DescriptorSetType::Static),
global_descriptor(DescriptorSetType::Global)
{}
virtual ~RenderResource()=default;
public: //Add
@@ -100,9 +104,9 @@ public: //Add
public: // VBO/VAO
VBO *CreateVBO(VkFormat format,uint32_t count,const void *data,SharingMode sm=SharingMode::Exclusive);
VBO *CreateVBO(VkFormat format,uint32_t count,SharingMode sm=SharingMode::Exclusive){return CreateVBO(format,count,nullptr,sm);}
VBO *CreateVBO(const VAD *vad,SharingMode sm=SharingMode::Exclusive){return CreateVBO(vad->GetFormat(),vad->GetCount(),vad->GetData(),sm);}
VBO *CreateVBO(VkFormat format,uint32_t count,const void *data, SharingMode sm=SharingMode::Exclusive);
VBO *CreateVBO(VkFormat format,uint32_t count, SharingMode sm=SharingMode::Exclusive){return CreateVBO(format, count, nullptr, sm);}
VBO *CreateVBO(const VAD *vad, SharingMode sm=SharingMode::Exclusive){return CreateVBO(vad->GetFormat(), vad->GetCount(),vad->GetData(), sm);}
#define SCENE_DB_CREATE_FUNC(name) DeviceBuffer *Create##name(const AnsiString &buf_name,VkDeviceSize size,void *data,SharingMode sm=SharingMode::Exclusive); \
DeviceBuffer *Create##name(const AnsiString &buf_name,VkDeviceSize size,SharingMode sm=SharingMode::Exclusive){return Create##name(buf_name,size,nullptr,sm);}
@@ -114,12 +118,14 @@ public: // VBO/VAO
#undef SCENE_DB_CREATE_FUNC
IndexBuffer *CreateIBO(IndexType index_type,uint32_t count,const void * data, SharingMode sm=SharingMode::Exclusive);
IndexBuffer *CreateIBO8 ( uint32_t count,const uint8 *data, SharingMode sm=SharingMode::Exclusive){return CreateIBO(IndexType::U8 ,count,(void *)data,sm);}
IndexBuffer *CreateIBO16( uint32_t count,const uint16 *data, SharingMode sm=SharingMode::Exclusive){return CreateIBO(IndexType::U16,count,(void *)data,sm);}
IndexBuffer *CreateIBO32( uint32_t count,const uint32 *data, SharingMode sm=SharingMode::Exclusive){return CreateIBO(IndexType::U32,count,(void *)data,sm);}
IndexBuffer *CreateIBO(IndexType index_type,uint32_t count,SharingMode sm=SharingMode::Exclusive){return CreateIBO(index_type,count,nullptr,sm);}
IndexBuffer *CreateIBO16( uint32_t count,SharingMode sm=SharingMode::Exclusive){return CreateIBO(IndexType::U16,count,nullptr,sm);}
IndexBuffer *CreateIBO32( uint32_t count,SharingMode sm=SharingMode::Exclusive){return CreateIBO(IndexType::U32,count,nullptr,sm);}
IndexBuffer *CreateIBO(IndexType index_type,uint32_t count,SharingMode sm=SharingMode::Exclusive){return CreateIBO(index_type, count,nullptr,sm);}
IndexBuffer *CreateIBO8 ( uint32_t count,SharingMode sm=SharingMode::Exclusive){return CreateIBO(IndexType::U8, count,nullptr,sm);}
IndexBuffer *CreateIBO16( uint32_t count,SharingMode sm=SharingMode::Exclusive){return CreateIBO(IndexType::U16, count,nullptr,sm);}
IndexBuffer *CreateIBO32( uint32_t count,SharingMode sm=SharingMode::Exclusive){return CreateIBO(IndexType::U32, count,nullptr,sm);}
public: //Material

View File

@@ -0,0 +1,26 @@
#pragma once
#include<hgl/graph/mtl/StdMaterial.h>
#include<hgl/graph/mtl/ShaderBuffer.h>
#include<hgl/math/Vector.h>
STD_MTL_NAMESPACE_BEGIN
namespace blinnphong
{
struct SunLight
{
Vector4f direction;
Vector4f color;
};//struct SunLight
constexpr const ShaderBufferSource SBS_SunLight=
{
"SunLight",
"sun",
R"(
vec4 direction;
vec4 color;
)"
};
}//namespace blinnphong
STD_MTL_NAMESPACE_END

View File

@@ -0,0 +1,24 @@
#pragma once
#include<hgl/graph/mtl/StdMaterial.h>
#include<hgl/graph/mtl/ShaderBuffer.h>
STD_MTL_NAMESPACE_BEGIN
/**
* 所有UBO的基类它即向生成器提供代码也可以为渲染器提供数据
*/
class UniformBuffer
{
private:
ShaderBufferSource *sbs;
public:
virtual const AnsiString &GetStructName ()const{return sbs->struct_name;} ///<取得结构名称
virtual const AnsiString &GetDefaultValueName ()const{return sbs->name;} ///<取得默认变量名称
virtual const AnsiString &GetShaderCodes ()const{return sbs->codes;} ///<取得Shader代码
};//class UniformBuffer
STD_MTL_NAMESPACE_END

View File

@@ -83,10 +83,11 @@ namespace hgl{namespace graph
bool AddStruct(const AnsiString &ubo_typename,const AnsiString &codes);
bool AddStruct(const ShaderBufferSource &ss){return AddStruct(ss.struct_name,ss.codes);}
bool AddUBO(const VkShaderStageFlagBits flag_bits,const DescriptorSetType set_type,const AnsiString &type_name,const AnsiString &name);
bool AddSampler(const VkShaderStageFlagBits flag_bits,const DescriptorSetType set_type,const SamplerType &st,const AnsiString &name);
bool AddUBO(const VkShaderStageFlagBits flag_bits,const DescriptorSetType set_type,const AnsiString &struct_name,const AnsiString &name);
bool AddUBO(const uint32_t flag_bits,const DescriptorSetType &set_type,const AnsiString &struct_name,const AnsiString &name);
bool AddUBO(const uint32_t flag_bits,const DescriptorSetType &set_type,const ShaderBufferSource &ss){return AddUBO(flag_bits,set_type,ss.struct_name,ss.name);}
bool AddUBO(const uint32_t flag_bits,const DescriptorSetType &set_type,const ShaderBufferSource &ss);
bool AddSampler(const VkShaderStageFlagBits flag_bits,const DescriptorSetType set_type,const SamplerType &st,const AnsiString &name);
bool CreateShader();
};//class MaterialCreateInfo

View File

@@ -80,7 +80,6 @@ public:
int AddOutput(const AnsiString &type,const AnsiString &name,Interpolation inter=Interpolation::Smooth);
void AddFunction(const char *str){function_list.Add(str);}
void AddFunction(const AnsiString *str){function_list.Add(str->c_str());}
void SetMaterialInstance(UBODescriptor *,const AnsiString &);
void AddMaterialInstanceOutput();

View File

@@ -19,6 +19,8 @@ namespace hgl
int AddInput(const graph::VAT &type,const AnsiString &name,const VkVertexInputRate input_rate=VK_VERTEX_INPUT_RATE_VERTEX,const VertexInputGroup &group=VertexInputGroup::Basic);
int AddInput(const AnsiString &type,const AnsiString &name,const VkVertexInputRate input_rate=VK_VERTEX_INPUT_RATE_VERTEX,const VertexInputGroup &group=VertexInputGroup::Basic);
int hasInput(const char *);
void AddJoint();
void AddAssign();
};//class ShaderCreateInfoVertex:public ShaderCreateInfo

View File

@@ -59,6 +59,8 @@ public:
bool AddInput(ShaderAttribute *);
bool AddOutput(ShaderAttribute *);
bool hasInput(const char *)const; ///<是否有指定输入
void AddStruct(const AnsiString &);
bool AddUBO(DescriptorSetType type,const UBODescriptor *sd);
bool AddSampler(DescriptorSetType type,const SamplerDescriptor *sd);

View File

@@ -166,24 +166,24 @@ namespace hgl
{
PrimitiveCreater rc(db,vil);
if(!rc.Init(((pgci->grid_size.width+1)+(pgci->grid_size.height+1))*2))
if(!rc.Init(((pgci->grid_size.Width()+1)+(pgci->grid_size.Height()+1))*2))
return(nullptr);
AutoDelete<VB3f> vertex=rc.AccessVAD<VB3f>(VAN::Position);
const float right=float(pgci->grid_size.width)/2.0f;
const float right=float(pgci->grid_size.Width())/2.0f;
const float left =-right;
const float bottom=float(pgci->grid_size.height)/2.0f;
const float bottom=float(pgci->grid_size.Height())/2.0f;
const float top =-bottom;
for(int row=0;row<=pgci->grid_size.height;row++)
for(int row=0;row<=pgci->grid_size.Height();row++)
{
vertex->WriteLine( Vector3f(left ,top+row,0),
Vector3f(right,top+row,0));
}
for(int col=0;col<=pgci->grid_size.width;col++)
for(int col=0;col<=pgci->grid_size.Width();col++)
{
vertex->WriteLine(Vector3f(left+col,top, 0),
Vector3f(left+col,bottom,0));
@@ -192,17 +192,17 @@ namespace hgl
AutoDelete<VB1f> lum=rc.AccessVAD<VB1f>(VAN::Luminance);
if(lum)
{
for(int row=0;row<=pgci->grid_size.height;row++)
for(int row=0;row<=pgci->grid_size.Height();row++)
{
if((row%pgci->sub_count.height)==0)
if((row%pgci->sub_count.Height())==0)
lum->RepeatWrite(pgci->sub_lum,2);
else
lum->RepeatWrite(pgci->lum,2);
}
for(int col=0;col<=pgci->grid_size.width;col++)
for(int col=0;col<=pgci->grid_size.Width();col++)
{
if((col%pgci->sub_count.width)==0)
if((col%pgci->sub_count.Width())==0)
lum->RepeatWrite(pgci->sub_lum,2);
else
lum->RepeatWrite(pgci->lum,2);
@@ -483,9 +483,9 @@ namespace hgl
if(np)
{
*np=+x;++np;
*np=-y;++np;
*np=+z;++np;
*np=x;++np;
*np=y;++np;
*np=z;++np;
}
if(tcp)
@@ -712,7 +712,7 @@ namespace hgl
// NOTE: cos (2PIx) = cos (x) and sin (2PIx) = sin (x) so, we can use this formula
// normal = {cos(2PIs)cos(2PIt) , sin(2PIs)cos(2PIt) ,sin(2PIt)}
*np = +cos2PIs * cos2PIt; ++np;
*np = -sin2PIt; ++np;
*np = +sin2PIt; ++np;
*np = +sin2PIs * cos2PIt; ++np;
}
@@ -943,7 +943,7 @@ namespace hgl
if(np)
{
*np = cos(currentAngle); ++np;
*np = sin(currentAngle); ++np;
*np = -sin(currentAngle); ++np;
*np = 0.0f; ++np;
}
@@ -1112,7 +1112,7 @@ namespace hgl
if(np)
{
*np = h / l * cos(currentAngle); ++np;
*np = h / l * sin(currentAngle); ++np;
*np =-h / l * sin(currentAngle); ++np;
*np = r / l; ++np;
}

View File

@@ -62,6 +62,7 @@ namespace
VkResult CreateDebugUtilsMessengerEXT(VkInstance instance,const VkDebugUtilsMessengerCreateInfoEXT *pCreateInfo,const VkAllocationCallbacks *pAllocator,VkDebugUtilsMessengerEXT *pDebugMessenger)
{
auto func=(PFN_vkCreateDebugUtilsMessengerEXT)vkGetInstanceProcAddr(instance,"vkCreateDebugUtilsMessengerEXT");
if(func)
{
return func(instance,pCreateInfo,pAllocator,pDebugMessenger);
@@ -75,6 +76,7 @@ namespace
void DestroyDebugUtilsMessengerEXT(VkInstance instance,VkDebugUtilsMessengerEXT debugMessenger,const VkAllocationCallbacks *pAllocator)
{
auto func=(PFN_vkDestroyDebugUtilsMessengerEXT)vkGetInstanceProcAddr(instance,"vkDestroyDebugUtilsMessengerEXT");
if(func)
{
func(instance,debugMessenger,pAllocator);
@@ -85,10 +87,8 @@ namespace
VkDebugUtilsMessageTypeFlagsEXT messageType,
const VkDebugUtilsMessengerCallbackDataEXT *pCallbackData)
{
if(messageSeverity&VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT)
std::cerr<<"[ERROR] "; else
if(messageSeverity&VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT)
std::cerr<<"[WARNING] "; else
if(messageSeverity&VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT) std::cerr<<"[ERROR] "; else
if(messageSeverity&VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT) std::cerr<<"[WARNING] "; else
if(messageSeverity&VK_DEBUG_UTILS_MESSAGE_SEVERITY_INFO_BIT_EXT) std::cerr<<"[INFO] "; else
if(messageSeverity&VK_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT) std::cerr<<"[VERBOSE] "; else
std::cerr<<"[Validation layer] ";
@@ -147,10 +147,8 @@ namespace
{
const char *obj_type_name=GetVkDebugReportObjectTypename(objType);
if(msgFlags&VK_DEBUG_REPORT_ERROR_BIT_EXT)
std::cerr<<"[ERROR:"; else
if(msgFlags&VK_DEBUG_REPORT_WARNING_BIT_EXT)
std::cerr<<"[WARNING:"; else
if(msgFlags&VK_DEBUG_REPORT_ERROR_BIT_EXT) std::cerr<<"[ERROR:"; else
if(msgFlags&VK_DEBUG_REPORT_WARNING_BIT_EXT) std::cerr<<"[WARNING:"; else
if(msgFlags&VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT)std::cerr<<"[PERFORMANCE WARNING:"; else
if(msgFlags&VK_DEBUG_REPORT_INFORMATION_BIT_EXT) std::cerr<<"[INFO:"; else
if(msgFlags&VK_DEBUG_REPORT_DEBUG_BIT_EXT) std::cerr<<"[DEBUG:";

View File

@@ -3,6 +3,26 @@
#include<hgl/graph/VKMaterialInstance.h>
VK_NAMESPACE_BEGIN
void DescriptorBinding::BindUBO(MaterialParameters *mp,const BindingMap &binding_map,bool dynamic)
{
if (binding_map.GetCount() <= 0)return;
DeviceBuffer* buf = nullptr;
const auto *dp =binding_map.GetDataList();
const uint count =binding_map.GetCount();
for(uint i=0;i<count;i++)
{
buf=GetUBO((*dp)->key);
if(buf)
mp->BindUBO((*dp)->value,buf,dynamic);
++dp;
}
}
bool DescriptorBinding::Bind(Material *mtl)
{
if(!mtl)
@@ -15,47 +35,13 @@ bool DescriptorBinding::Bind(Material *mtl)
const BindingMapArray &bma=mp->GetBindingMap();
const BindingMap &ubo_bm=bma[VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER];
const BindingMap &ubo_dynamic_bm=bma[VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC];
// const BindingMap &ssbo_bm=bma[VK_DESCRIPTOR_TYPE_STORAGE_BUFFER];
// const BindingMap &ssbo_dynamic_bm=bma[VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC];
// const BindingMap &texture_bm=bma[VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER];
DeviceBuffer *buf=nullptr;
if(ubo_bm.GetCount()>0)
{
const auto *dp=ubo_bm.GetDataList();
const uint count=ubo_bm.GetCount();
for(uint i=0;i<count;i++)
{
buf=GetUBO((*dp)->key);
if(buf)
mp->BindUBO((*dp)->value,buf,false);
++dp;
}
}
if(ubo_dynamic_bm.GetCount()>0)
{
const auto *dp=ubo_dynamic_bm.GetDataList();
const uint count=ubo_dynamic_bm.GetCount();
for(uint i=0;i<count;i++)
{
buf=GetUBO((*dp)->key);
if(buf)
mp->BindUBO((*dp)->value,buf,true);
++dp;
}
}
BindUBO(mp,bma[VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER],false);
BindUBO(mp,bma[VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC],true);
mp->Update();
return(true);

View File

@@ -90,6 +90,10 @@ void CheckInstanceLayer(CharPointerList &layer_list,CreateInstanceLayerInfo *lay
VK_LAYER_KHRONOS_ADD(validation)
VK_LAYER_KHRONOS_ADD(profiles)
#define VK_LAYER_AMD_ADD(name) VK_LAYER_CHECK(amd,"AMD",name)
VK_LAYER_AMD_ADD(switchable_graphics)
#define VK_LAYER_NV_ADD(name) VK_LAYER_CHECK(nv,"NV",name)
VK_LAYER_NV_ADD(optimus)

View File

@@ -175,6 +175,7 @@ Material *RenderResource::CreateMaterial(const mtl::MaterialCreateInfo *mci)
Add(mtl);
static_descriptor.Bind(mtl);
global_descriptor.Bind(mtl);
material_by_name.Add(mtl_name,mtl);

View File

@@ -35,8 +35,10 @@ bool Std2DMaterial::CustomVertexShader(ShaderCreateInfoVertex *vsc)
if(cfg->coordinate_system==CoordinateSystem2D::Ortho)
{
mci->AddStruct(SBS_ViewportInfo);
mci->AddUBO(VK_SHADER_STAGE_ALL_GRAPHICS,
DescriptorSetType::Global,
DescriptorSetType::Static,
SBS_ViewportInfo);
}

View File

@@ -4,6 +4,8 @@
STD_MTL_NAMESPACE_BEGIN
const char *GetUBOCodes(const AccumMemoryManager::Block *block);
namespace
{
class Std2DMaterialLoader:public Std2DMaterial
@@ -36,6 +38,18 @@ namespace
mfd->mi.shader_stage_flag_bits);
}
for(const auto ubo:mfd->ubo_list)
{
const char *ubo_codes=GetUBOCodes(ubo.block);
mci->AddStruct(ubo.struct_name,ubo_codes);
mci->AddUBO(ubo.shader_stage_flag_bits,
ubo.set,
ubo.struct_name,
ubo.name);
}
return true;
}
@@ -59,12 +73,12 @@ namespace
bool CustomVertexShader(ShaderCreateInfoVertex *vsc) override
{
if(!Std2DMaterial::CustomVertexShader(vsc))
return(false);
for(auto &ua:mfd->vi)
vsc->AddInput(ua.vat,ua.name);
if(!Std2DMaterial::CustomVertexShader(vsc))
return(false);
return CommonProc(VK_SHADER_STAGE_VERTEX_BIT,vsc);
}

View File

@@ -30,15 +30,20 @@ bool Std3DMaterial::CustomVertexShader(ShaderCreateInfoVertex *vsc)
else
vsc->AddFunction(cfg->camera?func::GetPosition3DCamera:func::GetPosition3D);
//if(cfg->camera
// &&cfg->local_to_world)
//{
// vsc->AddFunction(func::GetNormalMatrix);
// vsc->AddFunction(func::GetNormal);
//}
if(cfg->camera
&&cfg->local_to_world)
{
vsc->AddFunction(func::GetNormalMatrix);
vsc->AddFunction(func::GetNormal);
if(vsc->hasInput(VAN::Normal))
vsc->AddFunction(func::GetNormalVS);
}
mci->AddStruct(SBS_ViewportInfo);
mci->AddUBO(VK_SHADER_STAGE_ALL_GRAPHICS,
DescriptorSetType::Global,
DescriptorSetType::Static,
SBS_ViewportInfo);
return(true);

View File

@@ -4,12 +4,17 @@
STD_MTL_NAMESPACE_BEGIN
const char *GetUBOCodes(const AccumMemoryManager::Block *block);
namespace {
class Std3DMaterialLoader : public Std3DMaterial {
class Std3DMaterialLoader : public Std3DMaterial
{
protected:
material_file::MaterialFileData* mfd;
material_file::MaterialFileData *mfd;
public:
Std3DMaterialLoader(material_file::MaterialFileData* data, const Material3DCreateConfig* cfg)
: Std3DMaterial(cfg)
{
@@ -26,10 +31,23 @@ public:
if (!Std3DMaterial::BeginCustomShader())
return (false);
if (mfd->mi.mi_bytes > 0) {
mci->SetMaterialInstance(mfd->mi.code,
mfd->mi.mi_bytes,
mfd->mi.shader_stage_flag_bits);
for(const auto ubo:mfd->ubo_list)
{
const char *ubo_codes=GetUBOCodes(ubo.block);
mci->AddStruct(ubo.struct_name,ubo_codes);
mci->AddUBO(ubo.shader_stage_flag_bits,
ubo.set,
ubo.struct_name,
ubo.name);
}
if (mfd->mi.mi_bytes > 0)
{
mci->SetMaterialInstance( mfd->mi.code,
mfd->mi.mi_bytes,
mfd->mi.shader_stage_flag_bits);
}
return true;
@@ -55,12 +73,12 @@ public:
bool CustomVertexShader(ShaderCreateInfoVertex* vsc) override
{
if (!Std3DMaterial::CustomVertexShader(vsc))
return (false);
for (auto& ua : mfd->vi)
vsc->AddInput(ua.vat, ua.name);
if (!Std3DMaterial::CustomVertexShader(vsc))
return (false);
return CommonProc(VK_SHADER_STAGE_VERTEX_BIT, vsc);
}

View File

@@ -36,7 +36,8 @@ SOURCE_GROUP("GLSL Compiler" FILES ${GLSL_COMPILER_SOURCE})
set(STD_MTL_HEADER_PATH ${ROOT_INCLUDE_PATH}/hgl/graph/mtl)
SET(SHADERGEN_COMMON_FILES ${STD_MTL_HEADER_PATH}/UBOCommon.h
SET(SHADERGEN_COMMON_FILES ${STD_MTL_HEADER_PATH}/UniformBuffer.h
${STD_MTL_HEADER_PATH}/UBOCommon.h
${STD_MTL_HEADER_PATH}/SamplerName.h
common/MFCommon.h
common/MFGetPosition.h
@@ -49,6 +50,8 @@ SOURCE_GROUP("Common" FILES ${SHADERGEN_COMMON_FILES})
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
SET(BLINN_PHONG_HEADER_FILES ${STD_MTL_HEADER_PATH}/BlinnPhong.h)
SET(STD_MTL_2D_SOURCE_FILES ${STD_MTL_HEADER_PATH}/Material2DCreateConfig.h
2d/Std2DMaterial.h
2d/Std2DMaterial.cpp
@@ -76,6 +79,9 @@ SET(STD_MTL_SOURCE ${STD_MTL_HEADER_PATH}/MaterialConfig.h
MaterialFileLoader.cpp)
SOURCE_GROUP("Standard Material" FILES ${STD_MTL_SOURCE})
SOURCE_GROUP("Standard Material\\Light Model\\Blinn Phong" FILES ${BLINN_PHONG_HEADER_FILES})
SOURCE_GROUP("Standard Material\\2D" FILES ${STD_MTL_2D_SOURCE_FILES})
SOURCE_GROUP("Standard Material\\3D" FILES ${STD_MTL_3D_SOURCE_FILES})
@@ -93,6 +99,7 @@ add_cm_library(ULRE.ShaderGen "ULRE" ${DESC_INFO_HEADER_FILES}
${SHADERGEN_COMMON_FILES}
${SHADER_LIBRARY_FILES}
${STD_MTL_SOURCE}
${BLINN_PHONG_HEADER_FILES}
${STD_MTL_2D_SOURCE_FILES}
${STD_MTL_3D_SOURCE_FILES}
)

View File

@@ -9,12 +9,6 @@ using namespace hgl;
using namespace hgl::graph;
STD_MTL_NAMESPACE_BEGIN
namespace
{
const AnsiString *MF_HandoverMI=nullptr;
}//namespace
MaterialCreateInfo::MaterialCreateInfo(const MaterialCreateConfig *mc)
{
config=mc;
@@ -39,9 +33,6 @@ MaterialCreateInfo::MaterialCreateInfo(const MaterialCreateConfig *mc)
l2w_shader_stage=0;
l2w_ubo=nullptr;
}
if(!MF_HandoverMI)
MF_HandoverMI=LoadShader("HandoverMI");
}
bool MaterialCreateInfo::AddStruct(const AnsiString &struct_name,const AnsiString &codes)
@@ -52,12 +43,12 @@ bool MaterialCreateInfo::AddStruct(const AnsiString &struct_name,const AnsiStrin
return mdi.AddStruct(struct_name,codes);
}
bool MaterialCreateInfo::AddUBO(const VkShaderStageFlagBits flag_bit,const DescriptorSetType set_type,const AnsiString &type_name,const AnsiString &name)
bool MaterialCreateInfo::AddUBO(const VkShaderStageFlagBits flag_bit,const DescriptorSetType set_type,const AnsiString &struct_name,const AnsiString &name)
{
if(!shader_map.KeyExist(flag_bit))
return(false);
if(!mdi.hasStruct(type_name))
if(!mdi.hasStruct(struct_name))
return(false);
ShaderCreateInfo *sc=shader_map[flag_bit];
@@ -69,7 +60,7 @@ bool MaterialCreateInfo::AddUBO(const VkShaderStageFlagBits flag_bit,const Descr
if(ubo)
{
if(ubo->type!=type_name)
if(ubo->type!=struct_name)
return(false);
ubo->stage_flag|=flag_bit;
@@ -80,13 +71,35 @@ bool MaterialCreateInfo::AddUBO(const VkShaderStageFlagBits flag_bit,const Descr
{
ubo=new UBODescriptor();
ubo->type=type_name;
ubo->type=struct_name;
hgl::strcpy(ubo->name,DESCRIPTOR_NAME_MAX_LENGTH,name);
return sc->sdm->AddUBO(set_type,mdi.AddUBO(flag_bit,set_type,ubo));
}
}
bool MaterialCreateInfo::AddUBO(const uint32_t flag_bits,const DescriptorSetType &set_type,const AnsiString &struct_name,const AnsiString &name)
{
if(flag_bits==0)return(false); //没有任何SHADER用?
if(!mdi.hasStruct(struct_name))
return(false);
uint result=0;
VkShaderStageFlagBits bit;
for(int i=0;i<shader_map.GetCount();i++)
{
shader_map.GetKey(i,bit);
if(flag_bits&bit)
if(AddUBO(bit,set_type,struct_name,name))
++result;
}
return(result==shader_map.GetCount());
}
bool MaterialCreateInfo::AddSampler(const VkShaderStageFlagBits flag_bit,const DescriptorSetType set_type,const SamplerType &st,const AnsiString &name)
{
if(!shader_map.KeyExist(flag_bit))
@@ -123,28 +136,6 @@ bool MaterialCreateInfo::AddSampler(const VkShaderStageFlagBits flag_bit,const D
}
}
bool MaterialCreateInfo::AddUBO(const uint32_t flag_bits,const DescriptorSetType &set_type,const ShaderBufferSource &ss)
{
if(flag_bits==0)return(false); //没有任何SHADER用
if(!mdi.hasStruct(ss.struct_name))
mdi.AddStruct(ss.struct_name,ss.codes);
uint result=0;
VkShaderStageFlagBits bit;
for(int i=0;i<shader_map.GetCount();i++)
{
shader_map.GetKey(i,bit);
if(flag_bits&bit)
if(AddUBO(bit,set_type,ss.struct_name,ss.name))
++result;
}
return(result==shader_map.GetCount());
}
namespace
{
UBODescriptor *CreateUBODescriptor(const ShaderBufferSource &sbs,const uint32_t flag_bits)
@@ -255,12 +246,8 @@ bool MaterialCreateInfo::CreateShader()
return(false);
if(sc->GetShaderStage()<mi_shader_stage)
{
sc->AddMaterialInstanceOutput();
sc->AddFunction(MF_HandoverMI);
}
sc->CreateShader(last);
last=sc;

View File

@@ -1,16 +1,18 @@
#pragma once
#include<hgl/type/Map.h>
#include<hgl/type/StringList.h>
#include<hgl/type/AccumMemoryManager.h>
#include<hgl/graph/VKShaderStage.h>
#include<hgl/graph/VKSamplerType.h>
#include<hgl/graph/VKPrimitiveType.h>
#include<hgl/graph/VKDescriptorSetType.h>
namespace material_file
{
using namespace hgl;
using namespace hgl::graph;
struct UniformAttrib
struct ShaderIOAttrib
{
VAT vat;
@@ -34,16 +36,32 @@ namespace material_file
SamplerType type;
};
struct UBOData
{
char struct_name[SHADER_RESOURCE_NAME_MAX_LENGTH];
char name[SHADER_RESOURCE_NAME_MAX_LENGTH];
char filename[HGL_MAX_PATH];
uint32_t shader_stage_flag_bits;
hgl::graph::DescriptorSetType set;
AccumMemoryManager::Block *block;
};
using UBODataList=List<UBOData>;
struct ShaderData
{
VkShaderStageFlagBits shader_stage;
VkShaderStageFlagBits shader_stage;
const char *code;
uint code_length;
const char * code;
uint code_length;
List<UniformAttrib> output;
List<ShaderIOAttrib> output;
List<SamplerData> sampler;
List<SamplerData> sampler;
public:
@@ -89,7 +107,9 @@ namespace material_file
MaterialInstanceData mi{};
List<UniformAttrib> vi; ///<Vertex Input
List<ShaderIOAttrib> vi; ///<Vertex Input
UBODataList ubo_list;
ShaderDataMap shader;

View File

@@ -7,6 +7,9 @@
#include<hgl/io/TextInputStream.h>
#include<hgl/filesystem/FileSystem.h>
#include<hgl/type/AccumMemoryManager.h>
#include<hgl/io/FileAccess.h>
#include"MaterialFileData.h"
STD_MTL_NAMESPACE_BEGIN
@@ -63,19 +66,140 @@ namespace
return MaterialFileBlock::None;
}
const uint32_t ShaderStageParse(char *text,const char *ep)
{
uint32_t shader_stage_flag_bits=0;
char *sp;
while(*text==' '||*text=='\t')++text;
while(text<ep)
{
sp=text;
while(hgl::isalpha(*text))
++text;
shader_stage_flag_bits|=GetShaderStageFlagBits(sp,text-sp);
++text;
}
return shader_stage_flag_bits;
}
int ClipCodeString(char *str,const int max_len,const char *text)
{
while(*text==' '||*text=='\t')++text;
const char *sp=text;
while(hgl::iscodechar(*text))++text;
hgl::strcpy(str,max_len,sp,text-sp);
return text-sp;
}
int ClipFilename(char *str,const int max_len,const char *text)
{
while(*text==' '||*text=='\t')++text;
const char *sp=text;
while(hgl::isfilenamechar(*text))++text;
hgl::strcpy(str,max_len,sp,text-sp);
return text-sp;
}
struct UBOParse:public TextParse
{
UBOData ubo_data;
public:
void Clear()
{
hgl_zero(ubo_data);
}
bool OnLine(char *text,const int len) override
{
if(!text||!*text||len<=0)
return(false);
if(*text=='{')
{
++text;
while(*text=='\r'||*text=='\n')++text;
return(false);
}
if(*text=='}')
{
*text=0;
return(true);
}
while(*text==' '||*text=='\t')++text;
if(text[0]=='/'&&text[1]=='/')
return(false);
if(hgl::stricmp(text,"File ",5)==0)
{
ClipFilename(ubo_data.filename,sizeof(ubo_data.filename),text+5);
}
else
if(hgl::stricmp(text,"Struct ",7)==0)
{
ClipCodeString(ubo_data.struct_name,sizeof(ubo_data.struct_name),text+7);
}
else
if(hgl::stricmp(text,"Name ",5)==0)
{
ClipCodeString(ubo_data.name,sizeof(ubo_data.name),text+5);
}
else
if(hgl::stricmp(text,"Stage ",6)==0)
{
ubo_data.shader_stage_flag_bits=ShaderStageParse(text+6,text+len);
}
else
if(hgl::stricmp(text,"Set ",4)==0)
{
char set_name[32];
ClipCodeString(set_name,sizeof(set_name),text+4);
ubo_data.set=GetDescriptorSetType(set_name);
}
return(false);
}
};//struct UBOParse
struct MaterialBlockParse:public TextParse
{
MaterialFileBlock state;
AnsiStringList *require_list=nullptr;
UBODataList *ubo_list=nullptr;
bool ubo=false;
UBOParse ubo_parse;
public:
MaterialBlockParse(AnsiStringList *asl)
MaterialBlockParse(AnsiStringList *asl,UBODataList *udl)
{
state=MaterialFileBlock::None;
require_list=asl;
ubo_list=udl;
}
bool OnLine(char *text,const int len) override
@@ -85,6 +209,19 @@ namespace
char *ep=text+len;
if(ubo)
{
if(ubo_parse.OnLine(text,len))
{
ubo_list->Add(ubo_parse.ubo_data);
ubo_parse.Clear();
ubo=false;
}
return(true);
}
if(hgl::stricmp(text,"Require ",8)==0)
{
text+=8;
@@ -102,6 +239,11 @@ namespace
sp=text;
}
}
else
if(hgl::stricmp(text,"UBO",3)==0)
{
ubo=true;
}
return(true);
}
@@ -195,31 +337,14 @@ namespace
else
if(hgl::stricmp(text,"Stage ",6)==0)
{
const char *ep=text+len;
const char *sp;
text+=6;
while(*text==' '||*text=='\t')++text;
while(text<ep)
{
sp=text;
while(hgl::isalpha(*text))
++text;
shader_stage_flag_bits|=GetShaderStageFlagBits(sp,text-sp);
++text;
}
shader_stage_flag_bits=ShaderStageParse(text+6,text+len);
}
return(true);
}
};//struct MaterialInstanceBlockParse
bool ParseUniformAttrib(UniformAttrib *ua,const char *str)
bool ParseUniformAttrib(ShaderIOAttrib *ua,const char *str)
{
const char *sp;
@@ -242,11 +367,11 @@ namespace
struct VertexInputBlockParse:public TextParse
{
List<UniformAttrib> *vi_list=nullptr;
List<ShaderIOAttrib> *vi_list=nullptr;
public:
VertexInputBlockParse(List<UniformAttrib> *ual)
VertexInputBlockParse(List<ShaderIOAttrib> *ual)
{
vi_list=ual;
}
@@ -256,7 +381,7 @@ namespace
if(!text||!*text||len<=0)
return(false);
UniformAttrib ua;
ShaderIOAttrib ua;
if(ParseUniformAttrib(&ua,text))
vi_list->Add(ua);
@@ -307,7 +432,7 @@ namespace
return(true);
}
UniformAttrib ua;
ShaderIOAttrib ua;
if(ParseUniformAttrib(&ua,text))
shader_data->output.Add(ua);
@@ -461,7 +586,7 @@ namespace
state=GetMaterialFileState(text+1,len-1);
if(state==MaterialFileBlock::Material)
parse=new MaterialBlockParse(&(mfd->require_list));
parse=new MaterialBlockParse(&(mfd->require_list),&(mfd->ubo_list));
else
if(state==MaterialFileBlock::MaterialInstance)
parse=new MaterialInstanceBlockParse(&(mfd->mi));
@@ -519,11 +644,63 @@ namespace
};
}//namespace MaterialFile
namespace
{
constexpr const os_char HGL_SHADER_LIBRARY_FOLDER[]=OS_TEXT("ShaderLibrary");
AccumMemoryManager ubo_memory;
hgl::Map<OSString,AccumMemoryManager::Block *> ubo_codes_map;
AccumMemoryManager::Block *LoadUBO2Block(const OSString &filename)
{
AccumMemoryManager::Block *block;
if(ubo_codes_map.Get(filename,block))
return block;
hgl::io::FileAccess fa;
if(!fa.OpenRead(filename))
{
ubo_codes_map.Add(filename,nullptr);
return(nullptr);
}
const int64 size=fa.GetSize();
block=ubo_memory.Acquire(size+1);
char *ptr=(char *)ubo_memory.Access(block);
fa.Read(ptr,size);
ptr[size]=0;
ptr+=size-1;
while(*ptr=='\r'||*ptr=='\n')
{
*ptr=0;
--ptr;
}
ubo_codes_map.Add(filename,block);
return block;
}
}//namespace
const char *GetUBOCodes(const AccumMemoryManager::Block *block)
{
if(!block)return nullptr;
return (const char *)ubo_memory.Access(block);
}
MaterialFileData *LoadMaterialDataFromFile(const AnsiString &mtl_filename)
{
const OSString mtl_osfn=ToOSString(mtl_filename+".mtl");
const OSString mtl_osfn=filesystem::FixFilename(ToOSString(mtl_filename+".mtl"));
const OSString mtl_os_filename=filesystem::MergeFilename(OS_TEXT("ShaderLibrary"),mtl_osfn);
const OSString mtl_os_filename=filesystem::MergeFilename(HGL_SHADER_LIBRARY_FOLDER,mtl_osfn);
if(!filesystem::FileExist(mtl_os_filename))
return nullptr;
@@ -543,6 +720,32 @@ MaterialFileData *LoadMaterialDataFromFile(const AnsiString &mtl_filename)
if(!tis.Run())
return nullptr;
if(mfd->ubo_list.GetCount()<=0)
return mfd;
const OSString mtl_path=filesystem::ClipPathname(mtl_os_filename,false);
OSString ubo_os_fn;
OSString ubo_os_full_filename;
for(UBOData &ud:mfd->ubo_list)
{
ubo_os_fn=filesystem::FixFilename(ToOSString(ud.filename));
if(ubo_os_fn.GetFirstChar()==HGL_DIRECTORY_SEPARATOR)
ubo_os_full_filename=filesystem::MergeFilename(HGL_SHADER_LIBRARY_FOLDER,ubo_os_fn);
else
ubo_os_full_filename=filesystem::MergeFilename(mtl_path,ubo_os_fn);
ud.block=LoadUBO2Block(ubo_os_full_filename);
if(!ud.block)
{
delete mfd;
return nullptr;
}
}
return mfd;
}
STD_MTL_NAMESPACE_END

View File

@@ -1,4 +1,4 @@
#include<hgl/shadergen/ShaderCreateInfo.h>
#include<hgl/shadergen/ShaderCreateInfo.h>
#include<hgl/shadergen/ShaderDescriptorInfo.h>
#include<hgl/graph/mtl/UBOCommon.h>
#include<hgl/log/LogInfo.h>
@@ -9,12 +9,6 @@
namespace hgl{namespace graph{
namespace
{
const AnsiString *ShaderFileHeader=nullptr;
const AnsiString *MF_GetMI=nullptr;
}//namespace
ShaderCreateInfo::ShaderCreateInfo(VkShaderStageFlagBits ss,MaterialDescriptorInfo *m)
{
shader_stage=ss;
@@ -25,9 +19,6 @@ ShaderCreateInfo::ShaderCreateInfo(VkShaderStageFlagBits ss,MaterialDescriptorIn
define_macro_max_length=0;
define_value_max_length=0;
if(!ShaderFileHeader)ShaderFileHeader =mtl::LoadShader("ShaderHeader");
if(!MF_GetMI )MF_GetMI =mtl::LoadShader("GetMI");
}
ShaderCreateInfo::~ShaderCreateInfo()
@@ -163,12 +154,22 @@ bool ShaderCreateInfo::ProcSubpassInput()
return(true);
}
namespace
{
constexpr const char MF_GetMI_VS []="\nMaterialInstance GetMI(){return mtl.mi[Assign.y];}\n";
constexpr const char MF_GetMI_Other []="\nMaterialInstance GetMI(){return mtl.mi[Input.MaterialInstanceID];}\n";
constexpr const char MF_HandoverMI_VS[]= "\nvoid HandoverMI(){Output.MaterialInstanceID=Assign.y;}\n";
constexpr const char MF_HandoverMI_GS[]= "\nvoid HandoverMI(){Output.MaterialInstanceID=Input[0].MaterialInstanceID;}\n";
constexpr const char MF_HandoverMI_OTHER[]= "\nvoid HandoverMI(){Output.MaterialInstanceID=Input.MaterialInstanceID;}\n";
}//namespace
void ShaderCreateInfo::SetMaterialInstance(UBODescriptor *ubo,const AnsiString &mi)
{
sdm->AddUBO(DescriptorSetType::PerMaterial,ubo);
sdm->AddStruct(mtl::MaterialInstanceStruct);
AddFunction(MF_GetMI);
AddFunction(shader_stage==VK_SHADER_STAGE_VERTEX_BIT?MF_GetMI_VS:MF_GetMI_Other);
mi_codes=mi;
}
@@ -176,6 +177,10 @@ void ShaderCreateInfo::SetMaterialInstance(UBODescriptor *ubo,const AnsiString &
void ShaderCreateInfo::AddMaterialInstanceOutput()
{
AddOutput(VAT_UINT,mtl::func::MaterialInstanceID,Interpolation::Flat);
if(shader_stage==VK_SHADER_STAGE_VERTEX_BIT) AddFunction(MF_HandoverMI_VS);else
if(shader_stage==VK_SHADER_STAGE_GEOMETRY_BIT) AddFunction(MF_HandoverMI_GS);else
AddFunction(MF_HandoverMI_OTHER);
}
void ShaderCreateInfo::SetLocalToWorld(UBODescriptor *ubo)
@@ -386,13 +391,21 @@ bool ShaderCreateInfo::ProcSampler()
bool ShaderCreateInfo::CreateShader(ShaderCreateInfo *last_sc)
{
if(!ShaderFileHeader)
return(false);
if(main_function.IsEmpty())
return(false);
final_shader=ShaderFileHeader->c_str();
final_shader=R"(
#version 460 core
#define VertexShader 0x01
#define TessControlShader 0x02
#define TeseEvalShader 0x04
#define GeometryShader 0x08
#define FragmentShader 0x10
#define ComputeShader 0x20
#define TaskShader 0x40
#define MeshShader 0x80
)";
{
char ss_hex_str[9];
@@ -430,10 +443,12 @@ bool ShaderCreateInfo::CreateShader(ShaderCreateInfo *last_sc)
for(const char *str:function_list)
final_shader+=str;
final_shader+="\n";
final_shader+=main_function;
#ifdef _DEBUG
//想办法存成文件或是输出行号,以方便出错了调试
LOG_INFO(AnsiString(GetShaderStageName(shader_stage))+" shader: \n"+final_shader);
#endif//_DEBUG

View File

@@ -8,14 +8,8 @@
#include"ShaderLibrary.h"
VK_NAMESPACE_BEGIN
namespace
{
const AnsiString *MF_GetLocalToWorld=nullptr;
}//namespace
ShaderCreateInfoVertex::ShaderCreateInfoVertex(MaterialDescriptorInfo *m):ShaderCreateInfo(VK_SHADER_STAGE_VERTEX_BIT,m)
{
if(!MF_GetLocalToWorld)MF_GetLocalToWorld=mtl::LoadShader("GetLocalToWorld");
}
int ShaderCreateInfoVertex::AddInput(const VAT &type,const AnsiString &name,const VkVertexInputRate input_rate,const VertexInputGroup &group)
@@ -43,12 +37,22 @@ int ShaderCreateInfoVertex::AddInput(const AnsiString &type,const AnsiString &na
return AddInput(vat,name,input_rate,group);
}
int ShaderCreateInfoVertex::hasInput(const char *name)
{
return sdm->hasInput(name);
}
void ShaderCreateInfoVertex::AddJoint()
{
AddInput(VAT_UVEC4, VAN::JointID, VK_VERTEX_INPUT_RATE_VERTEX,VertexInputGroup::JointID);
AddInput(VAT_VEC4, VAN::JointWeight,VK_VERTEX_INPUT_RATE_VERTEX,VertexInputGroup::JointWeight);
}
namespace
{
constexpr const char MF_GetLocalToWorld[]="\nmat4 GetLocalToWorld(){return l2w.mats[Assign.x];}\n";
}
void ShaderCreateInfoVertex::AddAssign()
{
AddInput( ASSIGN_VAT_FMT,

View File

@@ -12,13 +12,13 @@ ShaderDescriptorInfo::ShaderDescriptorInfo(VkShaderStageFlagBits flag_bit)
namespace
{
bool Find(ShaderAttributeArray &sad,const ShaderAttribute *ss)
bool Find(const ShaderAttributeArray &sad,const char *name)
{
if(sad.count<=0)
return(false);
for(uint i=0;i<sad.count;i++)
if(hgl::strcmp(sad.items[i].name,ss->name)==0)
if(hgl::strcmp(sad.items[i].name,name)==0)
return(true);
return(false);
@@ -29,7 +29,7 @@ bool ShaderDescriptorInfo::AddInput(ShaderAttribute *ss)
{
if(!ss)return(false);
if(Find(stage_io.input,ss))return(false);
if(Find(stage_io.input,ss->name))return(false);
ss->location=stage_io.input.count;
@@ -37,11 +37,20 @@ bool ShaderDescriptorInfo::AddInput(ShaderAttribute *ss)
return(true);
}
bool ShaderDescriptorInfo::hasInput(const char *name)const
{
if(!name||!*name)return(false);
return Find(stage_io.input,name);
}
bool ShaderDescriptorInfo::AddOutput(ShaderAttribute *ss)
{
if(!ss)return(false);
if(Find(stage_io.output,ss))return(false);
if(Find(stage_io.output,ss->name))return(false);
ss->location=stage_io.output.count;

View File

@@ -17,6 +17,13 @@ vec3 GetNormal(mat3 normal_matrix,vec3 normal)
{
return normalize(normal_matrix*normal);
}
)";
constexpr const char *GetNormalVS=R"(
vec3 GetNormal()
{
return normalize(mat3(camera.view*GetLocalToWorld())*Normal);
}
)";
}//namespace func
STD_MTL_NAMESPACE_END