Files
renderdoc/renderdoc/driver/vulkan/vk_rendertext.h
T
baldurk 506d6c6d7b Fix self-capture for vulkan captures using ASs
* The problem here is that due to design flaws in the extension when ASs are in
  use we don't know whether a memory allocation will need BDA or not an the
  application doesn't have to set any flag - unlike for normal buffer BDA. So we
  promote (almost) all memory allocations to BDA when using ASs even if they're
  not needed.
* This normally works fine except if during self-capture the replay process
  allocates some normal memory before all application replayed allocations have
  been made, the self-capturing will promote it to BDA and request a replayable
  address that might clash with a later address the application had used and
  would be needed.
* To solve this, we ensure that during capture we don't create wrapped
  allocations more than necessary - to avoid causing clashes - as well as
  ensuring that on replay we only create new allocations after all replayed
  allocations.
* We also take advantage of dedicated allocations for fake swapchain images,
  since dedicated image allocations will not be promoted to BDA.
2025-04-17 16:21:19 +01:00

79 lines
2.7 KiB
C++

/******************************************************************************
* The MIT License (MIT)
*
* Copyright (c) 2019-2025 Baldur Karlsson
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
******************************************************************************/
#pragma once
#include "core/core.h"
#include "vk_common.h"
#include "vk_core.h"
struct TextPrintState
{
VkCommandBuffer cmd;
VkRenderPass rp;
VkFramebuffer fb;
uint32_t w, h;
VkFormat fmt;
};
class VulkanTextRenderer
{
public:
VulkanTextRenderer(WrappedVulkan *driver);
~VulkanTextRenderer();
void BeginText(const TextPrintState &textstate);
void RenderText(const TextPrintState &textstate, float x, float y, const rdcstr &text);
void EndText(const TextPrintState &textstate);
private:
void RenderTextInternal(const TextPrintState &textstate, float x, float y, const rdcstr &text);
static const uint32_t FONT_TEX_WIDTH = 256;
static const uint32_t FONT_TEX_HEIGHT = 128;
VkDevice m_Device = VK_NULL_HANDLE;
float m_FontCharAspect = 1.0f;
float m_FontCharSize = 1.0f;
VkDescriptorSetLayout m_TextDescSetLayout = VK_NULL_HANDLE;
VkPipelineLayout m_TextPipeLayout = VK_NULL_HANDLE;
VkDescriptorSet m_TextDescSet = VK_NULL_HANDLE;
static const int NUM_BB_FORMATS = 7;
VkPipeline m_TextPipeline[NUM_BB_FORMATS] = {};
VkSampler m_LinearSampler = VK_NULL_HANDLE;
VkDescriptorPool m_DescriptorPool = VK_NULL_HANDLE;
GPUBuffer m_TextGeneralUBO;
GPUBuffer m_TextGlyphUBO;
GPUBuffer m_TextStringUBO;
VkImage m_TextAtlas = VK_NULL_HANDLE;
VkDeviceMemory m_TextAtlasMem = VK_NULL_HANDLE;
VkImageView m_TextAtlasView = VK_NULL_HANDLE;
GPUBuffer m_TextAtlasUpload;
};