diff --git a/pcsx2/GS/Renderers/DX11/GSDevice11.cpp b/pcsx2/GS/Renderers/DX11/GSDevice11.cpp index 686f1f2f8b..7e081da308 100644 --- a/pcsx2/GS/Renderers/DX11/GSDevice11.cpp +++ b/pcsx2/GS/Renderers/DX11/GSDevice11.cpp @@ -29,6 +29,7 @@ #include #include #include +#include static bool SupportsTextureFormat(ID3D11Device* dev, DXGI_FORMAT format) { @@ -90,6 +91,8 @@ bool GSDevice11::Create() m_dev = static_cast(g_host_display->GetDevice()); m_ctx = static_cast(g_host_display->GetContext()); + if (GSConfig.UseDebugDevice) + m_annotation = m_ctx.try_query(); level = m_dev->GetFeatureLevel(); const bool support_feature_level_11_0 = (level >= D3D_FEATURE_LEVEL_11_0); @@ -451,6 +454,40 @@ void GSDevice11::ClearStencil(GSTexture* t, u8 c) m_ctx->ClearDepthStencilView(*(GSTexture11*)t, D3D11_CLEAR_STENCIL, 0, c); } +void GSDevice11::PushDebugGroup(const char* fmt, ...) +{ + if (!m_annotation) + return; + + std::va_list ap; + va_start(ap, fmt); + std::string str(StringUtil::StdStringFromFormatV(fmt, ap)); + va_end(ap); + + m_annotation->BeginEvent(StringUtil::UTF8StringToWideString(str).c_str()); +} + +void GSDevice11::PopDebugGroup() +{ + if (!m_annotation) + return; + + m_annotation->EndEvent(); +} + +void GSDevice11::InsertDebugMessage(DebugMessageCategory category, const char* fmt, ...) +{ + if (!m_annotation) + return; + + std::va_list ap; + va_start(ap, fmt); + std::string str(StringUtil::StdStringFromFormatV(fmt, ap)); + va_end(ap); + + m_annotation->SetMarker(StringUtil::UTF8StringToWideString(str).c_str()); +} + GSTexture* GSDevice11::CreateSurface(GSTexture::Type type, int width, int height, int levels, GSTexture::Format format) { D3D11_TEXTURE2D_DESC desc = {}; diff --git a/pcsx2/GS/Renderers/DX11/GSDevice11.h b/pcsx2/GS/Renderers/DX11/GSDevice11.h index 18203b7de3..30305e5347 100644 --- a/pcsx2/GS/Renderers/DX11/GSDevice11.h +++ b/pcsx2/GS/Renderers/DX11/GSDevice11.h @@ -22,6 +22,7 @@ #include #include #include +#include struct GSVertexShader11 { @@ -130,6 +131,7 @@ private: wil::com_ptr_nothrow m_dev; wil::com_ptr_nothrow m_ctx; + wil::com_ptr_nothrow m_annotation; wil::com_ptr_nothrow m_swapchain; wil::com_ptr_nothrow m_vb; wil::com_ptr_nothrow m_ib; @@ -257,6 +259,10 @@ public: void ClearDepth(GSTexture* t) override; void ClearStencil(GSTexture* t, u8 c) override; + void PushDebugGroup(const char* fmt, ...) override; + void PopDebugGroup() override; + void InsertDebugMessage(DebugMessageCategory category, const char* fmt, ...) override; + void CloneTexture(GSTexture* src, GSTexture** dest, const GSVector4i& rect); void CopyRect(GSTexture* sTex, GSTexture* dTex, const GSVector4i& r, u32 destX, u32 destY) override;