finished auto bound GlobalDescriptor
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
#ifndef HGL_GRAPH_VULKAN_MATERIAL_PARAMETERS_INCLUDE
|
||||
#ifndef HGL_GRAPH_VULKAN_MATERIAL_PARAMETERS_INCLUDE
|
||||
#define HGL_GRAPH_VULKAN_MATERIAL_PARAMETERS_INCLUDE
|
||||
|
||||
#include<hgl/graph/VK.h>
|
||||
@@ -27,10 +27,10 @@ public:
|
||||
DescriptorSet * GetDescriptorSet (){return descriptor_set;}
|
||||
const VkDescriptorSet GetVkDescriptorSet ()const{return descriptor_set->GetDescriptorSet();}
|
||||
|
||||
const uint32_t GetDescriptorCount ()const{return desc_manager->GetBindCount(set_type);} ///<<EFBFBD><EFBFBD>ȡ<EFBFBD>ܹ<EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
const uint32_t GetDescriptorCount ()const{return desc_manager->GetBindCount(set_type);} ///<获取总共需要绑定的描述符数量
|
||||
|
||||
const uint32_t GetBoundCount ()const{return descriptor_set->GetCount();} ///<<EFBFBD><EFBFBD>ȡ<EFBFBD>Ѿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
const bool IsReady ()const{return descriptor_set->IsReady();} ///<<EFBFBD>Ƿ<EFBFBD>ȫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
const uint32_t GetBoundCount ()const{return descriptor_set->GetCount();} ///<获取已经绑好的数量
|
||||
const bool IsReady ()const{return descriptor_set->IsReady();} ///<是否全部绑好了
|
||||
|
||||
public:
|
||||
|
||||
@@ -55,4 +55,4 @@ public:
|
||||
void Update();
|
||||
};//class MaterialParameters
|
||||
VK_NAMESPACE_END
|
||||
#endif//HGL_GRAPH_VULKAN_MATERIAL_PARAMETERS_INCLUDE
|
||||
#endif//HGL_GRAPH_VULKAN_MATERIAL_PARAMETERS_INCLUDE
|
||||
|
@@ -12,8 +12,50 @@ enum class CoordinateSystem2D
|
||||
Ortho //左上角为0,0;右下角为(width-1),(height-1)
|
||||
};
|
||||
|
||||
namespace GlobalShaderUBO
|
||||
namespace GlobalDescriptor
|
||||
{
|
||||
constexpr const char ViewportInfo[]="ViewportInfo";
|
||||
constexpr const char CameraInfo[]="CameraInfo";
|
||||
struct ShaderStruct
|
||||
{
|
||||
const char *struct_name;
|
||||
const char *name;
|
||||
const char *codes;
|
||||
};
|
||||
|
||||
constexpr const ShaderStruct ViewportInfo=
|
||||
{
|
||||
"ViewportInfo",
|
||||
"viewport",
|
||||
|
||||
R"(
|
||||
mat4 ortho_matrix;
|
||||
|
||||
vec2 canvas_resolution;
|
||||
vec2 viewport_resolution;
|
||||
vec2 inv_viewport_resolution;
|
||||
)"
|
||||
};
|
||||
|
||||
constexpr const ShaderStruct CameraInfo=
|
||||
{
|
||||
"CameraInfo",
|
||||
"camera",
|
||||
|
||||
R"(
|
||||
mat4 projection;
|
||||
mat4 inverse_projection;
|
||||
|
||||
mat4 view;
|
||||
mat4 inverse_view;
|
||||
|
||||
mat4 vp;
|
||||
mat4 inverse_vp;
|
||||
|
||||
mat4 sky;
|
||||
|
||||
vec3 pos; //eye
|
||||
vec3 view_line; //pos-target
|
||||
vec3 world_up;
|
||||
|
||||
float znear,zfar;)"
|
||||
};
|
||||
}
|
||||
|
@@ -5,6 +5,7 @@
|
||||
#include<hgl/shadergen/ShaderCreateInfoGeometry.h>
|
||||
#include<hgl/shadergen/ShaderCreateInfoFragment.h>
|
||||
#include<hgl/shadergen/ShaderCreateInfoMap.h>
|
||||
#include<hgl/graph/mtl/StdMaterial.h>
|
||||
#include<hgl/graph/VKSamplerType.h>
|
||||
|
||||
namespace hgl{namespace graph{
|
||||
@@ -19,7 +20,7 @@ protected:
|
||||
|
||||
uint32_t shader_stage; ///<着色器阶段
|
||||
|
||||
MaterialDescriptorInfo mdm; ///<材质描述符管理器
|
||||
MaterialDescriptorInfo mdi; ///<材质描述符管理器
|
||||
|
||||
ShaderCreateInfoMap shader_map; ///<着色器列表
|
||||
|
||||
@@ -52,12 +53,24 @@ public:
|
||||
~MaterialCreateInfo()=default;
|
||||
|
||||
bool AddStruct(const AnsiString &ubo_typename,const AnsiString &codes);
|
||||
bool AddStruct(const GlobalDescriptor::ShaderStruct &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 GlobalDescriptor::ShaderStruct &ss)
|
||||
{
|
||||
if(!mdi.hasStruct(ss.struct_name))
|
||||
mdi.AddStruct(ss.struct_name,ss.codes);
|
||||
|
||||
return AddUBO(flag_bits,DescriptorSetType::Global,ss.struct_name,ss.name);
|
||||
}
|
||||
|
||||
bool CreateShader();
|
||||
|
||||
const MaterialDescriptorInfo &GetMDI()const{return mdm;}
|
||||
const MaterialDescriptorInfo &GetMDI()const{return mdi;}
|
||||
};//class MaterialCreateInfo
|
||||
}}//namespace hgl::graph
|
||||
|
@@ -17,7 +17,7 @@ protected:
|
||||
|
||||
VkShaderStageFlagBits shader_stage; ///<着色器阶段
|
||||
|
||||
MaterialDescriptorInfo *mdm;
|
||||
MaterialDescriptorInfo *mdi;
|
||||
|
||||
protected:
|
||||
|
||||
|
Reference in New Issue
Block a user