2020-10-21 11:43:18 +08:00
|
|
|
|
#include<hgl/graph/VKCommandBuffer.h>
|
2020-11-16 16:42:20 +08:00
|
|
|
|
#include<hgl/graph/VKDeviceAttribute.h>
|
2019-04-09 02:02:43 +08:00
|
|
|
|
|
|
|
|
|
VK_NAMESPACE_BEGIN
|
2020-11-16 16:42:20 +08:00
|
|
|
|
GPUCmdBuffer::GPUCmdBuffer(const GPUDeviceAttribute *attr,VkCommandBuffer cb)
|
2019-04-18 22:10:24 +08:00
|
|
|
|
{
|
2020-11-16 16:42:20 +08:00
|
|
|
|
dev_attr=attr;
|
2019-04-18 22:10:24 +08:00
|
|
|
|
cmd_buf=cb;
|
|
|
|
|
}
|
|
|
|
|
|
2020-10-21 12:39:22 +08:00
|
|
|
|
GPUCmdBuffer::~GPUCmdBuffer()
|
2019-04-09 02:02:43 +08:00
|
|
|
|
{
|
2020-11-16 16:42:20 +08:00
|
|
|
|
vkFreeCommandBuffers(dev_attr->device,dev_attr->cmd_pool,1,&cmd_buf);
|
2019-04-09 02:02:43 +08:00
|
|
|
|
}
|
2019-05-05 11:54:49 +08:00
|
|
|
|
|
2020-10-21 12:39:22 +08:00
|
|
|
|
bool GPUCmdBuffer::Begin()
|
2019-04-18 22:10:24 +08:00
|
|
|
|
{
|
2020-09-27 20:58:25 +08:00
|
|
|
|
CommandBufferBeginInfo cmd_buf_info;
|
|
|
|
|
|
2019-04-20 02:28:57 +08:00
|
|
|
|
cmd_buf_info.pInheritanceInfo = nullptr;
|
|
|
|
|
|
|
|
|
|
if(vkBeginCommandBuffer(cmd_buf, &cmd_buf_info)!=VK_SUCCESS)
|
|
|
|
|
return(false);
|
|
|
|
|
|
2019-04-29 14:53:56 +08:00
|
|
|
|
return(true);
|
|
|
|
|
}
|
2021-11-23 11:54:54 +08:00
|
|
|
|
|
|
|
|
|
#ifdef _DEBUG
|
|
|
|
|
void GPUCmdBuffer::SetDebugName(const char *object_name)
|
|
|
|
|
{
|
|
|
|
|
if(dev_attr->debug_maker)
|
2022-09-26 16:11:42 +08:00
|
|
|
|
dev_attr->debug_maker->SetCommandBuffer(cmd_buf,object_name);
|
|
|
|
|
|
|
|
|
|
if(dev_attr->debug_utils)
|
|
|
|
|
dev_attr->debug_utils->SetCommandBuffer(cmd_buf,object_name);
|
2021-11-23 11:54:54 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void GPUCmdBuffer::BeginRegion(const char *region_name,const Color4f &color)
|
|
|
|
|
{
|
|
|
|
|
if(dev_attr->debug_maker)
|
|
|
|
|
dev_attr->debug_maker->Begin(cmd_buf,region_name,color);
|
2022-09-26 16:11:42 +08:00
|
|
|
|
|
|
|
|
|
if(dev_attr->debug_utils)
|
2022-09-26 22:06:17 +08:00
|
|
|
|
dev_attr->debug_utils->CmdBegin(cmd_buf,region_name,color);
|
2021-11-23 11:54:54 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void GPUCmdBuffer::EndRegion()
|
|
|
|
|
{
|
|
|
|
|
if(dev_attr->debug_maker)
|
|
|
|
|
dev_attr->debug_maker->End(cmd_buf);
|
2022-09-26 16:11:42 +08:00
|
|
|
|
|
|
|
|
|
if(dev_attr->debug_utils)
|
2022-09-26 22:06:17 +08:00
|
|
|
|
dev_attr->debug_utils->CmdEnd(cmd_buf);
|
2021-11-23 11:54:54 +08:00
|
|
|
|
}
|
|
|
|
|
#endif
|
2019-04-09 02:02:43 +08:00
|
|
|
|
VK_NAMESPACE_END
|