Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[hud] Use compute shader for text, use Titillium Web font #4673

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10,480 changes: 8,620 additions & 1,860 deletions src/dxvk/hud/dxvk_hud_font.cpp

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions src/dxvk/hud/dxvk_hud_font.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once

#include <cstdint>
#include <unordered_map>

namespace dxvk::hud {

Expand All @@ -12,20 +13,19 @@ namespace dxvk::hud {
int32_t h;
int32_t originX;
int32_t originY;
int32_t advance;
};

struct HudFont {
int32_t size;
uint32_t width;
uint32_t height;
uint32_t falloff;
uint32_t advance;
uint32_t charCount;

const HudGlyph* glyphs;
const uint8_t* texture;
};

extern const HudFont g_hudFont;

}
}
13 changes: 9 additions & 4 deletions src/dxvk/hud/dxvk_hud_item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,9 @@ namespace dxvk::hud {
VkDescriptorBufferInfo frameTimeBuffer = m_gpuBuffer->getDescriptor(
0, bufferLayout.timestampSize).buffer;

VkDescriptorBufferInfo charInfoBuffer = m_gpuBuffer->getDescriptor(
bufferLayout.charInfoOffset, bufferLayout.charInfoSize).buffer;

VkDescriptorBufferInfo drawInfoBuffer = m_gpuBuffer->getDescriptor(
bufferLayout.drawInfoOffset, bufferLayout.drawInfoSize).buffer;

Expand Down Expand Up @@ -376,8 +379,8 @@ namespace dxvk::hud {
renderer.drawText(12, minPos, 0xff4040ff, "min:");
renderer.drawText(12, maxPos, 0xff4040ff, "max:");

renderer.drawTextIndirect(ctx, key, drawParamBuffer,
drawInfoBuffer, textBufferView, 2u);
renderer.drawTextIndirect(ctx, key, charInfoBuffer,
drawParamBuffer, drawInfoBuffer, textBufferView, 2u);

if (unlikely(m_device->isDebugEnabled()))
ctx.cmd->cmdEndDebugUtilsLabel(DxvkCmdBuffer::InitBuffer);
Expand Down Expand Up @@ -494,7 +497,7 @@ namespace dxvk::hud {
HudRenderer& renderer) {
auto vk = m_device->vkd();

std::array<VkDescriptorSetLayoutBinding, 4> bindings = {{
std::array<VkDescriptorSetLayoutBinding, 5> bindings = {{
{ 0, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, 1, VK_SHADER_STAGE_COMPUTE_BIT },
{ 1, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, 1, VK_SHADER_STAGE_COMPUTE_BIT },
{ 2, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, 1, VK_SHADER_STAGE_COMPUTE_BIT },
Expand Down Expand Up @@ -704,7 +707,9 @@ namespace dxvk::hud {

BufferLayout result = { };
result.timestampSize = align(sizeof(ComputeTimestampBuffer), 256u);
result.drawInfoOffset = result.timestampSize;
result.charInfoOffset = result.timestampSize;
result.charInfoSize = align(sizeof(HudCharInfo) * 256u, 256u);
result.drawInfoOffset = result.charInfoOffset + result.charInfoSize;
result.drawInfoSize = align(sizeof(HudTextDrawInfo) * NumTextDraws, 256u);
result.drawParamOffset = result.drawInfoOffset + result.drawInfoSize;
result.drawParamSize = align(sizeof(VkDrawIndirectCommand) * NumTextDraws, 256u);
Expand Down
4 changes: 3 additions & 1 deletion src/dxvk/hud/dxvk_hud_item.h
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,8 @@ namespace dxvk::hud {

struct BufferLayout {
size_t timestampSize;
size_t charInfoOffset;
size_t charInfoSize;
size_t drawInfoOffset;
size_t drawInfoSize;
size_t drawParamOffset;
Expand Down Expand Up @@ -774,4 +776,4 @@ namespace dxvk::hud {

};

}
}
Loading