2022-06-24 17:51:39 +08:00
|
|
|
|
#include<hgl/graph/VKPrimitive.h>
|
|
|
|
|
#include<hgl/graph/VKBuffer.h>
|
|
|
|
|
#include<hgl/graph/VKShaderModule.h>
|
|
|
|
|
#include<hgl/graph/VKVertexAttribBuffer.h>
|
|
|
|
|
|
2023-10-12 05:55:39 +08:00
|
|
|
|
#ifdef _DEBUG
|
|
|
|
|
#include<hgl/graph/VKDevice.h>
|
|
|
|
|
#include<hgl/graph/VKDeviceAttribute.h>
|
|
|
|
|
#endif//_DEBUG
|
|
|
|
|
|
2022-06-24 17:51:39 +08:00
|
|
|
|
VK_NAMESPACE_BEGIN
|
2022-10-11 19:16:06 +08:00
|
|
|
|
//bool Renderable::Set(const int stage_input_binding,VIL *vil,VkDeviceSize offset)
|
2022-06-24 17:51:39 +08:00
|
|
|
|
//{
|
2022-10-11 19:16:06 +08:00
|
|
|
|
// if(stage_input_binding<0||stage_input_binding>=buf_count||!vil)return(false);
|
2022-06-24 17:51:39 +08:00
|
|
|
|
//
|
|
|
|
|
// const VkVertexInputBindingDescription *desc=vertex_sm->GetDesc(stage_input_binding);
|
|
|
|
|
// const VkVertexInputAttributeDescription *attr=vertex_sm->GetAttr(stage_input_binding);
|
|
|
|
|
//
|
2022-10-11 19:16:06 +08:00
|
|
|
|
// if(vil->GetFormat()!=attr->format)return(false);
|
|
|
|
|
// if(vil->GetStride()!=desc->stride)return(false);
|
2022-06-24 17:51:39 +08:00
|
|
|
|
//
|
|
|
|
|
// //format信息来自于shader,实际中可以不一样。但那样需要为每一个格式产生一个同样shader的material instance,不同的格式又需要不同的pipeline,我们不支持这种行为
|
|
|
|
|
//
|
2022-10-11 19:16:06 +08:00
|
|
|
|
// buf_list[stage_input_binding]=vil->GetBuffer();
|
2022-06-24 17:51:39 +08:00
|
|
|
|
// buf_offset[stage_input_binding]=offset;
|
|
|
|
|
//
|
|
|
|
|
// return(true);
|
|
|
|
|
//}
|
|
|
|
|
|
2024-04-27 01:07:44 +08:00
|
|
|
|
bool Primitive::SetVAB(const AnsiString &name,VAB *vab,VkDeviceSize start)
|
2022-06-24 17:51:39 +08:00
|
|
|
|
{
|
2024-04-24 01:38:55 +08:00
|
|
|
|
if(!vab)return(false);
|
2022-06-24 17:51:39 +08:00
|
|
|
|
if(buffer_list.KeyExist(name))return(false);
|
|
|
|
|
|
2024-04-24 01:38:55 +08:00
|
|
|
|
VABAccess vad;
|
2022-06-24 17:51:39 +08:00
|
|
|
|
|
2024-04-24 01:38:55 +08:00
|
|
|
|
vad.vab=vab;
|
2024-04-27 01:07:44 +08:00
|
|
|
|
vad.start=start;
|
2024-04-03 00:12:39 +08:00
|
|
|
|
|
|
|
|
|
buffer_list.Add(name,vad);
|
2023-10-12 05:55:39 +08:00
|
|
|
|
|
|
|
|
|
#ifdef _DEBUG
|
2023-10-13 02:01:57 +08:00
|
|
|
|
DebugUtils *du=device->GetDebugUtils();
|
2023-10-12 05:55:39 +08:00
|
|
|
|
|
2023-10-13 02:01:57 +08:00
|
|
|
|
if(du)
|
2023-10-13 01:48:07 +08:00
|
|
|
|
{
|
2024-04-24 01:44:01 +08:00
|
|
|
|
du->SetBuffer(vab->GetBuffer(),prim_name+":VAB:Buffer:"+name);
|
|
|
|
|
du->SetDeviceMemory(vab->GetVkMemory(),prim_name+":VAB:Memory:"+name);
|
2023-10-13 01:48:07 +08:00
|
|
|
|
}
|
2023-10-12 05:55:39 +08:00
|
|
|
|
#endif//_DEBUG
|
|
|
|
|
|
2022-06-24 17:51:39 +08:00
|
|
|
|
return(true);
|
|
|
|
|
}
|
|
|
|
|
|
2024-04-24 01:44:01 +08:00
|
|
|
|
bool Primitive::GetVABAccess(const AnsiString &name,VABAccess *vad)
|
2022-06-24 17:51:39 +08:00
|
|
|
|
{
|
2024-04-03 00:12:39 +08:00
|
|
|
|
if(name.IsEmpty())return(false);
|
|
|
|
|
if(!vad)return(false);
|
2022-06-24 17:51:39 +08:00
|
|
|
|
|
2024-04-03 00:12:39 +08:00
|
|
|
|
return buffer_list.Get(name,*vad);
|
2022-06-24 17:51:39 +08:00
|
|
|
|
}
|
|
|
|
|
|
2024-04-27 01:07:44 +08:00
|
|
|
|
bool Primitive::SetIndex(IndexBuffer *ib,VkDeviceSize start,const VkDeviceSize index_count)
|
2023-10-12 05:55:39 +08:00
|
|
|
|
{
|
|
|
|
|
if(!ib)return(false);
|
|
|
|
|
|
2024-04-26 00:32:11 +08:00
|
|
|
|
ib_access.buffer=ib;
|
2024-04-27 01:07:44 +08:00
|
|
|
|
ib_access.start=start;
|
|
|
|
|
ib_access.count=index_count;
|
2023-10-12 05:55:39 +08:00
|
|
|
|
|
|
|
|
|
#ifdef _DEBUG
|
2023-10-13 02:01:57 +08:00
|
|
|
|
DebugUtils *du=device->GetDebugUtils();
|
2023-10-13 01:48:07 +08:00
|
|
|
|
|
2023-10-13 02:01:57 +08:00
|
|
|
|
if(du)
|
2023-10-13 01:48:07 +08:00
|
|
|
|
{
|
2023-10-13 02:01:57 +08:00
|
|
|
|
du->SetBuffer(ib->GetBuffer(),prim_name+":IBO:Buffer");
|
|
|
|
|
du->SetDeviceMemory(ib->GetVkMemory(),prim_name+":IBO:Memory");
|
2023-10-13 01:48:07 +08:00
|
|
|
|
}
|
2023-10-12 05:55:39 +08:00
|
|
|
|
#endif//_DEBUG
|
|
|
|
|
return(true);
|
|
|
|
|
}
|
2022-06-24 17:51:39 +08:00
|
|
|
|
VK_NAMESPACE_END
|