From 869cc4050ca098c44dfe11cd25f3980851a8b6d3 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Fri, 17 Dec 2021 15:52:17 +0900 Subject: [PATCH] [vulkan] Flush bsp vertex indices after all drawing --- include/QF/Vulkan/qf_bsp.h | 1 + libs/video/renderer/vulkan/vulkan_bsp.c | 15 +++++++++++---- libs/video/renderer/vulkan/vulkan_main.c | 18 +++++++++++------- 3 files changed, 23 insertions(+), 11 deletions(-) diff --git a/include/QF/Vulkan/qf_bsp.h b/include/QF/Vulkan/qf_bsp.h index 1408ce64a..9f1108601 100644 --- a/include/QF/Vulkan/qf_bsp.h +++ b/include/QF/Vulkan/qf_bsp.h @@ -170,6 +170,7 @@ void Vulkan_ClearElements (struct vulkan_ctx_s *ctx); void Vulkan_DrawWorld (struct qfv_renderframe_s *rFrame); void Vulkan_DrawSky (struct qfv_renderframe_s *rFrame); void Vulkan_DrawWaterSurfaces (struct qfv_renderframe_s *rFrame); +void Vulkan_Bsp_Flush (struct vulkan_ctx_s *ctx); void Vulkan_LoadSkys (const char *sky, struct vulkan_ctx_s *ctx); void Vulkan_RegisterTextures (model_t **models, int num_models, struct vulkan_ctx_s *ctx); diff --git a/libs/video/renderer/vulkan/vulkan_bsp.c b/libs/video/renderer/vulkan/vulkan_bsp.c index 26ea253f1..98ccb1ecc 100644 --- a/libs/video/renderer/vulkan/vulkan_bsp.c +++ b/libs/video/renderer/vulkan/vulkan_bsp.c @@ -1041,7 +1041,7 @@ build_tex_elechain (vulktex_t *tex, bspctx_t *bctx, bspframe_t *bframe) elements_t *el = 0; for (is = tex->tex_chain; is; is = is->tex_chain) { - // emit the polygon indices for the the surface to the texture's + // emit the polygon indices for the surface to the texture's // element chain add_surf_elements (tex, is, &ec, &el, bctx, bframe); } @@ -1110,7 +1110,15 @@ Vulkan_DrawWorld (qfv_renderframe_t *rFrame) tex->elechain_tail = &tex->elechain; } bsp_end (ctx); +} +void +Vulkan_Bsp_Flush (vulkan_ctx_t *ctx) +{ + qfv_device_t *device = ctx->device; + qfv_devfuncs_t *dfunc = device->funcs; + bspctx_t *bctx = ctx->bsp_context; + bspframe_t *bframe = &bctx->frames.a[ctx->curFrame]; size_t atom = device->physDev->properties.limits.nonCoherentAtomSize; size_t atom_mask = atom - 1; size_t offset = bframe->index_offset; @@ -1119,7 +1127,6 @@ Vulkan_DrawWorld (qfv_renderframe_t *rFrame) offset &= ~atom_mask; size = (size + atom_mask) & ~atom_mask; - //FIXME this needs to come at the end of the frame after all passes VkMappedMemoryRange range = { VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE, 0, bctx->index_memory, offset, size @@ -1165,7 +1172,7 @@ Vulkan_DrawWaterSurfaces (qfv_renderframe_t *rFrame) } tex = surf->texinfo->texture->render; } - // emit the polygon indices for the the surface to the texture's + // emit the polygon indices for the surface to the texture's // element chain add_surf_elements (tex, is, &ec, &el, bctx, bframe); } @@ -1227,7 +1234,7 @@ Vulkan_DrawSky (qfv_renderframe_t *rFrame) } tex = surf->texinfo->texture->render; } - // emit the polygon indices for the the surface to the texture's + // emit the polygon indices for the surface to the texture's // element chain add_surf_elements (tex, is, &ec, &el, bctx, bframe); } diff --git a/libs/video/renderer/vulkan/vulkan_main.c b/libs/video/renderer/vulkan/vulkan_main.c index a8cf1a1d7..62775419e 100644 --- a/libs/video/renderer/vulkan/vulkan_main.c +++ b/libs/video/renderer/vulkan/vulkan_main.c @@ -131,7 +131,7 @@ void Vulkan_RenderView (qfv_renderframe_t *rFrame) { vulkan_ctx_t *ctx = rFrame->vulkan_ctx; - double t[9] = {}; + double t[10] = {}; int speeds = r_speeds->int_val; if (!r_worldentity.renderer.model) { @@ -165,14 +165,18 @@ Vulkan_RenderView (qfv_renderframe_t *rFrame) Vulkan_DrawParticles (ctx); if (speeds) t[8] = Sys_DoubleTime (); + Vulkan_Bsp_Flush (ctx); + if (speeds) + t[9] = Sys_DoubleTime (); if (speeds) { + double total = (t[9] - t[0]) * 1000; + for (int i = 0; i < 9; i++) { + t[i] = (t[i + 1] - t[i]) * 1000; + } Sys_Printf ("frame: %g, setup: %g, mark: %g, pushdl: %g, world: %g," - " sky: %g, ents: %g, water: %g, part: %g\n", - (t[8] - t[0]) * 1000, (t[1] - t[0]) * 1000, - (t[2] - t[1]) * 1000, (t[3] - t[2]) * 1000, - (t[4] - t[3]) * 1000, (t[5] - t[4]) * 1000, - (t[6] - t[5]) * 1000, (t[7] - t[6]) * 1000, - (t[8] - t[7]) * 1000); + " sky: %g, ents: %g, water: %g, flush: %g, part: %g\n", + total, + t[0], t[1], t[2], t[3], t[4], t[5], t[6], t[7], t[8]); } }