From 010738c107d771dd6fc34bae052789c5536e35ea Mon Sep 17 00:00:00 2001 From: Robin Kertels Date: Tue, 17 Sep 2024 17:51:44 +0200 Subject: [PATCH] [d3d9] Add HUD item for FF shaders --- src/d3d9/d3d9_device.h | 12 ++++++++++++ src/d3d9/d3d9_fixed_function.h | 9 ++++++++- src/d3d9/d3d9_hud.cpp | 35 +++++++++++++++++++++++++++++++++- src/d3d9/d3d9_hud.h | 25 ++++++++++++++++++++++++ src/d3d9/d3d9_swapchain.cpp | 1 + src/d3d9/d3d9_swvp_emu.h | 4 ++++ 6 files changed, 84 insertions(+), 2 deletions(-) diff --git a/src/d3d9/d3d9_device.h b/src/d3d9/d3d9_device.h index 114a0b9bb..5827e2606 100644 --- a/src/d3d9/d3d9_device.h +++ b/src/d3d9/d3d9_device.h @@ -1022,6 +1022,18 @@ namespace dxvk { return m_behaviorFlags & D3DCREATE_SOFTWARE_VERTEXPROCESSING; } + UINT GetFixedFunctionVSCount() const { + return m_ffModules.GetVSCount(); + } + + UINT GetFixedFunctionFSCount() const { + return m_ffModules.GetFSCount(); + } + + UINT GetSWVPShaderCount() const { + return m_swvpEmulator.GetShaderCount(); + } + private: DxvkCsChunkRef AllocCsChunk() { diff --git a/src/d3d9/d3d9_fixed_function.h b/src/d3d9/d3d9_fixed_function.h index 58ebdbcdc..85432ce52 100644 --- a/src/d3d9/d3d9_fixed_function.h +++ b/src/d3d9/d3d9_fixed_function.h @@ -9,7 +9,6 @@ #include "../dxso/dxso_isgn.h" #include -#include namespace dxvk { @@ -253,6 +252,14 @@ namespace dxvk { D3D9DeviceEx* pDevice, const D3D9FFShaderKeyFS& ShaderKey); + UINT GetVSCount() const { + return m_vsModules.size(); + } + + UINT GetFSCount() const { + return m_fsModules.size(); + } + private: std::unordered_map< diff --git a/src/d3d9/d3d9_hud.cpp b/src/d3d9/d3d9_hud.cpp index b9ab5f433..eec8cf78e 100644 --- a/src/d3d9/d3d9_hud.cpp +++ b/src/d3d9/d3d9_hud.cpp @@ -92,4 +92,37 @@ namespace dxvk::hud { return position; } -} \ No newline at end of file + HudFixedFunctionShaders::HudFixedFunctionShaders(D3D9DeviceEx* device) + : m_device (device) + , m_ffShaderCount ("") {} + + + void HudFixedFunctionShaders::update(dxvk::high_resolution_clock::time_point time) { + m_ffShaderCount = str::format( + "VS: ", m_device->GetFixedFunctionVSCount(), + " FS: ", m_device->GetFixedFunctionFSCount(), + " SWVP: ", m_device->GetSWVPShaderCount() + ); + } + + + HudPos HudFixedFunctionShaders::render( + HudRenderer& renderer, + HudPos position) { + position.y += 16.0f; + + renderer.drawText(16.0f, + { position.x, position.y }, + { 0.0f, 1.0f, 0.75f, 1.0f }, + "FF Shaders:"); + + renderer.drawText(16.0f, + { position.x + 155.0f, position.y }, + { 1.0f, 1.0f, 1.0f, 1.0f }, + m_ffShaderCount); + + position.y += 8.0f; + return position; + } + +} diff --git a/src/d3d9/d3d9_hud.h b/src/d3d9/d3d9_hud.h index b0060ef36..d54bde574 100644 --- a/src/d3d9/d3d9_hud.h +++ b/src/d3d9/d3d9_hud.h @@ -60,4 +60,29 @@ namespace dxvk::hud { }; + /** + * \brief HUD item to display amount of generated fixed function shaders + */ + class HudFixedFunctionShaders : public HudItem { + public: + + HudFixedFunctionShaders(D3D9DeviceEx* device); + + void update(dxvk::high_resolution_clock::time_point time); + + HudPos render( + HudRenderer& renderer, + HudPos position); + + private: + + D3D9DeviceEx* m_device; + + dxvk::high_resolution_clock::time_point m_lastUpdate + = dxvk::high_resolution_clock::now(); + + std::string m_ffShaderCount; + + }; + } \ No newline at end of file diff --git a/src/d3d9/d3d9_swapchain.cpp b/src/d3d9/d3d9_swapchain.cpp index 4ee347c2e..862cdffbb 100644 --- a/src/d3d9/d3d9_swapchain.cpp +++ b/src/d3d9/d3d9_swapchain.cpp @@ -1098,6 +1098,7 @@ namespace dxvk { if (m_hud != nullptr) { m_hud->addItem("api", 1, GetApiName()); m_hud->addItem("samplers", -1, m_parent); + m_hud->addItem("ffshaders", -1, m_parent); #ifdef D3D9_ALLOW_UNMAPPING m_hud->addItem("memory", -1, m_parent); diff --git a/src/d3d9/d3d9_swvp_emu.h b/src/d3d9/d3d9_swvp_emu.h index 905a5766b..530a140cf 100644 --- a/src/d3d9/d3d9_swvp_emu.h +++ b/src/d3d9/d3d9_swvp_emu.h @@ -40,6 +40,10 @@ namespace dxvk { Rc GetShaderModule(D3D9DeviceEx* pDevice, D3D9CompactVertexElements&& elements); + UINT GetShaderCount() const { + return m_modules.size(); + } + private: dxvk::mutex m_mutex;