From 58a87a045248e77228f83e19eaa0320436afc106 Mon Sep 17 00:00:00 2001 From: turanszkij Date: Wed, 18 May 2016 01:28:26 +0200 Subject: [PATCH] Added graphicsdevice event registration supprt --- .../WickedEngine_SHARED.vcxitems.filters | 129 +++++++++--------- WickedEngine/wiGraphicsAPI.h | 4 + WickedEngine/wiGraphicsAPI_DX11.cpp | 14 ++ WickedEngine/wiGraphicsAPI_DX11.h | 5 + WickedEngine/wiRenderer.cpp | 3 + 5 files changed, 92 insertions(+), 63 deletions(-) diff --git a/WickedEngine/WickedEngine_SHARED.vcxitems.filters b/WickedEngine/WickedEngine_SHARED.vcxitems.filters index 0d58ea4ac..29bad3d27 100644 --- a/WickedEngine/WickedEngine_SHARED.vcxitems.filters +++ b/WickedEngine/WickedEngine_SHARED.vcxitems.filters @@ -31,6 +31,9 @@ {d6f94528-ce59-4fa3-a0b9-d5c04994ac71} + + {3d5f1098-95e6-4baa-9e39-864be28a5b64} + @@ -153,48 +156,21 @@ ENGINE - - ENGINE - ENGINE - - ENGINE - ENGINE - - ENGINE - ENGINE - - ENGINE - - - ENGINE - - - ENGINE - - - ENGINE - ENGINE ENGINE - - ENGINE - - - ENGINE - ENGINE @@ -210,9 +186,6 @@ ENGINE - - ENGINE - ENGINE @@ -225,9 +198,6 @@ ENGINE - - ENGINE - ENGINE @@ -1023,6 +993,39 @@ BULLET + + ENGINE\Graphics + + + ENGINE\Graphics + + + ENGINE\Graphics + + + ENGINE\Graphics + + + ENGINE\Graphics + + + ENGINE\Graphics + + + ENGINE\Graphics + + + ENGINE\Graphics + + + ENGINE\Graphics + + + ENGINE\Graphics + + + ENGINE\Graphics + @@ -1154,18 +1157,9 @@ ENGINE - - ENGINE - - - ENGINE - ENGINE - - ENGINE - ENGINE @@ -1181,15 +1175,6 @@ ENGINE - - ENGINE - - - ENGINE - - - ENGINE - ENGINE @@ -1253,21 +1238,9 @@ ENGINE - - ENGINE - ENGINE - - ENGINE - - - ENGINE - - - ENGINE - ENGINE\Components @@ -1778,6 +1751,36 @@ BULLET + + ENGINE\Graphics + + + ENGINE\Graphics + + + ENGINE\Graphics + + + ENGINE\Graphics + + + ENGINE\Graphics + + + ENGINE\Graphics + + + ENGINE\Graphics + + + ENGINE\Graphics + + + ENGINE\Graphics + + + ENGINE\Graphics + diff --git a/WickedEngine/wiGraphicsAPI.h b/WickedEngine/wiGraphicsAPI.h index 4c23d12a8..14a8dca96 100644 --- a/WickedEngine/wiGraphicsAPI.h +++ b/WickedEngine/wiGraphicsAPI.h @@ -799,6 +799,10 @@ namespace wiGraphicsTypes virtual Texture2D GetBackBuffer() = 0; + virtual void EventBegin(const wchar_t* name) = 0; + virtual void EventEnd() = 0; + virtual void SetMarker(const wchar_t* name) = 0; + ///////////////Thread-sensitive//////////////////////// virtual void BindViewports(UINT NumViewports, const ViewPort *pViewports, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) = 0; diff --git a/WickedEngine/wiGraphicsAPI_DX11.cpp b/WickedEngine/wiGraphicsAPI_DX11.cpp index fdbf977f0..b796064c2 100644 --- a/WickedEngine/wiGraphicsAPI_DX11.cpp +++ b/WickedEngine/wiGraphicsAPI_DX11.cpp @@ -137,6 +137,8 @@ GraphicsDevice_DX11::GraphicsDevice_DX11(Windows::UI::Core::CoreWindow^ window) DEFERREDCONTEXT_SUPPORT = false; } + hr = deviceContexts[GRAPHICSTHREAD_IMMEDIATE]->QueryInterface(__uuidof(userDefinedAnnotation), + reinterpret_cast(&userDefinedAnnotation)); // Create a render target view backBuffer = NULL; @@ -1449,6 +1451,18 @@ void GraphicsDevice_DX11::FinishCommandList(GRAPHICSTHREAD thread) deviceContexts[thread]->FinishCommandList(true, &commandLists[thread]); } +void GraphicsDevice_DX11::EventBegin(const wchar_t* name) +{ + userDefinedAnnotation->BeginEvent(name); +} +void GraphicsDevice_DX11::EventEnd() +{ + userDefinedAnnotation->EndEvent(); +} +void GraphicsDevice_DX11::SetMarker(const wchar_t* name) +{ + userDefinedAnnotation->SetMarker(name); +} HRESULT GraphicsDevice_DX11::CreateTextureFromFile(const wstring& fileName, Texture2D **ppTexture, bool mipMaps, GRAPHICSTHREAD threadID) { diff --git a/WickedEngine/wiGraphicsAPI_DX11.h b/WickedEngine/wiGraphicsAPI_DX11.h index 1a217da17..cea98a47b 100644 --- a/WickedEngine/wiGraphicsAPI_DX11.h +++ b/WickedEngine/wiGraphicsAPI_DX11.h @@ -22,6 +22,7 @@ namespace wiGraphicsTypes ID3D11DeviceContext* deviceContexts[GRAPHICSTHREAD_COUNT]; ID3D11CommandList* commandLists[GRAPHICSTHREAD_COUNT]; bool DX11, DEFERREDCONTEXT_SUPPORT; + ID3DUserDefinedAnnotation* userDefinedAnnotation; public: #ifndef WINSTORE_SUPPORT @@ -68,6 +69,10 @@ namespace wiGraphicsTypes virtual Texture2D GetBackBuffer(); + virtual void EventBegin(const wchar_t* name); + virtual void EventEnd(); + virtual void SetMarker(const wchar_t* name); + ///////////////Thread-sensitive//////////////////////// virtual void BindViewports(UINT NumViewports, const ViewPort *pViewports, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) { diff --git a/WickedEngine/wiRenderer.cpp b/WickedEngine/wiRenderer.cpp index 0aa459016..2a0d1d38a 100644 --- a/WickedEngine/wiRenderer.cpp +++ b/WickedEngine/wiRenderer.cpp @@ -2454,6 +2454,8 @@ void wiRenderer::DrawWorld(Camera* camera, bool DX11Eff, int tessF, GRAPHICSTHRE } } + wiRenderer::GetDevice()->EventBegin(L"Draw Models"); + if(DX11Eff && tessF) GetDevice()->BindPrimitiveTopology(PATCHLIST,threadID); else @@ -2584,6 +2586,7 @@ void wiRenderer::DrawWorld(Camera* camera, bool DX11Eff, int tessF, GRAPHICSTHRE GetDevice()->BindDS(nullptr,threadID); GetDevice()->BindHS(nullptr,threadID); + wiRenderer::GetDevice()->EventEnd(); } }