mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-01-31 14:52:11 +01:00
[hud] Remove legacy code
This commit is contained in:
parent
3415376984
commit
ed69da0fff
@ -5,15 +5,10 @@
|
||||
namespace dxvk::hud {
|
||||
|
||||
Hud::Hud(
|
||||
const Rc<DxvkDevice>& device,
|
||||
const HudConfig& config)
|
||||
: m_config (config),
|
||||
m_device (device),
|
||||
const Rc<DxvkDevice>& device)
|
||||
: m_device (device),
|
||||
m_uniformBuffer (createUniformBuffer()),
|
||||
m_renderer (device),
|
||||
m_hudDeviceInfo (device),
|
||||
m_hudFramerate (config.elements),
|
||||
m_hudStats (config.elements) {
|
||||
m_renderer (device) {
|
||||
// Set up constant state
|
||||
m_rsState.polygonMode = VK_POLYGON_MODE_FILL;
|
||||
m_rsState.cullMode = VK_CULL_MODE_BACK_BIT;
|
||||
@ -55,8 +50,6 @@ namespace dxvk::hud {
|
||||
|
||||
void Hud::update() {
|
||||
m_hudItems.update();
|
||||
m_hudFramerate.update();
|
||||
m_hudStats.update(m_device);
|
||||
}
|
||||
|
||||
|
||||
@ -71,16 +64,7 @@ namespace dxvk::hud {
|
||||
|
||||
|
||||
Rc<Hud> Hud::createHud(const Rc<DxvkDevice>& device) {
|
||||
std::string hudElements = env::getEnvVar("DXVK_HUD");
|
||||
|
||||
if (hudElements.empty())
|
||||
hudElements = device->config().hud;
|
||||
|
||||
HudConfig config(hudElements);
|
||||
|
||||
return !config.elements.isClear()
|
||||
? new Hud(device, config)
|
||||
: nullptr;
|
||||
return new Hud(device);
|
||||
}
|
||||
|
||||
|
||||
@ -97,11 +81,6 @@ namespace dxvk::hud {
|
||||
|
||||
void Hud::renderHudElements(const Rc<DxvkContext>& ctx) {
|
||||
m_hudItems.render(m_renderer);
|
||||
|
||||
HudPos position = { 8.0f, 24.0f };
|
||||
|
||||
position = m_hudFramerate.render(m_renderer, position);
|
||||
position = m_hudStats .render(m_renderer, position);
|
||||
}
|
||||
|
||||
|
||||
|
@ -2,14 +2,8 @@
|
||||
|
||||
#include "../dxvk_device.h"
|
||||
|
||||
#include "../util/util_env.h"
|
||||
|
||||
#include "dxvk_hud_config.h"
|
||||
#include "dxvk_hud_devinfo.h"
|
||||
#include "dxvk_hud_item.h"
|
||||
#include "dxvk_hud_fps.h"
|
||||
#include "dxvk_hud_renderer.h"
|
||||
#include "dxvk_hud_stats.h"
|
||||
|
||||
namespace dxvk::hud {
|
||||
|
||||
@ -31,9 +25,7 @@ namespace dxvk::hud {
|
||||
|
||||
public:
|
||||
|
||||
Hud(
|
||||
const Rc<DxvkDevice>& device,
|
||||
const HudConfig& config);
|
||||
Hud(const Rc<DxvkDevice>& device);
|
||||
|
||||
~Hud();
|
||||
|
||||
@ -81,7 +73,6 @@ namespace dxvk::hud {
|
||||
|
||||
private:
|
||||
|
||||
const HudConfig m_config;
|
||||
const Rc<DxvkDevice> m_device;
|
||||
|
||||
Rc<DxvkBuffer> m_uniformBuffer;
|
||||
@ -91,9 +82,6 @@ namespace dxvk::hud {
|
||||
|
||||
HudUniformData m_uniformData;
|
||||
HudRenderer m_renderer;
|
||||
HudDeviceInfo m_hudDeviceInfo;
|
||||
HudFps m_hudFramerate;
|
||||
HudStats m_hudStats;
|
||||
HudItemSet m_hudItems;
|
||||
|
||||
void setupRendererState(
|
||||
|
@ -1,59 +0,0 @@
|
||||
#include "dxvk_hud_config.h"
|
||||
|
||||
#include <unordered_map>
|
||||
|
||||
namespace dxvk::hud {
|
||||
|
||||
const std::unordered_map<std::string, HudElement> g_hudElements = {{
|
||||
{ "devinfo", HudElement::DeviceInfo },
|
||||
{ "fps", HudElement::Framerate },
|
||||
{ "frametimes", HudElement::Frametimes },
|
||||
{ "drawcalls", HudElement::StatDrawCalls },
|
||||
{ "submissions", HudElement::StatSubmissions },
|
||||
{ "pipelines", HudElement::StatPipelines },
|
||||
{ "memory", HudElement::StatMemory },
|
||||
{ "gpuload", HudElement::StatGpuLoad },
|
||||
{ "version", HudElement::DxvkVersion },
|
||||
{ "api", HudElement::DxvkClientApi },
|
||||
{ "compiler", HudElement::CompilerActivity },
|
||||
}};
|
||||
|
||||
|
||||
HudConfig::HudConfig() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
HudConfig::HudConfig(const std::string& configStr) {
|
||||
if (configStr == "1") {
|
||||
this->elements.set(
|
||||
HudElement::DeviceInfo,
|
||||
HudElement::Framerate);
|
||||
} else if (configStr == "full") {
|
||||
for (auto pair : g_hudElements)
|
||||
this->elements.set(pair.second);
|
||||
} else {
|
||||
std::string::size_type pos = 0;
|
||||
std::string::size_type end = 0;
|
||||
|
||||
while (pos < configStr.size()) {
|
||||
end = configStr.find(',', pos);
|
||||
|
||||
if (end == std::string::npos)
|
||||
end = configStr.size();
|
||||
|
||||
std::string configPart = configStr.substr(pos, end - pos);
|
||||
|
||||
auto element = g_hudElements.find(configPart);
|
||||
|
||||
if (element != g_hudElements.cend()) {
|
||||
this->elements.set(element->second);
|
||||
Logger::debug(str::format("Hud: Enabled ", configPart));
|
||||
}
|
||||
|
||||
pos = end + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,49 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "../dxvk_include.h"
|
||||
|
||||
namespace dxvk::hud {
|
||||
|
||||
/**
|
||||
* \brief HUD element
|
||||
*
|
||||
* These flags can be used to enable
|
||||
* or disable HUD elements on demand.
|
||||
*/
|
||||
enum class HudElement {
|
||||
DeviceInfo = 0,
|
||||
Framerate = 1,
|
||||
Frametimes = 2,
|
||||
StatDrawCalls = 3,
|
||||
StatSubmissions = 4,
|
||||
StatPipelines = 5,
|
||||
StatMemory = 6,
|
||||
StatGpuLoad = 7,
|
||||
DxvkVersion = 8,
|
||||
DxvkClientApi = 9,
|
||||
CompilerActivity = 10,
|
||||
};
|
||||
|
||||
using HudElements = Flags<HudElement>;
|
||||
|
||||
|
||||
/**
|
||||
* \brief HUD configuration
|
||||
*/
|
||||
struct HudConfig {
|
||||
HudConfig();
|
||||
HudConfig(const std::string& configStr);
|
||||
|
||||
HudElements elements;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* \brief Gets HUD configuration from config strnig
|
||||
*
|
||||
* \param [in] configStr Configuration string
|
||||
* \returns HUD configuration struct
|
||||
*/
|
||||
HudConfig parseHudConfigStr(const std::string& configStr);
|
||||
|
||||
}
|
@ -1,45 +0,0 @@
|
||||
#include "dxvk_hud_devinfo.h"
|
||||
|
||||
namespace dxvk::hud {
|
||||
|
||||
HudDeviceInfo::HudDeviceInfo(const Rc<DxvkDevice>& device) {
|
||||
VkPhysicalDeviceProperties props = device->adapter()->deviceProperties();
|
||||
m_deviceName = props.deviceName;
|
||||
m_driverVer = str::format("Driver: ",
|
||||
VK_VERSION_MAJOR(props.driverVersion), ".",
|
||||
VK_VERSION_MINOR(props.driverVersion), ".",
|
||||
VK_VERSION_PATCH(props.driverVersion));
|
||||
m_vulkanVer = str::format("Vulkan: ",
|
||||
VK_VERSION_MAJOR(props.apiVersion), ".",
|
||||
VK_VERSION_MINOR(props.apiVersion), ".",
|
||||
VK_VERSION_PATCH(props.apiVersion));
|
||||
}
|
||||
|
||||
|
||||
HudDeviceInfo::~HudDeviceInfo() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
HudPos HudDeviceInfo::render(
|
||||
HudRenderer& renderer,
|
||||
HudPos position) {
|
||||
renderer.drawText(16.0f,
|
||||
{ position.x, position.y },
|
||||
{ 1.0f, 1.0f, 1.0f, 1.0f },
|
||||
m_deviceName);
|
||||
|
||||
renderer.drawText(16.0f,
|
||||
{ position.x, position.y + 24 },
|
||||
{ 1.0f, 1.0f, 1.0f, 1.0f },
|
||||
m_driverVer);
|
||||
|
||||
renderer.drawText(16.0f,
|
||||
{ position.x, position.y + 44 },
|
||||
{ 1.0f, 1.0f, 1.0f, 1.0f },
|
||||
m_vulkanVer);
|
||||
|
||||
return HudPos { position.x, position.y + 68 };
|
||||
}
|
||||
|
||||
}
|
@ -1,32 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "dxvk_hud_renderer.h"
|
||||
|
||||
namespace dxvk::hud {
|
||||
|
||||
/**
|
||||
* \brief Device info display for the HUD
|
||||
*
|
||||
* Displays the name of the device, as well as
|
||||
* the driver version and Vulkan API version.
|
||||
*/
|
||||
class HudDeviceInfo {
|
||||
|
||||
public:
|
||||
|
||||
HudDeviceInfo(const Rc<DxvkDevice>& device);
|
||||
~HudDeviceInfo();
|
||||
|
||||
HudPos render(
|
||||
HudRenderer& renderer,
|
||||
HudPos position);
|
||||
|
||||
private:
|
||||
|
||||
std::string m_deviceName;
|
||||
std::string m_driverVer;
|
||||
std::string m_vulkanVer;
|
||||
|
||||
};
|
||||
|
||||
}
|
@ -1,128 +0,0 @@
|
||||
#include "dxvk_hud_fps.h"
|
||||
|
||||
#include <cmath>
|
||||
#include <iomanip>
|
||||
|
||||
namespace dxvk::hud {
|
||||
|
||||
HudFps::HudFps(HudElements elements)
|
||||
: m_elements (elements),
|
||||
m_fpsString ("FPS: "),
|
||||
m_prevFpsUpdate(Clock::now()),
|
||||
m_prevFtgUpdate(Clock::now()) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
HudFps::~HudFps() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
void HudFps::update() {
|
||||
m_frameCount += 1;
|
||||
|
||||
TimePoint now = Clock::now();
|
||||
TimeDiff elapsedFps = std::chrono::duration_cast<TimeDiff>(now - m_prevFpsUpdate);
|
||||
TimeDiff elapsedFtg = std::chrono::duration_cast<TimeDiff>(now - m_prevFtgUpdate);
|
||||
m_prevFtgUpdate = now;
|
||||
|
||||
// Update FPS string
|
||||
if (elapsedFps.count() >= UpdateInterval) {
|
||||
const int64_t fps = (10'000'000ll * m_frameCount) / elapsedFps.count();
|
||||
m_fpsString = str::format("FPS: ", fps / 10, ".", fps % 10);
|
||||
|
||||
m_prevFpsUpdate = now;
|
||||
m_frameCount = 0;
|
||||
}
|
||||
|
||||
// Update frametime stuff
|
||||
m_dataPoints[m_dataPointId] = float(elapsedFtg.count());
|
||||
m_dataPointId = (m_dataPointId + 1) % NumDataPoints;
|
||||
}
|
||||
|
||||
|
||||
HudPos HudFps::render(
|
||||
HudRenderer& renderer,
|
||||
HudPos position) {
|
||||
if (m_elements.test(HudElement::Framerate))
|
||||
position = this->renderFpsText(renderer, position);
|
||||
|
||||
if (m_elements.test(HudElement::Frametimes))
|
||||
position = this->renderFrametimeGraph(renderer, position);
|
||||
|
||||
return position;
|
||||
}
|
||||
|
||||
|
||||
HudPos HudFps::renderFpsText(
|
||||
HudRenderer& renderer,
|
||||
HudPos position) {
|
||||
renderer.drawText(16.0f,
|
||||
{ position.x, position.y },
|
||||
{ 1.0f, 1.0f, 1.0f, 1.0f },
|
||||
m_fpsString);
|
||||
|
||||
return HudPos { position.x, position.y + 24 };
|
||||
}
|
||||
|
||||
|
||||
HudPos HudFps::renderFrametimeGraph(
|
||||
HudRenderer& renderer,
|
||||
HudPos position) {
|
||||
std::array<HudLineVertex, NumDataPoints * 2> vData;
|
||||
|
||||
// 60 FPS = optimal, 10 FPS = worst
|
||||
const float targetUs = 16'666.6f;
|
||||
const float minUs = 5'000.0f;
|
||||
const float maxUs = 100'000.0f;
|
||||
|
||||
// Ten times the maximum/minimum number
|
||||
// of milliseconds for a single frame
|
||||
uint32_t minMs = 0xFFFFFFFFu;
|
||||
uint32_t maxMs = 0x00000000u;
|
||||
|
||||
// Paint the time points
|
||||
for (uint32_t i = 0; i < NumDataPoints; i++) {
|
||||
float us = m_dataPoints[(m_dataPointId + i) % NumDataPoints];
|
||||
|
||||
minMs = std::min(minMs, uint32_t(us / 100.0f));
|
||||
maxMs = std::max(maxMs, uint32_t(us / 100.0f));
|
||||
|
||||
float r = std::min(std::max(-1.0f + us / targetUs, 0.0f), 1.0f);
|
||||
float g = std::min(std::max( 3.0f - us / targetUs, 0.0f), 1.0f);
|
||||
float l = std::sqrt(r * r + g * g);
|
||||
|
||||
HudNormColor color = {
|
||||
uint8_t(255.0f * (r / l)),
|
||||
uint8_t(255.0f * (g / l)),
|
||||
uint8_t(0), uint8_t(255) };
|
||||
|
||||
float x = position.x + float(i);
|
||||
float y = position.y + 24.0f;
|
||||
|
||||
float hVal = std::log2(std::max((us - minUs) / targetUs + 1.0f, 1.0f))
|
||||
/ std::log2((maxUs - minUs) / targetUs);
|
||||
float h = std::min(std::max(40.0f * hVal, 2.0f), 40.0f);
|
||||
|
||||
vData[2 * i + 0] = HudLineVertex { { x, y }, color };
|
||||
vData[2 * i + 1] = HudLineVertex { { x, y - h }, color };
|
||||
}
|
||||
|
||||
renderer.drawLines(vData.size(), vData.data());
|
||||
|
||||
// Paint min/max frame times in the entire window
|
||||
renderer.drawText(14.0f,
|
||||
{ position.x, position.y + 44.0f },
|
||||
{ 1.0f, 1.0f, 1.0f, 1.0f },
|
||||
str::format("min: ", minMs / 10, ".", minMs % 10));
|
||||
|
||||
renderer.drawText(14.0f,
|
||||
{ position.x + 150.0f, position.y + 44.0f },
|
||||
{ 1.0f, 1.0f, 1.0f, 1.0f },
|
||||
str::format("max: ", maxMs / 10, ".", maxMs % 10));
|
||||
|
||||
return HudPos { position.x, position.y + 66.0f };
|
||||
}
|
||||
|
||||
}
|
@ -1,56 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "../util/util_time.h"
|
||||
|
||||
#include "dxvk_hud_config.h"
|
||||
#include "dxvk_hud_renderer.h"
|
||||
|
||||
namespace dxvk::hud {
|
||||
|
||||
/**
|
||||
* \brief FPS display for the HUD
|
||||
*
|
||||
* Displays the current frames per second.
|
||||
*/
|
||||
class HudFps {
|
||||
using Clock = dxvk::high_resolution_clock;
|
||||
using TimeDiff = std::chrono::microseconds;
|
||||
using TimePoint = typename Clock::time_point;
|
||||
|
||||
constexpr static uint32_t NumDataPoints = 300;
|
||||
constexpr static int64_t UpdateInterval = 500'000;
|
||||
public:
|
||||
|
||||
HudFps(HudElements elements);
|
||||
~HudFps();
|
||||
|
||||
void update();
|
||||
|
||||
HudPos render(
|
||||
HudRenderer& renderer,
|
||||
HudPos position);
|
||||
|
||||
private:
|
||||
|
||||
const HudElements m_elements;
|
||||
|
||||
std::string m_fpsString;
|
||||
|
||||
TimePoint m_prevFpsUpdate;
|
||||
TimePoint m_prevFtgUpdate;
|
||||
int64_t m_frameCount = 0;
|
||||
|
||||
std::array<float, NumDataPoints> m_dataPoints = {};
|
||||
uint32_t m_dataPointId = 0;
|
||||
|
||||
HudPos renderFpsText(
|
||||
HudRenderer& renderer,
|
||||
HudPos position);
|
||||
|
||||
HudPos renderFrametimeGraph(
|
||||
HudRenderer& renderer,
|
||||
HudPos position);
|
||||
|
||||
};
|
||||
|
||||
}
|
@ -1,223 +0,0 @@
|
||||
#include "dxvk_hud_stats.h"
|
||||
|
||||
namespace dxvk::hud {
|
||||
|
||||
HudStats::HudStats(HudElements elements)
|
||||
: m_elements(filterElements(elements)),
|
||||
m_compilerShowTime(dxvk::high_resolution_clock::now()) { }
|
||||
|
||||
|
||||
HudStats::~HudStats() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
void HudStats::update(const Rc<DxvkDevice>& device) {
|
||||
if (m_elements.isClear())
|
||||
return;
|
||||
|
||||
// For some counters, we'll display the absolute value,
|
||||
// for others, the average counter increment per frame.
|
||||
DxvkStatCounters nextCounters = device->getStatCounters();
|
||||
m_diffCounters = nextCounters.diff(m_prevCounters);
|
||||
m_prevCounters = nextCounters;
|
||||
|
||||
// GPU load is a bit more complex than that since
|
||||
// we don't want to update this every frame
|
||||
if (m_elements.test(HudElement::StatGpuLoad))
|
||||
this->updateGpuLoad();
|
||||
}
|
||||
|
||||
|
||||
HudPos HudStats::render(
|
||||
HudRenderer& renderer,
|
||||
HudPos position) {
|
||||
if (m_elements.test(HudElement::StatSubmissions))
|
||||
position = this->printSubmissionStats(renderer, position);
|
||||
|
||||
if (m_elements.test(HudElement::StatDrawCalls))
|
||||
position = this->printDrawCallStats(renderer, position);
|
||||
|
||||
if (m_elements.test(HudElement::StatPipelines))
|
||||
position = this->printPipelineStats(renderer, position);
|
||||
|
||||
if (m_elements.test(HudElement::StatMemory))
|
||||
position = this->printMemoryStats(renderer, position);
|
||||
|
||||
if (m_elements.test(HudElement::StatGpuLoad))
|
||||
position = this->printGpuLoad(renderer, position);
|
||||
|
||||
if (m_elements.test(HudElement::CompilerActivity)) {
|
||||
this->printCompilerActivity(renderer,
|
||||
{ position.x, float(renderer.surfaceSize().height) - 20.0f });
|
||||
}
|
||||
|
||||
return position;
|
||||
}
|
||||
|
||||
|
||||
void HudStats::updateGpuLoad() {
|
||||
auto now = dxvk::high_resolution_clock::now();
|
||||
uint64_t ticks = std::chrono::duration_cast<std::chrono::microseconds>(now - m_gpuLoadUpdateTime).count();
|
||||
|
||||
if (ticks >= 500'000) {
|
||||
m_gpuLoadUpdateTime = now;
|
||||
|
||||
m_diffGpuIdleTicks = m_prevCounters.getCtr(DxvkStatCounter::GpuIdleTicks) - m_prevGpuIdleTicks;
|
||||
m_prevGpuIdleTicks = m_prevCounters.getCtr(DxvkStatCounter::GpuIdleTicks);
|
||||
|
||||
uint64_t busyTicks = ticks > m_diffGpuIdleTicks
|
||||
? uint64_t(ticks - m_diffGpuIdleTicks)
|
||||
: uint64_t(0);
|
||||
|
||||
m_gpuLoadString = str::format("GPU: ", (100 * busyTicks) / ticks, "%");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
HudPos HudStats::printDrawCallStats(
|
||||
HudRenderer& renderer,
|
||||
HudPos position) {
|
||||
const uint64_t frameCount = std::max<uint64_t>(m_diffCounters.getCtr(DxvkStatCounter::QueuePresentCount), 1);
|
||||
|
||||
const uint64_t gpCalls = m_diffCounters.getCtr(DxvkStatCounter::CmdDrawCalls) / frameCount;
|
||||
const uint64_t cpCalls = m_diffCounters.getCtr(DxvkStatCounter::CmdDispatchCalls) / frameCount;
|
||||
const uint64_t rpCalls = m_diffCounters.getCtr(DxvkStatCounter::CmdRenderPassCount) / frameCount;
|
||||
|
||||
const std::string strDrawCalls = str::format("Draw calls: ", gpCalls);
|
||||
const std::string strDispatchCalls = str::format("Dispatch calls: ", cpCalls);
|
||||
const std::string strRenderPasses = str::format("Render passes: ", rpCalls);
|
||||
|
||||
renderer.drawText(16.0f,
|
||||
{ position.x, position.y },
|
||||
{ 1.0f, 1.0f, 1.0f, 1.0f },
|
||||
strDrawCalls);
|
||||
|
||||
renderer.drawText(16.0f,
|
||||
{ position.x, position.y + 20.0f },
|
||||
{ 1.0f, 1.0f, 1.0f, 1.0f },
|
||||
strDispatchCalls);
|
||||
|
||||
renderer.drawText(16.0f,
|
||||
{ position.x, position.y + 40.0f },
|
||||
{ 1.0f, 1.0f, 1.0f, 1.0f },
|
||||
strRenderPasses);
|
||||
|
||||
return { position.x, position.y + 64 };
|
||||
}
|
||||
|
||||
|
||||
HudPos HudStats::printSubmissionStats(
|
||||
HudRenderer& renderer,
|
||||
HudPos position) {
|
||||
const uint64_t frameCount = std::max<uint64_t>(m_diffCounters.getCtr(DxvkStatCounter::QueuePresentCount), 1);
|
||||
const uint64_t numSubmits = m_diffCounters.getCtr(DxvkStatCounter::QueueSubmitCount) / frameCount;
|
||||
|
||||
const std::string strSubmissions = str::format("Queue submissions: ", numSubmits);
|
||||
|
||||
renderer.drawText(16.0f,
|
||||
{ position.x, position.y },
|
||||
{ 1.0f, 1.0f, 1.0f, 1.0f },
|
||||
strSubmissions);
|
||||
|
||||
return { position.x, position.y + 24.0f };
|
||||
}
|
||||
|
||||
|
||||
HudPos HudStats::printPipelineStats(
|
||||
HudRenderer& renderer,
|
||||
HudPos position) {
|
||||
const uint64_t gpCount = m_prevCounters.getCtr(DxvkStatCounter::PipeCountGraphics);
|
||||
const uint64_t cpCount = m_prevCounters.getCtr(DxvkStatCounter::PipeCountCompute);
|
||||
|
||||
const std::string strGpCount = str::format("Graphics pipelines: ", gpCount);
|
||||
const std::string strCpCount = str::format("Compute pipelines: ", cpCount);
|
||||
|
||||
renderer.drawText(16.0f,
|
||||
{ position.x, position.y },
|
||||
{ 1.0f, 1.0f, 1.0f, 1.0f },
|
||||
strGpCount);
|
||||
|
||||
renderer.drawText(16.0f,
|
||||
{ position.x, position.y + 20.0f },
|
||||
{ 1.0f, 1.0f, 1.0f, 1.0f },
|
||||
strCpCount);
|
||||
|
||||
return { position.x, position.y + 44.0f };
|
||||
}
|
||||
|
||||
|
||||
HudPos HudStats::printMemoryStats(
|
||||
HudRenderer& renderer,
|
||||
HudPos position) {
|
||||
constexpr uint64_t mib = 1024 * 1024;
|
||||
|
||||
const uint64_t memAllocated = m_prevCounters.getCtr(DxvkStatCounter::MemoryAllocated);
|
||||
const uint64_t memUsed = m_prevCounters.getCtr(DxvkStatCounter::MemoryUsed);
|
||||
|
||||
const std::string strMemAllocated = str::format("Memory allocated: ", memAllocated / mib, " MB");
|
||||
const std::string strMemUsed = str::format("Memory used: ", memUsed / mib, " MB");
|
||||
|
||||
renderer.drawText(16.0f,
|
||||
{ position.x, position.y },
|
||||
{ 1.0f, 1.0f, 1.0f, 1.0f },
|
||||
strMemAllocated);
|
||||
|
||||
renderer.drawText(16.0f,
|
||||
{ position.x, position.y + 20.0f },
|
||||
{ 1.0f, 1.0f, 1.0f, 1.0f },
|
||||
strMemUsed);
|
||||
|
||||
return { position.x, position.y + 44.0f };
|
||||
}
|
||||
|
||||
|
||||
HudPos HudStats::printGpuLoad(
|
||||
HudRenderer& renderer,
|
||||
HudPos position) {
|
||||
renderer.drawText(16.0f,
|
||||
{ position.x, position.y },
|
||||
{ 1.0f, 1.0f, 1.0f, 1.0f },
|
||||
m_gpuLoadString);
|
||||
|
||||
return { position.x, position.y + 24.0f };
|
||||
}
|
||||
|
||||
|
||||
HudPos HudStats::printCompilerActivity(
|
||||
HudRenderer& renderer,
|
||||
HudPos position) {
|
||||
auto now = dxvk::high_resolution_clock::now();
|
||||
bool doShow = m_prevCounters.getCtr(DxvkStatCounter::PipeCompilerBusy);
|
||||
|
||||
if (m_prevCounters.getCtr(DxvkStatCounter::PipeCompilerBusy)
|
||||
&& m_diffCounters.getCtr(DxvkStatCounter::PipeCompilerBusy))
|
||||
m_compilerShowTime = now;
|
||||
|
||||
if (!doShow) {
|
||||
doShow |= std::chrono::duration_cast<std::chrono::milliseconds>(now - m_compilerShowTime)
|
||||
< std::chrono::milliseconds(1000);
|
||||
}
|
||||
|
||||
if (doShow) {
|
||||
renderer.drawText(16.0f,
|
||||
{ position.x, position.y },
|
||||
{ 1.0f, 1.0f, 1.0f, 1.0f },
|
||||
"Compiling shaders...");
|
||||
}
|
||||
|
||||
return { position.x, position.y + 24.0f };
|
||||
}
|
||||
|
||||
|
||||
HudElements HudStats::filterElements(HudElements elements) {
|
||||
return elements & HudElements(
|
||||
HudElement::StatDrawCalls,
|
||||
HudElement::StatSubmissions,
|
||||
HudElement::StatPipelines,
|
||||
HudElement::StatMemory,
|
||||
HudElement::StatGpuLoad,
|
||||
HudElement::CompilerActivity);
|
||||
}
|
||||
|
||||
}
|
@ -1,78 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "../util/util_time.h"
|
||||
|
||||
#include "../dxvk_stats.h"
|
||||
|
||||
#include "dxvk_hud_config.h"
|
||||
#include "dxvk_hud_renderer.h"
|
||||
|
||||
namespace dxvk::hud {
|
||||
|
||||
/**
|
||||
* \brief Statistics display for the HUD
|
||||
*
|
||||
* Displays some stat counters for the device
|
||||
* if enabled. Certain groups of counters can
|
||||
* be enabled inidividually.
|
||||
*/
|
||||
class HudStats {
|
||||
|
||||
public:
|
||||
|
||||
HudStats(HudElements elements);
|
||||
~HudStats();
|
||||
|
||||
void update(
|
||||
const Rc<DxvkDevice>& device);
|
||||
|
||||
HudPos render(
|
||||
HudRenderer& renderer,
|
||||
HudPos position);
|
||||
|
||||
private:
|
||||
|
||||
const HudElements m_elements;
|
||||
|
||||
DxvkStatCounters m_prevCounters;
|
||||
DxvkStatCounters m_diffCounters;
|
||||
|
||||
dxvk::high_resolution_clock::time_point m_gpuLoadUpdateTime;
|
||||
dxvk::high_resolution_clock::time_point m_compilerShowTime;
|
||||
|
||||
uint64_t m_prevGpuIdleTicks = 0;
|
||||
uint64_t m_diffGpuIdleTicks = 0;
|
||||
|
||||
std::string m_gpuLoadString = "GPU: ";
|
||||
|
||||
void updateGpuLoad();
|
||||
|
||||
HudPos printDrawCallStats(
|
||||
HudRenderer& renderer,
|
||||
HudPos position);
|
||||
|
||||
HudPos printSubmissionStats(
|
||||
HudRenderer& renderer,
|
||||
HudPos position);
|
||||
|
||||
HudPos printPipelineStats(
|
||||
HudRenderer& renderer,
|
||||
HudPos position);
|
||||
|
||||
HudPos printMemoryStats(
|
||||
HudRenderer& renderer,
|
||||
HudPos position);
|
||||
|
||||
HudPos printGpuLoad(
|
||||
HudRenderer& renderer,
|
||||
HudPos position);
|
||||
|
||||
HudPos printCompilerActivity(
|
||||
HudRenderer& renderer,
|
||||
HudPos position);
|
||||
|
||||
static HudElements filterElements(HudElements elements);
|
||||
|
||||
};
|
||||
|
||||
}
|
@ -102,13 +102,9 @@ dxvk_src = files([
|
||||
'platform/dxvk_win32_exts.cpp',
|
||||
|
||||
'hud/dxvk_hud.cpp',
|
||||
'hud/dxvk_hud_config.cpp',
|
||||
'hud/dxvk_hud_devinfo.cpp',
|
||||
'hud/dxvk_hud_font.cpp',
|
||||
'hud/dxvk_hud_fps.cpp',
|
||||
'hud/dxvk_hud_item.cpp',
|
||||
'hud/dxvk_hud_renderer.cpp',
|
||||
'hud/dxvk_hud_stats.cpp',
|
||||
])
|
||||
|
||||
thread_dep = dependency('threads')
|
||||
|
Loading…
x
Reference in New Issue
Block a user