improved codes of Debug

This commit is contained in:
HuYingzhuo(hugo/hyzboy) 2022-09-27 19:41:28 +08:00
parent 981a1adf4c
commit cc02b719e6
7 changed files with 71 additions and 16 deletions

View File

@ -154,6 +154,39 @@ private:
CreateGBufferSampler();
#ifdef _DEBUG
{
auto da=device->GetDeviceAttribute();
VkQueue q=*(gbuffer.rt->GetQueue());
VkFramebuffer fbo= gbuffer.rt->GetFramebuffer()->GetFramebuffer();
VkRenderPass rp= gbuffer.rp->GetVkRenderPass();
VkSemaphore sem=*(gbuffer.rt->GetRenderCompleteSemaphore());
VkCommandBuffer cb=*(gbuffer.cmd);
VkSampler s=*(gbuffer.sampler);
if(da->debug_maker)
{
da->debug_maker->SetQueue( q, "[debug maker] GBufferQueue");
da->debug_maker->SetFramebuffer( fbo,"[debug maker] GBufferFBO");
da->debug_maker->SetRenderPass( rp, "[debug maker] GBufferRenderpass");
da->debug_maker->SetCommandBuffer( cb, "[debug maker] GBufferCommandBuffer");
da->debug_maker->SetSampler( s, "[debug maker] GBufferSampler");
da->debug_maker->SetSemaphore( sem,"[debug maker] GBufferSemaphore");
}
if(da->debug_utils)
{
da->debug_utils->SetQueue( q, "[debug utils] GBufferQueue");
da->debug_utils->SetFramebuffer( fbo,"[debug utils] GBufferFBO");
da->debug_utils->SetRenderPass( rp, "[debug utils] GBufferRenderpass");
da->debug_utils->SetCommandBuffer( cb, "[debug utils] GBufferCommandBuffer");
da->debug_utils->SetSampler( s, "[debug utils] GBufferSampler");
da->debug_utils->SetSemaphore( sem,"[debug utils] GBufferSemaphore");
}
}
#endif//_DEBUG
return(gbuffer.rt);
}
@ -361,7 +394,7 @@ private:
if(!gbuffer.cmd->BindFramebuffer(gbuffer.rt->GetRenderPass(),gbuffer.rt->GetFramebuffer()))
return(false);
gbuffer.cmd->BeginRegion("GBuffer",Color4f(1,0,0,1));
gbuffer.cmd->BeginRegion("GBuffer Begin",Color4f(1,0,0,1));
if(!gbuffer.cmd->BeginRenderPass())
return(false);
@ -405,13 +438,13 @@ public:
{
const double timer=GetDoubleTime();
// White
lights.position = Vector4f(0.0f, 0.0f, 25.0f, 0.0f);
lights.color = Vector4f(15.0f);
lights.radius = 155.0f;
// White
lights.position = Vector4f(0.0f, 0.0f, 25.0f, 0.0f);
lights.color = Vector4f(15.0f);
lights.radius = 155.0f;
lights.position.x = sin(rad2deg(timer/100)) * 100.0f;
lights.position.y = cos(rad2deg(timer/100)) * 100.0f;
lights.position.x = sin(rad2deg(timer/100)) * 100.0f;
lights.position.y = cos(rad2deg(timer/100)) * 100.0f;
ubo_lights->Write(&lights);
}

View File

@ -27,11 +27,11 @@ public:
bool End(){return(vkEndCommandBuffer(cmd_buf)==VK_SUCCESS);}
#ifdef _DEBUG
void SetDebugName(const char *);
void BeginRegion(const char *,const Color4f &);
void SetDebugName(const UTF8String &);
void BeginRegion(const UTF8String &,const Color4f &);
void EndRegion();
#else
void BeginRegion(const char *,const Color4f &){}
void BeginRegion(const UTF8String &,const Color4f &){}
void EndRegion(){}
#endif//_DEBUG
};//class GPUCmdBuffer

View File

@ -90,6 +90,8 @@ public:
DU_FUNC(DeferredOperationKHR, DEFERRED_OPERATION_KHR)
DU_FUNC(IndirectCommandsLayoutNV, INDIRECT_COMMANDS_LAYOUT_NV)
// DU_FUNC(BufferCollectionFuchsia, BUFFER_COLLECTION_FUCHSIA)
#undef DU_FUNC
void QueueBegin (VkQueue,const char *,const Color4f &color=Color4f(1,1,1,1));
void QueueEnd (VkQueue q){duf.QueueEnd(q);}

View File

@ -83,6 +83,23 @@ public:
const bool isIntegratedGPU ()const{return(properties.deviceType==VK_PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU);} ///<是否是集成显卡
const bool isVirtualGPU ()const{return(properties.deviceType==VK_PHYSICAL_DEVICE_TYPE_VIRTUAL_GPU);} ///<是否是虚拟显卡
#define HGL_VK_IS_BRAND(name) (hgl::stricmp(properties.deviceName,#name,sizeof(#name))==0)
const bool isMicrosoft ()const{return HGL_VK_IS_BRAND(Microsoft);}
const bool isMesa ()const{return HGL_VK_IS_BRAND(Mesa );}
const bool isAMD ()const{return HGL_VK_IS_BRAND(AMD )
||HGL_VK_IS_BRAND(ATI );}
const bool isNvidia ()const{return HGL_VK_IS_BRAND(nVidia );}
const bool isIntel ()const{return HGL_VK_IS_BRAND(Intel );}
const bool isQualcomm ()const{return HGL_VK_IS_BRAND(Adreno );}
const bool isApple ()const{return HGL_VK_IS_BRAND(Apple );}
const bool isImgTec ()const{return HGL_VK_IS_BRAND(ImgTec )
||HGL_VK_IS_BRAND(PowerVR );}
const bool isARM ()const{return HGL_VK_IS_BRAND(Arm )
||HGL_VK_IS_BRAND(Mali );}
#undef HGL_VK_IS_BRAND
public:
VkFormatProperties GetFormatProperties(const VkFormat format)const

View File

@ -26,6 +26,8 @@ private:
public:
virtual ~GPUQueue();
operator VkQueue(){return queue;}
VkResult Present(const VkPresentInfoKHR *pi){return vkQueuePresentKHR(queue,pi);}

View File

@ -41,6 +41,7 @@ public:
virtual ~RenderTarget();
GPUQueue * GetQueue () {return queue;}
const VkExtent2D & GetExtent ()const {return extent;}
virtual RenderPass * GetRenderPass () {return render_pass;}
virtual const VkRenderPass GetVkRenderPass ()const {return render_pass->GetVkRenderPass();}

View File

@ -26,22 +26,22 @@ bool GPUCmdBuffer::Begin()
}
#ifdef _DEBUG
void GPUCmdBuffer::SetDebugName(const char *object_name)
void GPUCmdBuffer::SetDebugName(const UTF8String &object_name)
{
if(dev_attr->debug_maker)
dev_attr->debug_maker->SetCommandBuffer(cmd_buf,object_name);
dev_attr->debug_maker->SetCommandBuffer(cmd_buf,"[debug_maker]"+object_name);
if(dev_attr->debug_utils)
dev_attr->debug_utils->SetCommandBuffer(cmd_buf,object_name);
dev_attr->debug_utils->SetCommandBuffer(cmd_buf,"[debug_utils]"+object_name);
}
void GPUCmdBuffer::BeginRegion(const char *region_name,const Color4f &color)
void GPUCmdBuffer::BeginRegion(const UTF8String &region_name,const Color4f &color)
{
if(dev_attr->debug_maker)
dev_attr->debug_maker->Begin(cmd_buf,region_name,color);
dev_attr->debug_maker->Begin(cmd_buf,"[debug_maker]"+region_name,color);
if(dev_attr->debug_utils)
dev_attr->debug_utils->CmdBegin(cmd_buf,region_name,color);
dev_attr->debug_utils->CmdBegin(cmd_buf,"[debug_utils]"+region_name,color);
}
void GPUCmdBuffer::EndRegion()