descriptor heap leak fix
This commit is contained in:
parent
c054f1e0b3
commit
825da78f7f
3 changed files with 232 additions and 29 deletions
|
|
@ -51,7 +51,7 @@ void UIRenderer::Initialize(Window& window, DescriptorHeapVulkan& heap, VkComman
|
|||
// Allocate one image slot for the swapchain output. Each per-frame heap
|
||||
// copy will hold ITS frame's image at this slot.
|
||||
auto outRange = heap_->AllocateImageSlots(1);
|
||||
outImageSlot_ = outRange.firstElement;
|
||||
outImageSlot_ = ImageSlot{heap_, outRange.firstElement};
|
||||
|
||||
WriteSwapchainDescriptors();
|
||||
|
||||
|
|
@ -59,7 +59,7 @@ void UIRenderer::Initialize(Window& window, DescriptorHeapVulkan& heap, VkComman
|
|||
// already before reaching here, so atlas->image is live).
|
||||
if (fontAtlas != nullptr) {
|
||||
auto atlasImg = heap_->AllocateImageSlots(1);
|
||||
fontAtlasImageSlot_ = atlasImg.firstElement;
|
||||
fontAtlasImageSlot_ = ImageSlot{heap_, atlasImg.firstElement};
|
||||
fontAtlasSamplerSlot_ = RegisterLinearClampSampler();
|
||||
WriteFontAtlasDescriptor();
|
||||
}
|
||||
|
|
@ -165,7 +165,7 @@ void UIRenderer::DispatchText(VkCommandBuffer cmd, std::uint32_t bufferSlot,
|
|||
std::uint32_t itemCount,
|
||||
std::array<float,4> clipRectPx) {
|
||||
if (itemCount == 0) return;
|
||||
if (fontAtlasImageSlot_ == 0xFFFF) {
|
||||
if (!fontAtlasImageSlot_) {
|
||||
throw std::runtime_error("UIRenderer::DispatchText: no FontAtlas registered (set fontAtlas before Initialize)");
|
||||
}
|
||||
// Flush any glyphs that ShapeText calls (during this onBuild) just
|
||||
|
|
@ -314,7 +314,7 @@ void UIRenderer::WriteBufferDescriptor(std::uint16_t slot, VkDeviceAddress addre
|
|||
for (auto& h : heap_->resourceHeap) h.FlushDevice();
|
||||
}
|
||||
|
||||
std::uint16_t UIRenderer::RegisterSampler(const VkSamplerCreateInfo& info) {
|
||||
SamplerSlot UIRenderer::RegisterSampler(const VkSamplerCreateInfo& info) {
|
||||
auto range = heap_->AllocateSamplerSlots(1);
|
||||
std::array<VkSamplerCreateInfo, Window::numFrames> infos{};
|
||||
std::array<VkHostAddressRangeEXT, Window::numFrames> destinations{};
|
||||
|
|
@ -329,10 +329,10 @@ std::uint16_t UIRenderer::RegisterSampler(const VkSamplerCreateInfo& info) {
|
|||
Device::device, Window::numFrames, infos.data(), destinations.data()
|
||||
);
|
||||
for (auto& h : heap_->samplerHeap) h.FlushDevice();
|
||||
return range.firstElement;
|
||||
return SamplerSlot{heap_, range.firstElement};
|
||||
}
|
||||
|
||||
std::uint16_t UIRenderer::RegisterLinearClampSampler() {
|
||||
SamplerSlot UIRenderer::RegisterLinearClampSampler() {
|
||||
VkSamplerCreateInfo s {
|
||||
.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO,
|
||||
.magFilter = VK_FILTER_LINEAR,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue