SBS增加DescriptorSetType数据,未来所有绑定地方使用此参数以避免对不上
This commit is contained in:
parent
b5a5cb16c0
commit
784e7f0e0b
2
CMCore
2
CMCore
@ -1 +1 @@
|
|||||||
Subproject commit fff021488c9608c2ac4ee06bc544e9a80849c6f0
|
Subproject commit 10108953ebff000823b072be9e4c632471520945
|
@ -216,5 +216,5 @@ public:
|
|||||||
|
|
||||||
int os_main(int,os_char **)
|
int os_main(int,os_char **)
|
||||||
{
|
{
|
||||||
return RunFramework<TestApp>(OS_TEXT("AutoInstance"),1024,1024);
|
return RunFramework<TestApp>(OS_TEXT("AutoInstance"),1280,720);
|
||||||
}
|
}
|
||||||
|
@ -96,6 +96,7 @@ class Semaphore;
|
|||||||
|
|
||||||
struct PipelineLayoutData;
|
struct PipelineLayoutData;
|
||||||
class DescriptorSet;
|
class DescriptorSet;
|
||||||
|
enum class DescriptorSetType;
|
||||||
|
|
||||||
struct VertexInputAttribute;
|
struct VertexInputAttribute;
|
||||||
|
|
||||||
|
@ -22,6 +22,7 @@ public:
|
|||||||
buffer=nullptr;
|
buffer=nullptr;
|
||||||
offset=0;
|
offset=0;
|
||||||
stride=count=0;
|
stride=count=0;
|
||||||
|
map_ptr=nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ~VKBufferMap()
|
virtual ~VKBufferMap()
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
#include<hgl/type/Map.h>
|
#include<hgl/type/Map.h>
|
||||||
#include<hgl/type/String.h>
|
#include<hgl/type/String.h>
|
||||||
#include<hgl/graph/VK.h>
|
#include<hgl/graph/VK.h>
|
||||||
#include<hgl/graph/VKDescriptorSetType.h>
|
|
||||||
|
|
||||||
VK_NAMESPACE_BEGIN
|
VK_NAMESPACE_BEGIN
|
||||||
|
|
||||||
@ -46,6 +45,9 @@ public:
|
|||||||
template<typename T>
|
template<typename T>
|
||||||
bool AddUBO(const AnsiString &name,DeviceBufferMap<T> *dbm)
|
bool AddUBO(const AnsiString &name,DeviceBufferMap<T> *dbm)
|
||||||
{
|
{
|
||||||
|
if(name.IsEmpty()||!dbm)
|
||||||
|
return(false);
|
||||||
|
|
||||||
return AddUBO(name,dbm->GetDeviceBuffer());
|
return AddUBO(name,dbm->GetDeviceBuffer());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
#include<hgl/type/Map.h>
|
#include<hgl/type/Map.h>
|
||||||
#include<hgl/type/String.h>
|
#include<hgl/type/String.h>
|
||||||
#include<hgl/graph/VKShaderModuleMap.h>
|
#include<hgl/graph/VKShaderModuleMap.h>
|
||||||
#include<hgl/graph/VKDescriptorSetType.h>
|
#include<hgl/graph/mtl/ShaderBufferSource.h>
|
||||||
|
|
||||||
namespace hgl
|
namespace hgl
|
||||||
{
|
{
|
||||||
@ -83,6 +83,11 @@ public:
|
|||||||
bool BindSSBO(const DescriptorSetType &type,const AnsiString &name,DeviceBuffer *ubo,bool dynamic=false);
|
bool BindSSBO(const DescriptorSetType &type,const AnsiString &name,DeviceBuffer *ubo,bool dynamic=false);
|
||||||
bool BindImageSampler(const DescriptorSetType &type,const AnsiString &name,Texture *tex,Sampler *sampler);
|
bool BindImageSampler(const DescriptorSetType &type,const AnsiString &name,Texture *tex,Sampler *sampler);
|
||||||
|
|
||||||
|
bool BindUBO(const ShaderBufferDesc *sbd,DeviceBuffer *ubo,bool dynamic=false)
|
||||||
|
{
|
||||||
|
return BindUBO(sbd->set_type,sbd->name,ubo,dynamic);
|
||||||
|
}
|
||||||
|
|
||||||
void Update();
|
void Update();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -14,9 +14,12 @@ namespace blinnphong
|
|||||||
|
|
||||||
constexpr const ShaderBufferSource SBS_SunLight=
|
constexpr const ShaderBufferSource SBS_SunLight=
|
||||||
{
|
{
|
||||||
"SunLight",
|
DescriptorSetType::Scene,
|
||||||
|
|
||||||
"sun",
|
"sun",
|
||||||
|
|
||||||
|
"SunLight",
|
||||||
|
|
||||||
R"(
|
R"(
|
||||||
vec4 direction;
|
vec4 direction;
|
||||||
vec4 color;
|
vec4 color;
|
||||||
|
@ -1,11 +1,19 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include<hgl/graph/VKDescriptorSetType.h>
|
||||||
|
|
||||||
namespace hgl::graph
|
namespace hgl::graph
|
||||||
{
|
{
|
||||||
struct ShaderBufferSource
|
struct ShaderBufferDesc
|
||||||
|
{
|
||||||
|
const DescriptorSetType set_type;
|
||||||
|
|
||||||
|
const char *name;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct ShaderBufferSource:public ShaderBufferDesc
|
||||||
{
|
{
|
||||||
const char *struct_name;
|
const char *struct_name;
|
||||||
const char *name;
|
|
||||||
const char *codes;
|
const char *codes;
|
||||||
};
|
};
|
||||||
}//namespace hgl::graph
|
}//namespace hgl::graph
|
||||||
|
@ -6,8 +6,10 @@
|
|||||||
STD_MTL_NAMESPACE_BEGIN
|
STD_MTL_NAMESPACE_BEGIN
|
||||||
constexpr const ShaderBufferSource SBS_ViewportInfo=
|
constexpr const ShaderBufferSource SBS_ViewportInfo=
|
||||||
{
|
{
|
||||||
"ViewportInfo",
|
DescriptorSetType::RenderTarget,
|
||||||
|
|
||||||
"viewport",
|
"viewport",
|
||||||
|
"ViewportInfo",
|
||||||
|
|
||||||
R"(
|
R"(
|
||||||
mat4 ortho_matrix;
|
mat4 ortho_matrix;
|
||||||
@ -20,8 +22,10 @@ constexpr const ShaderBufferSource SBS_ViewportInfo=
|
|||||||
|
|
||||||
constexpr const ShaderBufferSource SBS_CameraInfo=
|
constexpr const ShaderBufferSource SBS_CameraInfo=
|
||||||
{
|
{
|
||||||
"CameraInfo",
|
DescriptorSetType::Camera,
|
||||||
|
|
||||||
"camera",
|
"camera",
|
||||||
|
"CameraInfo",
|
||||||
|
|
||||||
R"(
|
R"(
|
||||||
mat4 projection;
|
mat4 projection;
|
||||||
@ -48,12 +52,13 @@ constexpr const ShaderBufferSource SBS_CameraInfo=
|
|||||||
};
|
};
|
||||||
|
|
||||||
constexpr const char LocalToWorldStruct[]="LocalToWorld";
|
constexpr const char LocalToWorldStruct[]="LocalToWorld";
|
||||||
constexpr const DescriptorSetType DST_LocalToWorld=DescriptorSetType::PerFrame;
|
|
||||||
|
|
||||||
constexpr const ShaderBufferSource SBS_LocalToWorld=
|
constexpr const ShaderBufferSource SBS_LocalToWorld=
|
||||||
{
|
{
|
||||||
"LocalToWorldData",
|
DescriptorSetType::PerFrame,
|
||||||
|
|
||||||
"l2w",
|
"l2w",
|
||||||
|
"LocalToWorldData",
|
||||||
|
|
||||||
R"(
|
R"(
|
||||||
mat4 mats[L2W_MAX_COUNT];
|
mat4 mats[L2W_MAX_COUNT];
|
||||||
@ -64,12 +69,13 @@ constexpr const ShaderBufferSource SBS_LocalToWorld=
|
|||||||
// SSBO则不需要,使用[]方式指定为动态大小数组
|
// SSBO则不需要,使用[]方式指定为动态大小数组
|
||||||
|
|
||||||
constexpr const char MaterialInstanceStruct[]="MaterialInstance";
|
constexpr const char MaterialInstanceStruct[]="MaterialInstance";
|
||||||
constexpr const DescriptorSetType DST_MaterialInstance=DescriptorSetType::PerMaterial;
|
|
||||||
|
|
||||||
constexpr const ShaderBufferSource SBS_MaterialInstance=
|
constexpr const ShaderBufferSource SBS_MaterialInstance=
|
||||||
{
|
{
|
||||||
"MaterialInstanceData",
|
DescriptorSetType::PerMaterial,
|
||||||
|
|
||||||
"mtl",
|
"mtl",
|
||||||
|
"MaterialInstanceData",
|
||||||
|
|
||||||
R"(
|
R"(
|
||||||
MaterialInstance mi[MI_MAX_COUNT];)"
|
MaterialInstance mi[MI_MAX_COUNT];)"
|
||||||
@ -77,11 +83,13 @@ constexpr const ShaderBufferSource SBS_MaterialInstance=
|
|||||||
|
|
||||||
constexpr const ShaderBufferSource SBS_JointInfo=
|
constexpr const ShaderBufferSource SBS_JointInfo=
|
||||||
{
|
{
|
||||||
"JointInfo",
|
DescriptorSetType::PerFrame,
|
||||||
"joint",
|
|
||||||
|
|
||||||
R"(
|
"joint",
|
||||||
mat4 mats[];
|
"JointInfo",
|
||||||
)"
|
|
||||||
|
R"(
|
||||||
|
mat4 mats[];
|
||||||
|
)"
|
||||||
};
|
};
|
||||||
STD_MTL_NAMESPACE_END
|
STD_MTL_NAMESPACE_END
|
||||||
|
@ -30,8 +30,8 @@ void RenderAssignBuffer::Bind(Material *mtl)const
|
|||||||
{
|
{
|
||||||
if(!mtl)return;
|
if(!mtl)return;
|
||||||
|
|
||||||
mtl->BindUBO(mtl::DST_LocalToWorld, mtl::SBS_LocalToWorld.name, l2w_buffer);
|
mtl->BindUBO(&mtl::SBS_LocalToWorld, l2w_buffer);
|
||||||
mtl->BindUBO(mtl::DST_MaterialInstance, mtl::SBS_MaterialInstance.name, mi_buffer);
|
mtl->BindUBO(&mtl::SBS_MaterialInstance, mi_buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderAssignBuffer::Clear()
|
void RenderAssignBuffer::Clear()
|
||||||
|
@ -168,11 +168,12 @@ bool MaterialCreateInfo::SetMaterialInstance(const AnsiString &glsl_codes,const
|
|||||||
mi_max_count=hgl_min<uint32_t>(ubo_range/data_bytes,HGL_U16_MAX);
|
mi_max_count=hgl_min<uint32_t>(ubo_range/data_bytes,HGL_U16_MAX);
|
||||||
|
|
||||||
mdi.AddStruct(MaterialInstanceStruct,mi_codes);
|
mdi.AddStruct(MaterialInstanceStruct,mi_codes);
|
||||||
|
|
||||||
mdi.AddStruct(SBS_MaterialInstance);
|
mdi.AddStruct(SBS_MaterialInstance);
|
||||||
|
|
||||||
mi_ubo=CreateUBODescriptor(SBS_MaterialInstance,shader_stage_flag_bits);
|
mi_ubo=CreateUBODescriptor(SBS_MaterialInstance,shader_stage_flag_bits);
|
||||||
|
|
||||||
mdi.AddUBO(shader_stage_flag_bits,DST_MaterialInstance,mi_ubo);
|
mdi.AddUBO(shader_stage_flag_bits,SBS_MaterialInstance.set_type,mi_ubo);
|
||||||
|
|
||||||
const AnsiString MI_MAX_COUNT_STRING=AnsiString::numberOf(mi_max_count);
|
const AnsiString MI_MAX_COUNT_STRING=AnsiString::numberOf(mi_max_count);
|
||||||
|
|
||||||
@ -204,7 +205,7 @@ bool MaterialCreateInfo::SetLocalToWorld(const uint32_t shader_stage_flag_bits)
|
|||||||
|
|
||||||
l2w_ubo=CreateUBODescriptor(SBS_LocalToWorld,shader_stage_flag_bits);
|
l2w_ubo=CreateUBODescriptor(SBS_LocalToWorld,shader_stage_flag_bits);
|
||||||
|
|
||||||
mdi.AddUBO(shader_stage_flag_bits,DST_LocalToWorld,l2w_ubo);
|
mdi.AddUBO(shader_stage_flag_bits,SBS_LocalToWorld.set_type,l2w_ubo);
|
||||||
|
|
||||||
const AnsiString L2W_MAX_COUNT_STRING=AnsiString::numberOf(l2w_max_count);
|
const AnsiString L2W_MAX_COUNT_STRING=AnsiString::numberOf(l2w_max_count);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user