2018-01-13 03:53:33 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "../dxvk_device.h"
|
|
|
|
|
|
|
|
#include "dxvk_hud_font.h"
|
|
|
|
|
|
|
|
namespace dxvk::hud {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* \brief HUD coordinates
|
|
|
|
*
|
|
|
|
* Coordinates relative to the top-left
|
|
|
|
* corner of the swap image, in pixels.
|
|
|
|
*/
|
|
|
|
struct HudPos {
|
|
|
|
float x;
|
|
|
|
float y;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* \brief Texture coordinates
|
|
|
|
*
|
|
|
|
* Absolute texture coordinates that are used
|
|
|
|
* to pick letters in the font texture.
|
|
|
|
*/
|
|
|
|
struct HudTexCoord {
|
2018-01-22 01:20:07 +01:00
|
|
|
uint32_t u;
|
|
|
|
uint32_t v;
|
2018-01-13 03:53:33 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* \brief Color
|
|
|
|
*
|
|
|
|
* SRGB color with alpha channel. The text
|
|
|
|
* will use this color for the most part.
|
|
|
|
*/
|
|
|
|
struct HudColor {
|
2018-01-22 01:20:07 +01:00
|
|
|
float x;
|
|
|
|
float y;
|
|
|
|
float z;
|
|
|
|
float w;
|
2018-01-13 03:53:33 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* \brief Text vertex
|
|
|
|
*/
|
|
|
|
struct HudTextVertex {
|
|
|
|
HudPos position;
|
|
|
|
HudTexCoord texcoord;
|
|
|
|
HudColor color;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* \brief Text renderer for the HUD
|
|
|
|
*
|
|
|
|
* Can be used by the presentation backend to
|
|
|
|
* display performance and driver information.
|
|
|
|
*/
|
|
|
|
class HudTextRenderer {
|
|
|
|
constexpr static VkDeviceSize MaxVertexCount = 1 << 16;
|
|
|
|
public:
|
|
|
|
|
|
|
|
HudTextRenderer(
|
|
|
|
const Rc<DxvkDevice>& device,
|
|
|
|
const Rc<DxvkContext>& context);
|
|
|
|
|
|
|
|
~HudTextRenderer();
|
|
|
|
|
|
|
|
void beginFrame(
|
|
|
|
const Rc<DxvkContext>& context);
|
|
|
|
|
|
|
|
void drawText(
|
|
|
|
const Rc<DxvkContext>& context,
|
|
|
|
float size,
|
|
|
|
HudPos pos,
|
|
|
|
HudColor color,
|
|
|
|
const std::string& text);
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
std::array<uint8_t, 256> m_charMap;
|
|
|
|
|
|
|
|
Rc<DxvkShader> m_vertShader;
|
|
|
|
Rc<DxvkShader> m_fragShader;
|
|
|
|
|
|
|
|
Rc<DxvkImage> m_fontImage;
|
|
|
|
Rc<DxvkImageView> m_fontView;
|
|
|
|
Rc<DxvkSampler> m_fontSampler;
|
|
|
|
|
|
|
|
Rc<DxvkBuffer> m_vertexBuffer;
|
|
|
|
size_t m_vertexIndex = 0;
|
|
|
|
|
|
|
|
Rc<DxvkShader> createVertexShader(
|
|
|
|
const Rc<DxvkDevice>& device);
|
|
|
|
|
|
|
|
Rc<DxvkShader> createFragmentShader(
|
|
|
|
const Rc<DxvkDevice>& device);
|
|
|
|
|
|
|
|
Rc<DxvkImage> createFontImage(
|
|
|
|
const Rc<DxvkDevice>& device);
|
|
|
|
|
|
|
|
Rc<DxvkImageView> createFontView(
|
|
|
|
const Rc<DxvkDevice>& device);
|
|
|
|
|
|
|
|
Rc<DxvkSampler> createFontSampler(
|
|
|
|
const Rc<DxvkDevice>& device);
|
|
|
|
|
|
|
|
Rc<DxvkBuffer> createVertexBuffer(
|
|
|
|
const Rc<DxvkDevice>& device);
|
|
|
|
|
|
|
|
void initFontTexture(
|
|
|
|
const Rc<DxvkDevice>& device,
|
|
|
|
const Rc<DxvkContext>& context);
|
|
|
|
|
|
|
|
void initCharMap();
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|