Implement texture atlas for fonts

This commit is contained in:
Dynamitos committed 2026-10-21 21:21:49 +02:00
1 parent 17dc1e4d88
commit 22a90fe07c
14 files changed
+388 -50

No files matched your search

+5 -1
View File
@@ -1023,7 +1023,11 @@ void Graphics::createDevice(GraphicsInitializer initializer) {
updateQueueInfo(familyIndex, computeQueueInfo, numQueuesForFamily);
}
}
if ((currProps.queueFlags ^ VK_QUEUE_TRANSFER_BIT) == 0) {
// a queue family is a valid transfer queue if it supports the transfer bit at all
// (previously `(flags ^ TRANSFER) == 0`, which only matched pure-transfer families
// that don't exist on standard drivers: no transfer queue was ever created, so
// every vkQueueSubmit on the transfer queue path failed with VK_ERROR_DEVICE_LOST)
if (currProps.queueFlags & VK_QUEUE_TRANSFER_BIT) {
updateQueueInfo(familyIndex, transferQueueInfo, numQueuesForFamily);
}
+12
View File
@@ -213,6 +213,10 @@ TextureHandle::TextureHandle(PGraphics graphics, VkImageViewType viewType, const
// When loading a texture from a file, we will almost always use it as a texture map for fragment shaders
changeLayout(Gfx::SE_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL, VK_ACCESS_TRANSFER_READ_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT,
VK_ACCESS_SHADER_READ_BIT, VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT);
// The copy above is only enqueued on a command buffer; it must actually be
// submitted to the GPU before any consumer (the UI pass, a test's download,
// etc.) can read the image. Without this the image is still all zeros.
commandPool->submitCommands();
graphics->getDestructionManager()->queueResourceForDestruction(std::move(stagingAlloc));
}
}
@@ -359,6 +363,14 @@ void TextureHandle::download(uint32 mipLevel, uint32 arrayLayer, uint32 face, Ar
cmdBuffer->bindResource(PBufferAllocation(stagingAlloc));
changeLayout(prevLayout, VK_ACCESS_TRANSFER_READ_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_ACCESS_MEMORY_READ_BIT,
VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT);
// The copy above is only enqueued; the staging buffer is still all zeros until the
// command actually runs. Submit it and wait on its fence before mapping, or the read
// below would race the GPU and return a blank texture. (submitCommands() submits the
// current command and rotates to a fresh one, exactly like the upload path in the
// TextureHandle constructor.)
PCommandPool pool = graphics->getQueueCommands(owner);
pool->submitCommands();
cmdBuffer->waitForCommand();
VK_CHECK(vmaMapMemory(graphics->getAllocator(), stagingAlloc->allocation, &data));
buffer.resize(imageSize);
std::memcpy(buffer.data(), data, buffer.size());