update codes...but can't compile

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

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 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ŷ<EFBFBD><C5B7><EFBFBD>
*
* 1.Push Constants <20><><EFBFBD><EFBFBD>
*
* 2.UBO <20>д<EFBFBD><D0B4><EFBFBD>matrix4f<34><66><EFBFBD>У<EFBFBD>vertex attrib<69>д<EFBFBD><D0B4><EFBFBD>ID
* UBOͨ<4F><CDA8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ16k/64k<34><6B>һ<EFBFBD><D2BB>matrix4fΪ64<36>ֽڡ<D6BD>
*
* 3.Vertex Attribute
*/
/**
* <20><><EFBFBD>ʶ<EFBFBD><CAB6><EFBFBD><EFBFBD>
*/
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_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

View File

@@ -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);