Skip to content

Commit

Permalink
[d3d9] Add SWVP HUD item
Browse files Browse the repository at this point in the history
  • Loading branch information
K0bin committed Sep 21, 2024
1 parent 0d7a272 commit 19792a4
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 3 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).

Expand Down
4 changes: 4 additions & 0 deletions src/d3d9/d3d9_device.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
41 changes: 41 additions & 0 deletions src/d3d9/d3d9_hud.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

}
25 changes: 22 additions & 3 deletions src/d3d9/d3d9_hud.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

};

}
1 change: 1 addition & 0 deletions src/d3d9/d3d9_swapchain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1101,6 +1101,7 @@ namespace dxvk {
m_hud->addItem<hud::HudClientApiItem>("api", 1, GetApiName());
m_hud->addItem<hud::HudSamplerCount>("samplers", -1, m_parent);
m_hud->addItem<hud::HudFixedFunctionShaders>("ffshaders", -1, m_parent);
m_hud->addItem<hud::HudSWVPState>("swvp", -1, m_parent);

#ifdef D3D9_ALLOW_UNMAPPING
m_hud->addItem<hud::HudTextureMemory>("memory", -1, m_parent);
Expand Down

0 comments on commit 19792a4

Please sign in to comment.