added DebugUtils/DebugMaker test
This commit is contained in:
parent
12760ab5c5
commit
d98df3ee9c
@ -361,12 +361,14 @@ private:
|
|||||||
if(!gbuffer.cmd->BindFramebuffer(gbuffer.rt->GetRenderPass(),gbuffer.rt->GetFramebuffer()))
|
if(!gbuffer.cmd->BindFramebuffer(gbuffer.rt->GetRenderPass(),gbuffer.rt->GetFramebuffer()))
|
||||||
return(false);
|
return(false);
|
||||||
|
|
||||||
|
gbuffer.cmd->BeginRegion("GBuffer",Color4f(1,0,0,1));
|
||||||
if(!gbuffer.cmd->BeginRenderPass())
|
if(!gbuffer.cmd->BeginRenderPass())
|
||||||
return(false);
|
return(false);
|
||||||
|
|
||||||
render_list->Render(gbuffer.cmd);
|
render_list->Render(gbuffer.cmd);
|
||||||
|
|
||||||
gbuffer.cmd->EndRenderPass();
|
gbuffer.cmd->EndRenderPass();
|
||||||
|
gbuffer.cmd->EndRegion();
|
||||||
gbuffer.cmd->End();
|
gbuffer.cmd->End();
|
||||||
|
|
||||||
return(true);
|
return(true);
|
||||||
@ -440,8 +442,8 @@ public:
|
|||||||
|
|
||||||
render_root.RefreshMatrix();
|
render_root.RefreshMatrix();
|
||||||
render_list->Expend(GetCameraInfo(),&render_root);
|
render_list->Expend(GetCameraInfo(),&render_root);
|
||||||
|
|
||||||
CameraAppFramework::Draw();
|
CameraAppFramework::Draw();
|
||||||
}
|
}
|
||||||
};//class TestApp:public CameraAppFramework
|
};//class TestApp:public CameraAppFramework
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ public:
|
|||||||
void Insert(VkCommandBuffer cmdbuffer, const char *markerName, const Color4f &color);
|
void Insert(VkCommandBuffer cmdbuffer, const char *markerName, const Color4f &color);
|
||||||
void End(VkCommandBuffer cmdBuffer);
|
void End(VkCommandBuffer cmdBuffer);
|
||||||
|
|
||||||
#define DEBUG_MAKER_SET_FUNC(type,MNAME) void Set##type##Name(Vk##type obj,const char *name){SetObjectName((uint64_t)obj,VK_DEBUG_REPORT_OBJECT_TYPE_##MNAME##_EXT,name);}
|
#define DEBUG_MAKER_SET_FUNC(type,MNAME) void Set##type(Vk##type obj,const char *name){SetObjectName((uint64_t)obj,VK_DEBUG_REPORT_OBJECT_TYPE_##MNAME##_EXT,name);}
|
||||||
|
|
||||||
DEBUG_MAKER_SET_FUNC(CommandBuffer, COMMAND_BUFFER)
|
DEBUG_MAKER_SET_FUNC(CommandBuffer, COMMAND_BUFFER)
|
||||||
DEBUG_MAKER_SET_FUNC(Queue, QUEUE)
|
DEBUG_MAKER_SET_FUNC(Queue, QUEUE)
|
||||||
|
@ -5,18 +5,31 @@
|
|||||||
#include<hgl/type/Color4f.h>
|
#include<hgl/type/Color4f.h>
|
||||||
|
|
||||||
VK_NAMESPACE_BEGIN
|
VK_NAMESPACE_BEGIN
|
||||||
class VKDebugUtils
|
struct DebugUtilsFunction
|
||||||
|
{
|
||||||
|
PFN_vkSetDebugUtilsObjectNameEXT SetName;
|
||||||
|
PFN_vkCmdBeginDebugUtilsLabelEXT Begin;
|
||||||
|
PFN_vkCmdEndDebugUtilsLabelEXT End;
|
||||||
|
};//struct DebugUtilsFunction
|
||||||
|
|
||||||
|
class DebugUtils
|
||||||
{
|
{
|
||||||
VkDevice device;
|
VkDevice device;
|
||||||
|
|
||||||
PFN_vkSetDebugUtilsObjectNameEXT s_vkSetDebugUtilsObjectName;
|
|
||||||
PFN_vkCmdBeginDebugUtilsLabelEXT s_vkCmdBeginDebugUtilsLabel;
|
|
||||||
PFN_vkCmdEndDebugUtilsLabelEXT s_vkCmdEndDebugUtilsLabel;
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
VKDebugUtils(VkDevice dev);
|
DebugUtilsFunction duf;
|
||||||
~VKDebugUtils()=default;
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
friend DebugUtils *CreateDebugUtils(VkDevice);
|
||||||
|
|
||||||
|
DebugUtils(VkDevice dev,const DebugUtilsFunction &f)
|
||||||
|
{
|
||||||
|
device=dev;
|
||||||
|
duf=f;
|
||||||
|
}
|
||||||
|
|
||||||
|
public:
|
||||||
|
~DebugUtils()=default;
|
||||||
|
|
||||||
void SetName(VkObjectType,uint64_t,const char *);
|
void SetName(VkObjectType,uint64_t,const char *);
|
||||||
|
|
||||||
@ -47,11 +60,7 @@ public:
|
|||||||
void SetCommandPool (VkCommandPool cp, const char *name){SetName(VK_OBJECT_TYPE_COMMAND_POOL, (uint64_t)cp, name);}
|
void SetCommandPool (VkCommandPool cp, const char *name){SetName(VK_OBJECT_TYPE_COMMAND_POOL, (uint64_t)cp, name);}
|
||||||
|
|
||||||
void Begin(VkCommandBuffer,const char *,const Color4f &color=Color4f(1,1,1,1));
|
void Begin(VkCommandBuffer,const char *,const Color4f &color=Color4f(1,1,1,1));
|
||||||
void End(VkCommandBuffer cmd_buf)
|
void End(VkCommandBuffer cmd_buf){duf.End(cmd_buf);}
|
||||||
{
|
};//class DebugUtils
|
||||||
if(s_vkCmdEndDebugUtilsLabel)
|
|
||||||
s_vkCmdEndDebugUtilsLabel(cmd_buf);
|
|
||||||
}
|
|
||||||
};//class VKDebugUtils
|
|
||||||
VK_NAMESPACE_END
|
VK_NAMESPACE_END
|
||||||
#endif//HGL_GRAPH_VULKAN_DEBUG_UTILS_INCLUDE
|
#endif//HGL_GRAPH_VULKAN_DEBUG_UTILS_INCLUDE
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
#include<hgl/graph/VKDebugMaker.h>
|
#include<hgl/graph/VKDebugMaker.h>
|
||||||
|
#include<hgl/graph/VKDebugUtils.h>
|
||||||
#endif//_DEBUG
|
#endif//_DEBUG
|
||||||
|
|
||||||
VK_NAMESPACE_BEGIN
|
VK_NAMESPACE_BEGIN
|
||||||
@ -37,7 +38,7 @@ struct GPUDeviceAttribute
|
|||||||
|
|
||||||
VkSurfaceTransformFlagBitsKHR preTransform;
|
VkSurfaceTransformFlagBitsKHR preTransform;
|
||||||
VkCompositeAlphaFlagBitsKHR compositeAlpha =VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR;
|
VkCompositeAlphaFlagBitsKHR compositeAlpha =VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR;
|
||||||
|
|
||||||
VkDevice device =VK_NULL_HANDLE;
|
VkDevice device =VK_NULL_HANDLE;
|
||||||
VkCommandPool cmd_pool =VK_NULL_HANDLE;
|
VkCommandPool cmd_pool =VK_NULL_HANDLE;
|
||||||
|
|
||||||
@ -47,6 +48,7 @@ struct GPUDeviceAttribute
|
|||||||
|
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
DebugMaker * debug_maker =nullptr;
|
DebugMaker * debug_maker =nullptr;
|
||||||
|
DebugUtils * debug_utils =nullptr;
|
||||||
#endif//_DEBUG
|
#endif//_DEBUG
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -1,39 +1,42 @@
|
|||||||
#include<hgl/graph/VKDebugUtils.h>
|
#include<hgl/graph/VKDebugUtils.h>
|
||||||
|
|
||||||
VK_NAMESPACE_BEGIN
|
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={};
|
VkDebugUtilsObjectNameInfoEXT name_info={};
|
||||||
|
|
||||||
name_info.sType=VK_STRUCTURE_TYPE_DEBUG_UTILS_OBJECT_NAME_INFO_EXT;
|
name_info.sType =VK_STRUCTURE_TYPE_DEBUG_UTILS_OBJECT_NAME_INFO_EXT;
|
||||||
name_info.objectType=type;
|
name_info.objectType =type;
|
||||||
name_info.objectHandle=handle;
|
name_info.objectHandle =handle;
|
||||||
name_info.pObjectName=name;
|
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={};
|
VkDebugUtilsLabelEXT label={};
|
||||||
|
|
||||||
label.sType=VK_STRUCTURE_TYPE_DEBUG_UTILS_LABEL_EXT;
|
label.sType=VK_STRUCTURE_TYPE_DEBUG_UTILS_LABEL_EXT;
|
||||||
label.pLabelName=name;
|
label.pLabelName=name;
|
||||||
memcpy(label.color,&color,sizeof(float)*4);
|
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
|
VK_NAMESPACE_END
|
||||||
|
@ -29,19 +29,28 @@ bool GPUCmdBuffer::Begin()
|
|||||||
void GPUCmdBuffer::SetDebugName(const char *object_name)
|
void GPUCmdBuffer::SetDebugName(const char *object_name)
|
||||||
{
|
{
|
||||||
if(dev_attr->debug_maker)
|
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)
|
void GPUCmdBuffer::BeginRegion(const char *region_name,const Color4f &color)
|
||||||
{
|
{
|
||||||
if(dev_attr->debug_maker)
|
if(dev_attr->debug_maker)
|
||||||
dev_attr->debug_maker->Begin(cmd_buf,region_name,color);
|
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()
|
void GPUCmdBuffer::EndRegion()
|
||||||
{
|
{
|
||||||
if(dev_attr->debug_maker)
|
if(dev_attr->debug_maker)
|
||||||
dev_attr->debug_maker->End(cmd_buf);
|
dev_attr->debug_maker->End(cmd_buf);
|
||||||
|
|
||||||
|
if(dev_attr->debug_utils)
|
||||||
|
dev_attr->debug_utils->End(cmd_buf);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
VK_NAMESPACE_END
|
VK_NAMESPACE_END
|
||||||
|
@ -21,6 +21,13 @@ GPUDeviceAttribute::GPUDeviceAttribute(VulkanInstance *inst,const GPUPhysicalDev
|
|||||||
|
|
||||||
GPUDeviceAttribute::~GPUDeviceAttribute()
|
GPUDeviceAttribute::~GPUDeviceAttribute()
|
||||||
{
|
{
|
||||||
|
#ifdef _DEBUG
|
||||||
|
if(debug_maker)
|
||||||
|
delete debug_maker;
|
||||||
|
if(debug_utils)
|
||||||
|
delete debug_utils;
|
||||||
|
#endif//_DEBUG
|
||||||
|
|
||||||
if(pipeline_cache)
|
if(pipeline_cache)
|
||||||
{
|
{
|
||||||
SavePipelineCacheData(device,pipeline_cache,physical_device->GetProperties());
|
SavePipelineCacheData(device,pipeline_cache,physical_device->GetProperties());
|
||||||
|
@ -17,6 +17,7 @@ Swapchain *CreateSwapchain(const GPUDeviceAttribute *attr,const VkExtent2D &acqu
|
|||||||
|
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
DebugMaker *CreateDebugMaker(VkDevice);
|
DebugMaker *CreateDebugMaker(VkDevice);
|
||||||
|
DebugUtils *CreateDebugUtils(VkDevice);
|
||||||
#endif//_DEBUG
|
#endif//_DEBUG
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
@ -540,6 +541,7 @@ GPUDevice *CreateRenderDevice(VulkanInstance *inst,const GPUPhysicalDevice *phys
|
|||||||
|
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
device_attr->debug_maker=CreateDebugMaker(device_attr->device);
|
device_attr->debug_maker=CreateDebugMaker(device_attr->device);
|
||||||
|
device_attr->debug_utils=CreateDebugUtils(device_attr->device);
|
||||||
#endif//_DEBUG
|
#endif//_DEBUG
|
||||||
|
|
||||||
GetDeviceQueue(device_attr);
|
GetDeviceQueue(device_attr);
|
||||||
@ -559,7 +561,7 @@ GPUDevice *CreateRenderDevice(VulkanInstance *inst,const GPUPhysicalDevice *phys
|
|||||||
if(!device_attr->pipeline_cache)
|
if(!device_attr->pipeline_cache)
|
||||||
return(nullptr);
|
return(nullptr);
|
||||||
|
|
||||||
auto_delete.Discard();
|
auto_delete.Discard(); //discard autodelete
|
||||||
|
|
||||||
return(new GPUDevice(device_attr));
|
return(new GPUDevice(device_attr));
|
||||||
}
|
}
|
||||||
|
@ -132,6 +132,16 @@ Texture2D *RenderResource::LoadTexture2D(const OSString &filename,bool auto_mipm
|
|||||||
{
|
{
|
||||||
texture_by_name.Add(filename,tex);
|
texture_by_name.Add(filename,tex);
|
||||||
Add(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;
|
return tex;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user