added DebugUtils/DebugMaker test
This commit is contained in:
@@ -1,39 +1,42 @@
|
||||
#include<hgl/graph/VKDebugUtils.h>
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
VKDebugUtils::VKDebugUtils(VkDevice dev)
|
||||
void DebugUtils::SetName(VkObjectType type,uint64_t handle,const char *name)
|
||||
{
|
||||
device=dev;
|
||||
|
||||
s_vkSetDebugUtilsObjectName=(PFN_vkSetDebugUtilsObjectNameEXT)vkGetDeviceProcAddr(device,"vkSetDebugUtilsObjectNameEXT");
|
||||
s_vkCmdBeginDebugUtilsLabel=(PFN_vkCmdBeginDebugUtilsLabelEXT)vkGetDeviceProcAddr(device,"vkCmdBeginDebugUtilsLabelEXT");
|
||||
s_vkCmdEndDebugUtilsLabel=(PFN_vkCmdEndDebugUtilsLabelEXT)vkGetDeviceProcAddr(device,"vkCmdEndDebugUtilsLabelEXT");
|
||||
}
|
||||
|
||||
void VKDebugUtils::SetName(VkObjectType type,uint64_t handle,const char *name)
|
||||
{
|
||||
if(!s_vkSetDebugUtilsObjectName)return;
|
||||
|
||||
VkDebugUtilsObjectNameInfoEXT name_info={};
|
||||
|
||||
name_info.sType=VK_STRUCTURE_TYPE_DEBUG_UTILS_OBJECT_NAME_INFO_EXT;
|
||||
name_info.objectType=type;
|
||||
name_info.objectHandle=handle;
|
||||
name_info.pObjectName=name;
|
||||
name_info.sType =VK_STRUCTURE_TYPE_DEBUG_UTILS_OBJECT_NAME_INFO_EXT;
|
||||
name_info.objectType =type;
|
||||
name_info.objectHandle =handle;
|
||||
name_info.pObjectName =name;
|
||||
|
||||
s_vkSetDebugUtilsObjectName(device,&name_info);
|
||||
duf.SetName(device,&name_info);
|
||||
}
|
||||
|
||||
void VKDebugUtils::Begin(VkCommandBuffer cmd_buf,const char *name,const Color4f &color)
|
||||
void DebugUtils::Begin(VkCommandBuffer cmd_buf,const char *name,const Color4f &color)
|
||||
{
|
||||
if(!s_vkCmdBeginDebugUtilsLabel)return;
|
||||
|
||||
VkDebugUtilsLabelEXT label={};
|
||||
|
||||
label.sType=VK_STRUCTURE_TYPE_DEBUG_UTILS_LABEL_EXT;
|
||||
label.pLabelName=name;
|
||||
memcpy(label.color,&color,sizeof(float)*4);
|
||||
|
||||
s_vkCmdBeginDebugUtilsLabel(cmd_buf,&label);
|
||||
duf.Begin(cmd_buf,&label);
|
||||
}
|
||||
|
||||
DebugUtils *CreateDebugUtils(VkDevice device)
|
||||
{
|
||||
DebugUtilsFunction duf;
|
||||
|
||||
duf.SetName =(PFN_vkSetDebugUtilsObjectNameEXT )vkGetDeviceProcAddr(device,"vkSetDebugUtilsObjectNameEXT");
|
||||
duf.Begin =(PFN_vkCmdBeginDebugUtilsLabelEXT )vkGetDeviceProcAddr(device,"vkCmdBeginDebugUtilsLabelEXT");
|
||||
duf.End =(PFN_vkCmdEndDebugUtilsLabelEXT )vkGetDeviceProcAddr(device,"vkCmdEndDebugUtilsLabelEXT");
|
||||
|
||||
if(!duf.SetName
|
||||
||!duf.Begin
|
||||
||!duf.End)
|
||||
return(nullptr);
|
||||
|
||||
return(new DebugUtils(device,duf));
|
||||
}
|
||||
VK_NAMESPACE_END
|
||||
|
@@ -29,19 +29,28 @@ bool GPUCmdBuffer::Begin()
|
||||
void GPUCmdBuffer::SetDebugName(const char *object_name)
|
||||
{
|
||||
if(dev_attr->debug_maker)
|
||||
dev_attr->debug_maker->SetCommandBufferName(cmd_buf,object_name);
|
||||
dev_attr->debug_maker->SetCommandBuffer(cmd_buf,object_name);
|
||||
|
||||
if(dev_attr->debug_utils)
|
||||
dev_attr->debug_utils->SetCommandBuffer(cmd_buf,object_name);
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
if(dev_attr->debug_utils)
|
||||
dev_attr->debug_utils->Begin(cmd_buf,region_name,color);
|
||||
}
|
||||
|
||||
void GPUCmdBuffer::EndRegion()
|
||||
{
|
||||
if(dev_attr->debug_maker)
|
||||
dev_attr->debug_maker->End(cmd_buf);
|
||||
|
||||
if(dev_attr->debug_utils)
|
||||
dev_attr->debug_utils->End(cmd_buf);
|
||||
}
|
||||
#endif
|
||||
VK_NAMESPACE_END
|
||||
|
@@ -21,6 +21,13 @@ GPUDeviceAttribute::GPUDeviceAttribute(VulkanInstance *inst,const GPUPhysicalDev
|
||||
|
||||
GPUDeviceAttribute::~GPUDeviceAttribute()
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
if(debug_maker)
|
||||
delete debug_maker;
|
||||
if(debug_utils)
|
||||
delete debug_utils;
|
||||
#endif//_DEBUG
|
||||
|
||||
if(pipeline_cache)
|
||||
{
|
||||
SavePipelineCacheData(device,pipeline_cache,physical_device->GetProperties());
|
||||
|
@@ -17,6 +17,7 @@ Swapchain *CreateSwapchain(const GPUDeviceAttribute *attr,const VkExtent2D &acqu
|
||||
|
||||
#ifdef _DEBUG
|
||||
DebugMaker *CreateDebugMaker(VkDevice);
|
||||
DebugUtils *CreateDebugUtils(VkDevice);
|
||||
#endif//_DEBUG
|
||||
|
||||
namespace
|
||||
@@ -540,6 +541,7 @@ GPUDevice *CreateRenderDevice(VulkanInstance *inst,const GPUPhysicalDevice *phys
|
||||
|
||||
#ifdef _DEBUG
|
||||
device_attr->debug_maker=CreateDebugMaker(device_attr->device);
|
||||
device_attr->debug_utils=CreateDebugUtils(device_attr->device);
|
||||
#endif//_DEBUG
|
||||
|
||||
GetDeviceQueue(device_attr);
|
||||
@@ -559,7 +561,7 @@ GPUDevice *CreateRenderDevice(VulkanInstance *inst,const GPUPhysicalDevice *phys
|
||||
if(!device_attr->pipeline_cache)
|
||||
return(nullptr);
|
||||
|
||||
auto_delete.Discard();
|
||||
auto_delete.Discard(); //discard autodelete
|
||||
|
||||
return(new GPUDevice(device_attr));
|
||||
}
|
||||
|
@@ -132,6 +132,16 @@ Texture2D *RenderResource::LoadTexture2D(const OSString &filename,bool auto_mipm
|
||||
{
|
||||
texture_by_name.Add(filename,tex);
|
||||
Add(tex);
|
||||
|
||||
#ifdef _DEBUG
|
||||
GPUDeviceAttribute *da=device->GetDeviceAttribute();
|
||||
const UTF8String name=ToUTF8String(filename);
|
||||
|
||||
if(da->debug_maker)
|
||||
da->debug_maker->SetImage(tex->GetImage(),name);
|
||||
if(da->debug_utils)
|
||||
da->debug_utils->SetImage(tex->GetImage(),name);
|
||||
#endif//_DEBUG
|
||||
}
|
||||
|
||||
return tex;
|
||||
|
Reference in New Issue
Block a user