Switch to more compact TextGlyph vertex format

This commit is contained in:
Georg Hagen
2025-01-05 00:02:01 +01:00
parent 47a904f572
commit e9a1c629d9
13 changed files with 249 additions and 248 deletions

View File

@@ -5,49 +5,36 @@
*/
#include "Scene/TextDrawable.hpp"
#include "VulkanGeometry.hpp"
#include "VulkanNode.hpp"
#include "Vulkan/VulkanDrawContext.hpp"
#include "Vulkan/Scene/VulkanUniformBuffer.hpp"
#include "Vulkan/Scene/VulkanVertexBuffer.hpp"
#include "VulkanTexture.hpp"
using namespace OpenVulkano::Scene;
namespace OpenVulkano::Vulkan
{
void EncodeTextDrawable(Drawable* instance, Vulkan::VulkanDrawContext* drawContext)
void EncodeTextDrawable(Drawable* instance, VulkanDrawContext* drawContext)
{
TextDrawable* drawable = static_cast<TextDrawable*>(instance);
Geometry* mesh = drawable->GetGeometry();
VulkanGeometry* renderGeo = mesh->GetRenderResource();
if (!renderGeo) renderGeo = drawContext->renderer->GetResourceManager().PrepareGeometry(mesh);
renderGeo->RecordBind(drawContext->commandBuffer);
VertexBuffer* vbo = drawable->GetVertexBuffer();
VulkanVertexBuffer* renderVbo = vbo->GetRenderResource();
if (!renderVbo) renderVbo = drawContext->renderer->GetResourceManager().PrepareVertexBuffer(vbo);
renderVbo->RecordBind(drawContext->commandBuffer);
if (drawable->GetUniformBuffer())
VulkanTexture* renderTexture = drawable->GetTexture()->GetRenderResource();
if (!renderTexture)
{
VulkanUniformBuffer* vkBuffer = drawable->GetUniformBuffer()->GetRenderResource();
if (!vkBuffer)
{
vkBuffer = drawContext->renderer->GetResourceManager().PrepareUniformBuffer(drawable->GetUniformBuffer());
}
vkBuffer->Record(drawContext);
}
if (Texture* texture = drawable->GetTexture())
{
VulkanTexture* renderTexture = texture->GetRenderResource();
if (!renderTexture)
{
renderTexture = drawContext->renderer->GetResourceManager().PrepareTexture(drawable->GetTexture());
}
renderTexture->Record(drawContext);
renderTexture = drawContext->renderer->GetResourceManager().PrepareTexture(drawable->GetTexture());
}
renderTexture->Record(drawContext);
for(Node* node : instance->GetNodes())
{
if (!node->IsEnabled()) [[unlikely]] continue;
drawContext->EncodeNode(node);
renderGeo->RecordDraw(drawContext->commandBuffer);
drawContext->commandBuffer.draw(4, drawable->GetSymbolCount(), 0, 0);
}
}
}