update codes...but can't compile
This commit is contained in:
parent
e488b4c3d3
commit
011fbdb55d
2
CMCore
2
CMCore
@ -1 +1 @@
|
||||
Subproject commit 3b1a62eb78ed7cf3d6d186b8b7e4c7d4b57eba18
|
||||
Subproject commit a377fe8d05d9486379c1da6007a940a90898e956
|
@ -1 +1 @@
|
||||
Subproject commit fd78d7e14b95e01e37eb5e631cbd6967e284fb95
|
||||
Subproject commit fe635b5851cd651f570a88b84a9353edf18a55ed
|
2
CMUtil
2
CMUtil
@ -1 +1 @@
|
||||
Subproject commit 9f94d5082bbbba65d55ae259deebbfc72b4a672a
|
||||
Subproject commit f4d19fc898e9434e93f77843975369744e59350a
|
46
inc/hgl/graph/mtl/MaterialVertexFormat.h
Normal file
46
inc/hgl/graph/mtl/MaterialVertexFormat.h
Normal 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/64k,一个matrix4f为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
|
18
inc/hgl/graph/mtl/ShaderBuffer.h
Normal file
18
inc/hgl/graph/mtl/ShaderBuffer.h
Normal 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
|
@ -3,7 +3,11 @@
|
||||
#define STD_MTL_NAMESPACE_BEGIN namespace hgl{namespace graph{namespace mtl{
|
||||
#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
|
||||
{
|
||||
@ -12,35 +16,26 @@ enum class CoordinateSystem2D
|
||||
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;
|
||||
};
|
||||
"ViewportInfo",
|
||||
"viewport",
|
||||
|
||||
constexpr const ShaderStruct ViewportInfo=
|
||||
{
|
||||
"ViewportInfo",
|
||||
"viewport",
|
||||
|
||||
R"(
|
||||
R"(
|
||||
mat4 ortho_matrix;
|
||||
|
||||
vec2 canvas_resolution;
|
||||
vec2 viewport_resolution;
|
||||
vec2 inv_viewport_resolution;
|
||||
)"
|
||||
};
|
||||
};
|
||||
|
||||
constexpr const ShaderStruct CameraInfo=
|
||||
{
|
||||
"CameraInfo",
|
||||
"camera",
|
||||
constexpr const ShaderBufferSource SBS_CameraInfo=
|
||||
{
|
||||
"CameraInfo",
|
||||
"camera",
|
||||
|
||||
R"(
|
||||
R"(
|
||||
mat4 projection;
|
||||
mat4 inverse_projection;
|
||||
|
||||
@ -57,5 +52,6 @@ vec3 view_line; //pos-target
|
||||
vec3 world_up;
|
||||
|
||||
float znear,zfar;)"
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
STD_MTL_NAMESPACE_END
|
||||
|
@ -53,7 +53,7 @@ public:
|
||||
~MaterialCreateInfo()=default;
|
||||
|
||||
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);
|
||||
}
|
||||
@ -61,7 +61,7 @@ public:
|
||||
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 InlineDescriptor::ShaderStruct &ss)
|
||||
bool AddUBO(const VkShaderStageFlagBits flag_bits,const DescriptorSetType &set_type,const InlineDescriptor::ShaderBufferSource &ss)
|
||||
{
|
||||
if(!mdi.hasStruct(ss.struct_name))
|
||||
mdi.AddStruct(ss.struct_name,ss.codes);
|
||||
|
@ -117,10 +117,10 @@ namespace hgl
|
||||
const auto *sp=ssb_map.GetDataList();
|
||||
for(uint i=0;i<si_count;i++)
|
||||
{
|
||||
if((*sp)->right->vbo)
|
||||
primitive->Set((*sp)->left,(*sp)->right->vbo);
|
||||
if((*sp)->value->vbo)
|
||||
primitive->Set((*sp)->key,(*sp)->value->vbo);
|
||||
else
|
||||
primitive->Set((*sp)->left,db->CreateVBO((*sp)->right->data));
|
||||
primitive->Set((*sp)->key,db->CreateVBO((*sp)->value->data));
|
||||
|
||||
++sp;
|
||||
}
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include<hgl/util/sort/Sort.h>
|
||||
|
||||
/**
|
||||
*
|
||||
* 理论上讲,我们需要按以下顺序排序
|
||||
*
|
||||
* for(material)
|
||||
|
@ -6,6 +6,27 @@
|
||||
|
||||
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
|
||||
{
|
||||
GPUArrayBuffer::GPUArrayBuffer(VKMemoryAllocator *va,const uint us)
|
||||
@ -50,23 +71,5 @@ namespace hgl
|
||||
{
|
||||
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 hgl
|
||||
|
@ -32,10 +32,10 @@ bool DescriptorBinding::Bind(MaterialInstance *mi)
|
||||
|
||||
for(uint i=0;i<count;i++)
|
||||
{
|
||||
buf=GetUBO((*dp)->left);
|
||||
buf=GetUBO((*dp)->key);
|
||||
|
||||
if(buf)
|
||||
mp->BindUBO((*dp)->right,buf,false);
|
||||
mp->BindUBO((*dp)->value,buf,false);
|
||||
|
||||
++dp;
|
||||
}
|
||||
@ -48,10 +48,10 @@ bool DescriptorBinding::Bind(MaterialInstance *mi)
|
||||
|
||||
for(uint i=0;i<count;i++)
|
||||
{
|
||||
buf=GetUBO((*dp)->left);
|
||||
buf=GetUBO((*dp)->key);
|
||||
|
||||
if(buf)
|
||||
mp->BindUBO((*dp)->right,buf,true);
|
||||
mp->BindUBO((*dp)->value,buf,true);
|
||||
|
||||
++dp;
|
||||
}
|
||||
|
@ -69,7 +69,7 @@ void CreateShaderStageList(List<VkPipelineShaderStageCreateInfo> &shader_stage_l
|
||||
auto **itp=shader_maps->GetDataList();
|
||||
for(int i=0;i<shader_count;i++)
|
||||
{
|
||||
sm=(*itp)->right;
|
||||
sm=(*itp)->value;
|
||||
hgl_cpy(p,sm->GetCreateInfo(),1);
|
||||
|
||||
++p;
|
||||
|
@ -202,7 +202,7 @@ DeviceRenderPassManage::~DeviceRenderPassManage()
|
||||
|
||||
for(int i=0;i<count;i++)
|
||||
{
|
||||
delete (*obj)->right;
|
||||
delete (*obj)->value;
|
||||
|
||||
++obj;
|
||||
}
|
||||
|
@ -107,7 +107,7 @@ MaterialDescriptorManager::MaterialDescriptorManager(const UTF8String &name,cons
|
||||
|
||||
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);
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
#include<hgl/graph/VKDevice.h>
|
||||
#include<hgl/graph/VKDevice.h>
|
||||
#include<hgl/graph/VKMaterialInstance.h>
|
||||
#include<hgl/graph/VKMaterialParameters.h>
|
||||
#include<hgl/graph/VKShaderModule.h>
|
||||
@ -21,10 +21,13 @@ MaterialInstance::MaterialInstance(Material *mtl,VIL *v)
|
||||
|
||||
vil=v;
|
||||
|
||||
mp_per_mi=
|
||||
device->CreateMP(desc_manager,pld,(DescriptorSetType)dst);
|
||||
PerMaterial的属性每个MaterialInstance不一样,所以需要在这里分配自己的MP做绑定记录
|
||||
mtl->GetMP(DescriptorSetType::PerMaterial);
|
||||
mp_per_mi=mtl->GetMP(DescriptorSetType::PerMaterial);
|
||||
|
||||
/*
|
||||
由于PerMaterial的属性每个MaterialInstance不一样,
|
||||
所以理论上需要在这里分配属于它自己的MP做绑定记录
|
||||
|
||||
*/
|
||||
}
|
||||
|
||||
bool MaterialInstance::BindUBO(const DescriptorSetType &type,const AnsiString &name,DeviceBuffer *ubo,bool dynamic)
|
||||
|
@ -42,7 +42,7 @@ namespace hgl
|
||||
|
||||
for(int i=0;i<count;i++)
|
||||
{
|
||||
get_max(max_char_height,(*fsp)->right->GetCharHeight());
|
||||
get_max(max_char_height,(*fsp)->value->GetCharHeight());
|
||||
|
||||
++fsp;
|
||||
}
|
||||
@ -93,8 +93,8 @@ namespace hgl
|
||||
|
||||
for(int i=0;i<count;i++)
|
||||
{
|
||||
if(IsInUnicodeBlock((*fsp)->left,ch))
|
||||
return (*fsp)->right;
|
||||
if(IsInUnicodeBlock((*fsp)->key,ch))
|
||||
return (*fsp)->value;
|
||||
|
||||
++fsp;
|
||||
}
|
||||
|
@ -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
|
||||
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\\2D" FILES ${STD_MTL_2D_SOURCE_FILES})
|
||||
|
@ -92,8 +92,8 @@ void MaterialDescriptorInfo::Resort()
|
||||
auto *sdp=p.descriptor_map.GetDataList();
|
||||
for(int i=0;i<p.descriptor_map.GetCount();i++)
|
||||
{
|
||||
(*sdp)->right->set=set;
|
||||
(*sdp)->right->binding=i;
|
||||
(*sdp)->value->set=set;
|
||||
(*sdp)->value->binding=i;
|
||||
|
||||
++sdp;
|
||||
}
|
||||
|
@ -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
|
||||
|
||||
|
||||
}}//namespace hgl::graph
|
||||
STD_MTL_NAMESPACE_END
|
||||
|
Loading…
x
Reference in New Issue
Block a user