update codes...but can't compile

This commit is contained in:
HuYingzhuo(hugo/hyzboy) 2023-04-20 21:49:48 +08:00
parent e488b4c3d3
commit 011fbdb55d
19 changed files with 141 additions and 70 deletions

2
CMCore

@ -1 +1 @@
Subproject commit 3b1a62eb78ed7cf3d6d186b8b7e4c7d4b57eba18 Subproject commit a377fe8d05d9486379c1da6007a940a90898e956

@ -1 +1 @@
Subproject commit fd78d7e14b95e01e37eb5e631cbd6967e284fb95 Subproject commit fe635b5851cd651f570a88b84a9353edf18a55ed

2
CMUtil

@ -1 +1 @@
Subproject commit 9f94d5082bbbba65d55ae259deebbfc72b4a672a Subproject commit f4d19fc898e9434e93f77843975369744e59350a

View File

@ -0,0 +1,46 @@
#ifndef HGL_GRAPH_MATERIAL_VERTEX_FORMAT_INCLUDE
#define HGL_GRAPH_MATERIAL_VERTEX_FORMAT_INCLUDE
#include<hgl/type/DataType.h>
namespace hgl
{
namespace graph
{
/**
* Local 2 World
*
* 1.Push Constants
*
* 2.UBO matrix4f阵列vertex attrib中存放ID
* UBO通常情况为16k/64kmatrix4f为64字节
*
* 3.Vertex Attribute
*/
/**
*
*/
union MaterialVertexFormat
{
struct
{
uint position:3;
bool normal:1;
bool tangent:1;
bool bitangent:1;
uint color:4;
uint texcoord:4;
bool local2world:1;
bool skeleton:1;
};
uint32 format;
};//union MaterialVertexFormat
}//namespace graph
}//namespace hgl
#endif//HGL_GRAPH_MATERIAL_VERTEX_FORMAT_INCLUDE

View File

@ -0,0 +1,18 @@
#ifndef HGL_GRAPH_MTL_SHADER_BUFFER_INCLUDE
#define HGL_GRAPH_MTL_SHADER_BUFFER_INCLUDE
#include<hgl/type/DataType.h>
namespace hgl
{
namespace graph
{
struct ShaderBufferSource
{
const char *struct_name;
const char *value_name;
const char *codes;
};
}//namespace graph
}//namespace hgl
#endif//HGL_GRAPH_MTL_SHADER_BUFFER_INCLUDE

View File

@ -3,7 +3,11 @@
#define STD_MTL_NAMESPACE_BEGIN namespace hgl{namespace graph{namespace mtl{ #define STD_MTL_NAMESPACE_BEGIN namespace hgl{namespace graph{namespace mtl{
#define STD_MTL_NAMESPACE_END }}} #define STD_MTL_NAMESPACE_END }}}
#define STD_MTL_NAMESPACE_USING using namespace hgl::graph::mtl #define STD_MTL_NAMESPACE_USING using namespace hgl::graph::mtl;
#include<hgl/graph/mtl/ShaderBuffer.h>
STD_MTL_NAMESPACE_BEGIN
enum class CoordinateSystem2D enum class CoordinateSystem2D
{ {
@ -12,17 +16,8 @@ enum class CoordinateSystem2D
Ortho //左上角为0,0右下角为(width-1),(height-1) Ortho //左上角为0,0右下角为(width-1),(height-1)
}; };
namespace InlineDescriptor constexpr const ShaderBufferSource SBS_ViewportInfo=
{ {
struct ShaderStruct
{
const char *struct_name;
const char *name;
const char *codes;
};
constexpr const ShaderStruct ViewportInfo=
{
"ViewportInfo", "ViewportInfo",
"viewport", "viewport",
@ -33,10 +28,10 @@ vec2 canvas_resolution;
vec2 viewport_resolution; vec2 viewport_resolution;
vec2 inv_viewport_resolution; vec2 inv_viewport_resolution;
)" )"
}; };
constexpr const ShaderStruct CameraInfo= constexpr const ShaderBufferSource SBS_CameraInfo=
{ {
"CameraInfo", "CameraInfo",
"camera", "camera",
@ -57,5 +52,6 @@ vec3 view_line; //pos-target
vec3 world_up; vec3 world_up;
float znear,zfar;)" float znear,zfar;)"
}; };
}
STD_MTL_NAMESPACE_END

View File

@ -53,7 +53,7 @@ public:
~MaterialCreateInfo()=default; ~MaterialCreateInfo()=default;
bool AddStruct(const AnsiString &ubo_typename,const AnsiString &codes); bool AddStruct(const AnsiString &ubo_typename,const AnsiString &codes);
bool AddStruct(const InlineDescriptor::ShaderStruct &ss) bool AddStruct(const InlineDescriptor::ShaderBufferSource &ss)
{ {
return AddStruct(ss.struct_name,ss.codes); return AddStruct(ss.struct_name,ss.codes);
} }
@ -61,7 +61,7 @@ public:
bool AddUBO(const VkShaderStageFlagBits flag_bits,const DescriptorSetType set_type,const AnsiString &type_name,const AnsiString &name); 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 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 InlineDescriptor::ShaderStruct &ss) bool AddUBO(const VkShaderStageFlagBits flag_bits,const DescriptorSetType &set_type,const InlineDescriptor::ShaderBufferSource &ss)
{ {
if(!mdi.hasStruct(ss.struct_name)) if(!mdi.hasStruct(ss.struct_name))
mdi.AddStruct(ss.struct_name,ss.codes); mdi.AddStruct(ss.struct_name,ss.codes);

View File

@ -117,10 +117,10 @@ namespace hgl
const auto *sp=ssb_map.GetDataList(); const auto *sp=ssb_map.GetDataList();
for(uint i=0;i<si_count;i++) for(uint i=0;i<si_count;i++)
{ {
if((*sp)->right->vbo) if((*sp)->value->vbo)
primitive->Set((*sp)->left,(*sp)->right->vbo); primitive->Set((*sp)->key,(*sp)->value->vbo);
else else
primitive->Set((*sp)->left,db->CreateVBO((*sp)->right->data)); primitive->Set((*sp)->key,db->CreateVBO((*sp)->value->data));
++sp; ++sp;
} }

View File

@ -9,6 +9,7 @@
#include<hgl/util/sort/Sort.h> #include<hgl/util/sort/Sort.h>
/** /**
*
* *
* *
* for(material) * for(material)

View File

@ -6,6 +6,27 @@
namespace hgl namespace hgl
{ {
namespace graph
{
GPUArrayBuffer *GPUDevice::CreateUBO(const VkDeviceSize &item_length)
{
const uint unit_size=hgl_align<VkDeviceSize>(item_length,GetUBOAlign());
auto vk_ma=new VKMemoryAllocator(this,VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT,unit_size);
return(new GPUArrayBuffer(vk_ma,unit_size));
}
GPUArrayBuffer *GPUDevice::CreateSSBO(const VkDeviceSize &item_length)
{
const uint unit_size=hgl_align<VkDeviceSize>(item_length,GetSSBOAlign());
auto vk_ma=new VKMemoryAllocator(this,VK_BUFFER_USAGE_STORAGE_BUFFER_BIT,unit_size);
return(new GPUArrayBuffer(vk_ma,unit_size));
}
}//namespace graph
namespace graph namespace graph
{ {
GPUArrayBuffer::GPUArrayBuffer(VKMemoryAllocator *va,const uint us) GPUArrayBuffer::GPUArrayBuffer(VKMemoryAllocator *va,const uint us)
@ -50,23 +71,5 @@ namespace hgl
{ {
vk_ma->Flush(count*unit_size); vk_ma->Flush(count*unit_size);
} }
GPUArrayBuffer *GPUDevice::CreateUBO(const VkDeviceSize &item_length)
{
const uint unit_size=hgl_align<VkDeviceSize>(item_length,GetUBOAlign());
auto vk_ma=new VKMemoryAllocator(this,VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT,unit_size);
return(new GPUArrayBuffer(vk_ma,unit_size));
}
GPUArrayBuffer *GPUDevice::CreateSSBO(const VkDeviceSize &item_length)
{
const uint unit_size=hgl_align<VkDeviceSize>(item_length,GetSSBOAlign());
auto vk_ma=new VKMemoryAllocator(this,VK_BUFFER_USAGE_STORAGE_BUFFER_BIT,unit_size);
return(new GPUArrayBuffer(vk_ma,unit_size));
}
}//namespace graph }//namespace graph
}//namespace hgl }//namespace hgl

View File

@ -32,10 +32,10 @@ bool DescriptorBinding::Bind(MaterialInstance *mi)
for(uint i=0;i<count;i++) for(uint i=0;i<count;i++)
{ {
buf=GetUBO((*dp)->left); buf=GetUBO((*dp)->key);
if(buf) if(buf)
mp->BindUBO((*dp)->right,buf,false); mp->BindUBO((*dp)->value,buf,false);
++dp; ++dp;
} }
@ -48,10 +48,10 @@ bool DescriptorBinding::Bind(MaterialInstance *mi)
for(uint i=0;i<count;i++) for(uint i=0;i<count;i++)
{ {
buf=GetUBO((*dp)->left); buf=GetUBO((*dp)->key);
if(buf) if(buf)
mp->BindUBO((*dp)->right,buf,true); mp->BindUBO((*dp)->value,buf,true);
++dp; ++dp;
} }

View File

@ -69,7 +69,7 @@ void CreateShaderStageList(List<VkPipelineShaderStageCreateInfo> &shader_stage_l
auto **itp=shader_maps->GetDataList(); auto **itp=shader_maps->GetDataList();
for(int i=0;i<shader_count;i++) for(int i=0;i<shader_count;i++)
{ {
sm=(*itp)->right; sm=(*itp)->value;
hgl_cpy(p,sm->GetCreateInfo(),1); hgl_cpy(p,sm->GetCreateInfo(),1);
++p; ++p;

View File

@ -202,7 +202,7 @@ DeviceRenderPassManage::~DeviceRenderPassManage()
for(int i=0;i<count;i++) for(int i=0;i<count;i++)
{ {
delete (*obj)->right; delete (*obj)->value;
++obj; ++obj;
} }

View File

@ -107,7 +107,7 @@ MaterialDescriptorManager::MaterialDescriptorManager(const UTF8String &name,cons
for(int j=0;j<sds_array[i].count;j++) for(int j=0;j<sds_array[i].count;j++)
{ {
sd=(*sp)->right; sd=(*sp)->value;
binding_map[size_t(sd->set_type)][size_t(sd->desc_type)].Add(sd->name,sd->binding); binding_map[size_t(sd->set_type)][size_t(sd->desc_type)].Add(sd->name,sd->binding);

View File

@ -1,4 +1,4 @@
#include<hgl/graph/VKDevice.h> #include<hgl/graph/VKDevice.h>
#include<hgl/graph/VKMaterialInstance.h> #include<hgl/graph/VKMaterialInstance.h>
#include<hgl/graph/VKMaterialParameters.h> #include<hgl/graph/VKMaterialParameters.h>
#include<hgl/graph/VKShaderModule.h> #include<hgl/graph/VKShaderModule.h>
@ -21,10 +21,13 @@ MaterialInstance::MaterialInstance(Material *mtl,VIL *v)
vil=v; vil=v;
mp_per_mi= mp_per_mi=mtl->GetMP(DescriptorSetType::PerMaterial);
device->CreateMP(desc_manager,pld,(DescriptorSetType)dst);
PerMaterial的属性每个MaterialInstance不一样MP做绑定记录 /*
mtl->GetMP(DescriptorSetType::PerMaterial); PerMaterial的属性每个MaterialInstance不一样
MP做绑定记录
*/
} }
bool MaterialInstance::BindUBO(const DescriptorSetType &type,const AnsiString &name,DeviceBuffer *ubo,bool dynamic) bool MaterialInstance::BindUBO(const DescriptorSetType &type,const AnsiString &name,DeviceBuffer *ubo,bool dynamic)

View File

@ -42,7 +42,7 @@ namespace hgl
for(int i=0;i<count;i++) for(int i=0;i<count;i++)
{ {
get_max(max_char_height,(*fsp)->right->GetCharHeight()); get_max(max_char_height,(*fsp)->value->GetCharHeight());
++fsp; ++fsp;
} }
@ -93,8 +93,8 @@ namespace hgl
for(int i=0;i<count;i++) for(int i=0;i<count;i++)
{ {
if(IsInUnicodeBlock((*fsp)->left,ch)) if(IsInUnicodeBlock((*fsp)->key,ch))
return (*fsp)->right; return (*fsp)->value;
++fsp; ++fsp;
} }

View File

@ -42,7 +42,9 @@ SET(STD_MTL_2D_HEADER_PATH ${STD_MTL_HEADER_PATH}/2d)
SET(STD_MTL_2D_SOURCE_FILES ${STD_MTL_2D_HEADER_PATH}/VertexColor2D.h SET(STD_MTL_2D_SOURCE_FILES ${STD_MTL_2D_HEADER_PATH}/VertexColor2D.h
2d/VertexColor2D.cpp) 2d/VertexColor2D.cpp)
SET(STANDARD_MATERIAL_SOURCE ${STD_MTL_HEADER_PATH}/StdMaterial.h) SET(STANDARD_MATERIAL_SOURCE ${STD_MTL_HEADER_PATH}/StdMaterial.h
${STD_MTL_HEADER_PATH}/ShaderBuffer.h
StandardMaterial.cpp)
SOURCE_GROUP("Standard Material" FILES ${STANDARD_MATERIAL_SOURCE}) SOURCE_GROUP("Standard Material" FILES ${STANDARD_MATERIAL_SOURCE})
SOURCE_GROUP("Standard Material\\2D" FILES ${STD_MTL_2D_SOURCE_FILES}) SOURCE_GROUP("Standard Material\\2D" FILES ${STD_MTL_2D_SOURCE_FILES})

View File

@ -92,8 +92,8 @@ void MaterialDescriptorInfo::Resort()
auto *sdp=p.descriptor_map.GetDataList(); auto *sdp=p.descriptor_map.GetDataList();
for(int i=0;i<p.descriptor_map.GetCount();i++) for(int i=0;i<p.descriptor_map.GetCount();i++)
{ {
(*sdp)->right->set=set; (*sdp)->value->set=set;
(*sdp)->right->binding=i; (*sdp)->value->binding=i;
++sdp; ++sdp;
} }

View File

@ -1,7 +1,9 @@
#include<hgl/shadergen/StandardMaterial.h> #include<hgl/graph/mtl/StdMaterial.h>
namespace hgl{namespace graph{ STD_MTL_NAMESPACE_BEGIN
namespace
{
}//namespace
STD_MTL_NAMESPACE_END
}}//namespace hgl::graph