From 04ad98690b70529cea7a880f63b90d8fb2d64661 Mon Sep 17 00:00:00 2001 From: Robin Kertels Date: Thu, 19 Sep 2024 16:28:17 +0200 Subject: [PATCH] [d3d9] Add SWVP HUD item --- README.md | 2 ++ src/d3d9/d3d9_device.h | 4 ++++ src/d3d9/d3d9_hud.cpp | 41 +++++++++++++++++++++++++++++++++++++ src/d3d9/d3d9_hud.h | 25 +++++++++++++++++++--- src/d3d9/d3d9_swapchain.cpp | 1 + 5 files changed, 70 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index c50ecec51..6182f5073 100644 --- a/README.md +++ b/README.md @@ -62,6 +62,8 @@ The `DXVK_HUD` environment variable controls a HUD which can display the framera - `cs`: Shows worker thread statistics. - `compiler`: Shows shader compiler activity - `samplers`: Shows the current number of sampler pairs used *[D3D9 Only]* +- `ffshaders`: Shows the current number of shaders generated from fixed function state *[D3D9 Only]* +- `swvp`: Shows whether or not the device is running in software vertex processing mode *[D3D9 Only]* - `scale=x`: Scales the HUD by a factor of `x` (e.g. `1.5`) - `opacity=y`: Adjusts the HUD opacity by a factor of `y` (e.g. `0.5`, `1.0` being fully opaque). diff --git a/src/d3d9/d3d9_device.h b/src/d3d9/d3d9_device.h index 0892222ed..ecceeecbb 100644 --- a/src/d3d9/d3d9_device.h +++ b/src/d3d9/d3d9_device.h @@ -1026,6 +1026,10 @@ namespace dxvk { return m_behaviorFlags & (D3DCREATE_MIXED_VERTEXPROCESSING | D3DCREATE_SOFTWARE_VERTEXPROCESSING); } + bool IsSWVP() const { + return m_isSWVP; + } + UINT GetFixedFunctionVSCount() const { return m_ffModules.GetVSCount(); } diff --git a/src/d3d9/d3d9_hud.cpp b/src/d3d9/d3d9_hud.cpp index eec8cf78e..d958584b3 100644 --- a/src/d3d9/d3d9_hud.cpp +++ b/src/d3d9/d3d9_hud.cpp @@ -125,4 +125,45 @@ namespace dxvk::hud { return position; } + HudSWVPState::HudSWVPState(D3D9DeviceEx* device) + : m_device (device) + , m_isSWVPText ("") {} + + + void HudSWVPState::update(dxvk::high_resolution_clock::time_point time) { + if (m_device->IsSWVP()) { + if (m_device->CanOnlySWVP()) { + m_isSWVPText = "SWVP"; + } else { + m_isSWVPText = "SWVP (Mixed)"; + } + } else { + if (m_device->CanSWVP()) { + m_isSWVPText = "HWVP (Mixed)"; + } else { + m_isSWVPText = "HWVP"; + } + } + } + + + HudPos HudSWVPState::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 }, + "Vertex Processing:"); + + renderer.drawText(16.0f, + { position.x + 240.0f, position.y }, + { 1.0f, 1.0f, 1.0f, 1.0f }, + m_isSWVPText); + + position.y += 8.0f; + return position; + } + } diff --git a/src/d3d9/d3d9_hud.h b/src/d3d9/d3d9_hud.h index d54bde574..7c43ec0cd 100644 --- a/src/d3d9/d3d9_hud.h +++ b/src/d3d9/d3d9_hud.h @@ -78,11 +78,30 @@ namespace dxvk::hud { D3D9DeviceEx* m_device; - dxvk::high_resolution_clock::time_point m_lastUpdate - = dxvk::high_resolution_clock::now(); - std::string m_ffShaderCount; }; + /** + * \brief HUD item to whether or not we're in SWVP mode + */ + class HudSWVPState : public HudItem { + public: + + HudSWVPState(D3D9DeviceEx* device); + + void update(dxvk::high_resolution_clock::time_point time); + + HudPos render( + HudRenderer& renderer, + HudPos position); + + private: + + D3D9DeviceEx* m_device; + + std::string m_isSWVPText; + + }; + } \ No newline at end of file diff --git a/src/d3d9/d3d9_swapchain.cpp b/src/d3d9/d3d9_swapchain.cpp index 35af5aa07..fcfd65d0d 100644 --- a/src/d3d9/d3d9_swapchain.cpp +++ b/src/d3d9/d3d9_swapchain.cpp @@ -1101,6 +1101,7 @@ namespace dxvk { m_hud->addItem("api", 1, GetApiName()); m_hud->addItem("samplers", -1, m_parent); m_hud->addItem("ffshaders", -1, m_parent); + m_hud->addItem("swvp", -1, m_parent); #ifdef D3D9_ALLOW_UNMAPPING m_hud->addItem("memory", -1, m_parent);