added DebugMaker
This commit is contained in:
parent
6a74d4eb95
commit
e6df11e572
66
inc/hgl/graph/VKDebugMaker.h
Normal file
66
inc/hgl/graph/VKDebugMaker.h
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
#ifndef HGL_GRAPH_VULKAN_DEBUG_MAKER_INCLUDE
|
||||||
|
#define HGL_GRAPH_VULKAN_DEBUG_MAKER_INCLUDE
|
||||||
|
|
||||||
|
#include<hgl/graph/VK.h>
|
||||||
|
#include<hgl/type/Color4f.h>
|
||||||
|
|
||||||
|
VK_NAMESPACE_BEGIN
|
||||||
|
struct DebugMakerFunction
|
||||||
|
{
|
||||||
|
PFN_vkDebugMarkerSetObjectTagEXT SetObjectTag;
|
||||||
|
PFN_vkDebugMarkerSetObjectNameEXT SetObjectName;
|
||||||
|
PFN_vkCmdDebugMarkerBeginEXT Begin;
|
||||||
|
PFN_vkCmdDebugMarkerEndEXT End;
|
||||||
|
PFN_vkCmdDebugMarkerInsertEXT Insert;
|
||||||
|
};//struct DebugMakerFunction
|
||||||
|
|
||||||
|
class DebugMaker
|
||||||
|
{
|
||||||
|
VkDevice device;
|
||||||
|
|
||||||
|
DebugMakerFunction dmf;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
void SetObjectName(uint64_t object, VkDebugReportObjectTypeEXT objectType, const char *name);
|
||||||
|
void SetObjectTag(uint64_t object, VkDebugReportObjectTypeEXT objectType, uint64_t name, size_t tagSize, const void* tag);
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
friend DebugMaker *CreateDebugMaker(VkDevice device);
|
||||||
|
|
||||||
|
DebugMaker(VkDevice dev,const DebugMakerFunction &f)
|
||||||
|
{
|
||||||
|
device=dev;
|
||||||
|
dmf=f;
|
||||||
|
}
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
void Begin(VkCommandBuffer cmdbuffer, const char * pMarkerName, const Color4f &color);
|
||||||
|
void Insert(VkCommandBuffer cmdbuffer, const char *markerName, const Color4f &color);
|
||||||
|
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);}
|
||||||
|
|
||||||
|
DEBUG_MAKER_SET_FUNC(CommandBuffer, COMMAND_BUFFER)
|
||||||
|
DEBUG_MAKER_SET_FUNC(Queue, QUEUE)
|
||||||
|
DEBUG_MAKER_SET_FUNC(Image, IMAGE)
|
||||||
|
DEBUG_MAKER_SET_FUNC(Sampler, SAMPLER)
|
||||||
|
DEBUG_MAKER_SET_FUNC(Buffer, BUFFER)
|
||||||
|
DEBUG_MAKER_SET_FUNC(DeviceMemory, DEVICE_MEMORY)
|
||||||
|
DEBUG_MAKER_SET_FUNC(ShaderModule, SHADER_MODULE)
|
||||||
|
DEBUG_MAKER_SET_FUNC(Pipeline, PIPELINE)
|
||||||
|
DEBUG_MAKER_SET_FUNC(PipelineLayout, PIPELINE_LAYOUT)
|
||||||
|
DEBUG_MAKER_SET_FUNC(RenderPass, RENDER_PASS)
|
||||||
|
DEBUG_MAKER_SET_FUNC(Framebuffer, FRAMEBUFFER)
|
||||||
|
DEBUG_MAKER_SET_FUNC(DescriptorSetLayout, DESCRIPTOR_SET_LAYOUT)
|
||||||
|
DEBUG_MAKER_SET_FUNC(DescriptorSet, DESCRIPTOR_SET)
|
||||||
|
DEBUG_MAKER_SET_FUNC(Semaphore, SEMAPHORE)
|
||||||
|
DEBUG_MAKER_SET_FUNC(Fence, FENCE)
|
||||||
|
DEBUG_MAKER_SET_FUNC(Event, EVENT)
|
||||||
|
|
||||||
|
#undef DEBUG_MAKER_SET_FUNC
|
||||||
|
};//class DebugMaker
|
||||||
|
VK_NAMESPACE_END
|
||||||
|
#endif//HGL_GRAPH_VULKAN_DEBUG_MAKER_INCLUDE
|
@ -3,6 +3,10 @@
|
|||||||
#include<hgl/graph/VKInstance.h>
|
#include<hgl/graph/VKInstance.h>
|
||||||
#include<hgl/graph/VKTexture.h>
|
#include<hgl/graph/VKTexture.h>
|
||||||
|
|
||||||
|
#ifdef _DEBUG
|
||||||
|
#include<hgl/graph/VKDebugMaker.h>
|
||||||
|
#endif//_DEBUG
|
||||||
|
|
||||||
VK_NAMESPACE_BEGIN
|
VK_NAMESPACE_BEGIN
|
||||||
|
|
||||||
constexpr uint32_t ERROR_FAMILY_INDEX=UINT32_MAX;
|
constexpr uint32_t ERROR_FAMILY_INDEX=UINT32_MAX;
|
||||||
@ -40,6 +44,10 @@ struct GPUDeviceAttribute
|
|||||||
|
|
||||||
VkPipelineCache pipeline_cache =VK_NULL_HANDLE;
|
VkPipelineCache pipeline_cache =VK_NULL_HANDLE;
|
||||||
|
|
||||||
|
#ifdef _DEBUG
|
||||||
|
DebugMaker * debug_maker =nullptr;
|
||||||
|
#endif//_DEBUG
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
GPUDeviceAttribute(VulkanInstance *inst,const GPUPhysicalDevice *pd,VkSurfaceKHR s);
|
GPUDeviceAttribute(VulkanInstance *inst,const GPUPhysicalDevice *pd,VkSurfaceKHR s);
|
||||||
|
@ -97,7 +97,9 @@ SET(VK_INST_SOURCE ${SG_INCLUDE_PATH}/VKInstance.h
|
|||||||
Vulkan/VKInstance.cpp)
|
Vulkan/VKInstance.cpp)
|
||||||
|
|
||||||
SET(VK_DEBUG_SOURCE ${SG_INCLUDE_PATH}/VKDebugOut.h
|
SET(VK_DEBUG_SOURCE ${SG_INCLUDE_PATH}/VKDebugOut.h
|
||||||
Vulkan/VKDebugOut.cpp)
|
${SG_INCLUDE_PATH}/VKDebugMaker.h
|
||||||
|
Vulkan/VKDebugOut.cpp
|
||||||
|
Vulkan/VKDebugMaker.cpp)
|
||||||
|
|
||||||
SET(VK_MEMORY_SOURCE ${SG_INCLUDE_PATH}/VKMemory.h
|
SET(VK_MEMORY_SOURCE ${SG_INCLUDE_PATH}/VKMemory.h
|
||||||
${SG_INCLUDE_PATH}/VKMemoryAllocator.h
|
${SG_INCLUDE_PATH}/VKMemoryAllocator.h
|
||||||
|
86
src/SceneGraph/Vulkan/VKDebugMaker.cpp
Normal file
86
src/SceneGraph/Vulkan/VKDebugMaker.cpp
Normal file
@ -0,0 +1,86 @@
|
|||||||
|
#include<hgl/graph/VKDebugMaker.h>
|
||||||
|
|
||||||
|
VK_NAMESPACE_BEGIN
|
||||||
|
void DebugMaker::SetObjectName(uint64_t object, VkDebugReportObjectTypeEXT objectType, const char *name)
|
||||||
|
{
|
||||||
|
// Check for valid function pointer (may not be present if not running in a debugging application)
|
||||||
|
if(!dmf.SetObjectName)return;
|
||||||
|
|
||||||
|
VkDebugMarkerObjectNameInfoEXT nameInfo = {};
|
||||||
|
nameInfo.sType = VK_STRUCTURE_TYPE_DEBUG_MARKER_OBJECT_NAME_INFO_EXT;
|
||||||
|
nameInfo.objectType = objectType;
|
||||||
|
nameInfo.object = object;
|
||||||
|
nameInfo.pObjectName = name;
|
||||||
|
|
||||||
|
dmf.SetObjectName(device, &nameInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DebugMaker::SetObjectTag(uint64_t object, VkDebugReportObjectTypeEXT objectType, uint64_t name, size_t tagSize, const void* tag)
|
||||||
|
{
|
||||||
|
// Check for valid function pointer (may not be present if not running in a debugging application)
|
||||||
|
if(!dmf.SetObjectTag)return;
|
||||||
|
|
||||||
|
VkDebugMarkerObjectTagInfoEXT tagInfo = {};
|
||||||
|
tagInfo.sType = VK_STRUCTURE_TYPE_DEBUG_MARKER_OBJECT_TAG_INFO_EXT;
|
||||||
|
tagInfo.objectType = objectType;
|
||||||
|
tagInfo.object = object;
|
||||||
|
tagInfo.tagName = name;
|
||||||
|
tagInfo.tagSize = tagSize;
|
||||||
|
tagInfo.pTag = tag;
|
||||||
|
|
||||||
|
dmf.SetObjectTag(device, &tagInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DebugMaker::Begin(VkCommandBuffer cmdbuffer, const char * pMarkerName, const Color4f &color)
|
||||||
|
{
|
||||||
|
//Check for valid function pointer (may not be present if not running in a debugging application)
|
||||||
|
if(!dmf.Begin)return;
|
||||||
|
|
||||||
|
VkDebugMarkerMarkerInfoEXT markerInfo = {};
|
||||||
|
markerInfo.sType = VK_STRUCTURE_TYPE_DEBUG_MARKER_MARKER_INFO_EXT;
|
||||||
|
memcpy(markerInfo.color, &color, sizeof(float) * 4);
|
||||||
|
markerInfo.pMarkerName = pMarkerName;
|
||||||
|
|
||||||
|
dmf.Begin(cmdbuffer, &markerInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DebugMaker::Insert(VkCommandBuffer cmdbuffer, const char *markerName, const Color4f &color)
|
||||||
|
{
|
||||||
|
// Check for valid function pointer (may not be present if not running in a debugging application)
|
||||||
|
if(!dmf.Insert)return;
|
||||||
|
|
||||||
|
VkDebugMarkerMarkerInfoEXT markerInfo = {};
|
||||||
|
markerInfo.sType = VK_STRUCTURE_TYPE_DEBUG_MARKER_MARKER_INFO_EXT;
|
||||||
|
memcpy(markerInfo.color, &color, sizeof(float) * 4);
|
||||||
|
markerInfo.pMarkerName = markerName;
|
||||||
|
|
||||||
|
dmf.Insert(cmdbuffer, &markerInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DebugMaker::End(VkCommandBuffer cmdBuffer)
|
||||||
|
{
|
||||||
|
// Check for valid function (may not be present if not running in a debugging application)
|
||||||
|
if(!dmf.End)return;
|
||||||
|
|
||||||
|
dmf.End(cmdBuffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
DebugMaker *CreateDebugMaker(VkDevice device)
|
||||||
|
{
|
||||||
|
DebugMakerFunction dmf;
|
||||||
|
|
||||||
|
dmf.SetObjectTag = reinterpret_cast<PFN_vkDebugMarkerSetObjectTagEXT >(vkGetDeviceProcAddr(device, "vkDebugMarkerSetObjectTagEXT"));
|
||||||
|
dmf.SetObjectName = reinterpret_cast<PFN_vkDebugMarkerSetObjectNameEXT>(vkGetDeviceProcAddr(device, "vkDebugMarkerSetObjectNameEXT"));
|
||||||
|
dmf.Begin = reinterpret_cast<PFN_vkCmdDebugMarkerBeginEXT >(vkGetDeviceProcAddr(device, "vkCmdDebugMarkerBeginEXT"));
|
||||||
|
dmf.End = reinterpret_cast<PFN_vkCmdDebugMarkerEndEXT >(vkGetDeviceProcAddr(device, "vkCmdDebugMarkerEndEXT"));
|
||||||
|
dmf.Insert = reinterpret_cast<PFN_vkCmdDebugMarkerInsertEXT >(vkGetDeviceProcAddr(device, "vkCmdDebugMarkerInsertEXT"));
|
||||||
|
|
||||||
|
if(!dmf.SetObjectTag )return(nullptr);
|
||||||
|
if(!dmf.SetObjectName )return(nullptr);
|
||||||
|
if(!dmf.Begin )return(nullptr);
|
||||||
|
if(!dmf.End )return(nullptr);
|
||||||
|
if(!dmf.Insert )return(nullptr);
|
||||||
|
|
||||||
|
return(new DebugMaker(device,dmf));
|
||||||
|
}
|
||||||
|
VK_NAMESPACE_END
|
@ -6,6 +6,7 @@
|
|||||||
#include<hgl/graph/VKFramebuffer.h>
|
#include<hgl/graph/VKFramebuffer.h>
|
||||||
#include<hgl/graph/VKTexture.h>
|
#include<hgl/graph/VKTexture.h>
|
||||||
#include<hgl/graph/VKDevice.h>
|
#include<hgl/graph/VKDevice.h>
|
||||||
|
#include<hgl/graph/VKDebugMaker.h>
|
||||||
|
|
||||||
#include<iostream>
|
#include<iostream>
|
||||||
#include<iomanip>
|
#include<iomanip>
|
||||||
@ -14,6 +15,10 @@ VK_NAMESPACE_BEGIN
|
|||||||
VkPipelineCache CreatePipelineCache(VkDevice device,const VkPhysicalDeviceProperties &);
|
VkPipelineCache CreatePipelineCache(VkDevice device,const VkPhysicalDeviceProperties &);
|
||||||
Swapchain *CreateSwapchain(const GPUDeviceAttribute *attr,const VkExtent2D &acquire_extent);
|
Swapchain *CreateSwapchain(const GPUDeviceAttribute *attr,const VkExtent2D &acquire_extent);
|
||||||
|
|
||||||
|
#ifdef _DEBUG
|
||||||
|
DebugMaker *CreateDebugMaker(VkDevice);
|
||||||
|
#endif//_DEBUG
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
void SetDeviceExtension(CharPointerList *ext_list,const GPUPhysicalDevice *physical_device)
|
void SetDeviceExtension(CharPointerList *ext_list,const GPUPhysicalDevice *physical_device)
|
||||||
@ -27,8 +32,10 @@ namespace
|
|||||||
#endif//_DEBUG
|
#endif//_DEBUG
|
||||||
// VK_KHR_PUSH_DESCRIPTOR_EXTENSION_NAME,
|
// VK_KHR_PUSH_DESCRIPTOR_EXTENSION_NAME,
|
||||||
// VK_EXT_HDR_METADATA_EXTENSION_NAME,
|
// VK_EXT_HDR_METADATA_EXTENSION_NAME,
|
||||||
VK_EXT_FULL_SCREEN_EXCLUSIVE_EXTENSION_NAME,
|
// VK_EXT_FULL_SCREEN_EXCLUSIVE_EXTENSION_NAME,
|
||||||
// VK_AMD_DISPLAY_NATIVE_HDR_EXTENSION_NAME
|
// VK_AMD_DISPLAY_NATIVE_HDR_EXTENSION_NAME,
|
||||||
|
|
||||||
|
// VK_EXT_SAMPLER_FILTER_MINMAX_EXTENSION_NAME,
|
||||||
};
|
};
|
||||||
|
|
||||||
for(const char *ext_name:require_ext_list)
|
for(const char *ext_name:require_ext_list)
|
||||||
@ -412,6 +419,10 @@ GPUDevice *CreateRenderDevice(VulkanInstance *inst,const GPUPhysicalDevice *phys
|
|||||||
if(!device_attr->device)
|
if(!device_attr->device)
|
||||||
return(nullptr);
|
return(nullptr);
|
||||||
|
|
||||||
|
#ifdef _DEBUG
|
||||||
|
device_attr->debug_maker=CreateDebugMaker(device_attr->device);
|
||||||
|
#endif//_DEBUG
|
||||||
|
|
||||||
GetDeviceQueue(device_attr);
|
GetDeviceQueue(device_attr);
|
||||||
|
|
||||||
device_attr->cmd_pool=CreateCommandPool(device_attr->device,device_attr->graphics_family);
|
device_attr->cmd_pool=CreateCommandPool(device_attr->device,device_attr->graphics_family);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user