From 694d969c83c9eb6116e5a351059e70b90d9f2d67 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Wed, 13 Dec 2023 00:03:25 +0900 Subject: [PATCH] [vulkan] Round shadow map sizes correctly I'd added some developer output to see how the layers were distributed between images and found the image widths to be... odd. It turns out I was double-adding the shadow_quanta. Oops. Results in ~164MB less memory used by marcher (for 32 pixel quanta). --- libs/video/renderer/vulkan/vulkan_lighting.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/libs/video/renderer/vulkan/vulkan_lighting.c b/libs/video/renderer/vulkan/vulkan_lighting.c index 6d5839348..11a38b308 100644 --- a/libs/video/renderer/vulkan/vulkan_lighting.c +++ b/libs/video/renderer/vulkan/vulkan_lighting.c @@ -1615,7 +1615,7 @@ allocate_map (mapctx_t *mctx, int type, int (*getsize) (const light_t *light)) if (lr->mode != type) { continue; } - int light_size = getsize (&mctx->lights[li]) + shadow_quanta - 1; + int light_size = getsize (&mctx->lights[li]); light_size = ((light_size + shadow_quanta - 1) / shadow_quanta) * shadow_quanta; if (size != light_size || numLayers + layers > mctx->maxLayers) { @@ -1854,6 +1854,13 @@ build_shadow_maps (lightingctx_t *lctx, vulkan_ctx_t *ctx) totalLayers, lctx->num_maps, lctx->shadow_resources ? lctx->shadow_resources->size : (VkDeviceSize) 0); + if (developer & SYS_lighting) { + auto images = lctx->shadow_resources->objects; + for (int i = 0; i < lctx->num_maps; i++) { + printf ("map id:%d width:%d layers:%d\n", i, + images[i].image.extent.width, images[i].image.num_layers); + } + } } static void