[vulkan] Cope with an empty world model

Vulkan doesn't appreciate the empty buffers that result from the model
not having any textures or surfaces that can be rendered (rightfully so,
for such a bare-metal api).
This commit is contained in:
Bill Currie 2022-04-26 07:26:32 +09:00
parent 5703df00fd
commit c4d56afd33
3 changed files with 25 additions and 7 deletions

View file

@ -303,7 +303,9 @@ Vulkan_Mod_ProcessTexture (model_t *mod, texture_t *tx, vulkan_ctx_t *ctx)
mod->data = mctx; mod->data = mctx;
r_notexture_mip->render = &vulkan_notexture; r_notexture_mip->render = &vulkan_notexture;
load_textures (mod, ctx); if (mod->brush.numtextures) {
load_textures (mod, ctx);
}
return; return;
} }

View file

@ -413,6 +413,10 @@ Vulkan_BuildDisplayLists (model_t **models, int num_models, vulkan_ctx_t *ctx)
bsppoly_t *poly; bsppoly_t *poly;
mod_brush_t *brush; mod_brush_t *brush;
if (!num_models) {
return;
}
// run through all surfaces, chaining them to their textures, thus // run through all surfaces, chaining them to their textures, thus
// effectively sorting the surfaces by texture (without worrying about // effectively sorting the surfaces by texture (without worrying about
// surface order on the same texture chain). // surface order on the same texture chain).
@ -1037,6 +1041,9 @@ Vulkan_DrawWorld (qfv_renderframe_t *rFrame)
bctx->color = 0; bctx->color = 0;
R_VisitWorldNodes (brush, ctx); R_VisitWorldNodes (brush, ctx);
if (!bctx->vertex_buffer) {
return;
}
if (r_drawentities) { if (r_drawentities) {
for (size_t i = 0; i < r_ent_queue->ent_queues[mod_brush].size; i++) { for (size_t i = 0; i < r_ent_queue->ent_queues[mod_brush].size; i++) {
entity_t *ent = r_ent_queue->ent_queues[mod_brush].a[i]; entity_t *ent = r_ent_queue->ent_queues[mod_brush].a[i];
@ -1089,6 +1096,9 @@ Vulkan_Bsp_Flush (vulkan_ctx_t *ctx)
size_t offset = bframe->index_offset; size_t offset = bframe->index_offset;
size_t size = bframe->index_count * sizeof (uint32_t); size_t size = bframe->index_count * sizeof (uint32_t);
if (!bframe->index_count) {
return;
}
offset &= ~atom_mask; offset &= ~atom_mask;
size = (size + atom_mask) & ~atom_mask; size = (size + atom_mask) & ~atom_mask;

View file

@ -927,6 +927,10 @@ Vulkan_LoadLights (model_t *model, const char *entity_data, vulkan_ctx_t *ctx)
lightingctx_t *lctx = ctx->lighting_context; lightingctx_t *lctx = ctx->lighting_context;
plitem_t *entities = 0; plitem_t *entities = 0;
if (!entity_data) {
return;
}
lctx->lights.size = 0; lctx->lights.size = 0;
lctx->lightleafs.size = 0; lctx->lightleafs.size = 0;
lctx->lightmats.size = 0; lctx->lightmats.size = 0;
@ -1006,11 +1010,13 @@ Vulkan_LoadLights (model_t *model, const char *entity_data, vulkan_ctx_t *ctx)
PL_Free (entities); PL_Free (entities);
} }
Sys_MaskPrintf (SYS_vulkan, "loaded %zd lights\n", lctx->lights.size); Sys_MaskPrintf (SYS_vulkan, "loaded %zd lights\n", lctx->lights.size);
build_shadow_maps (lctx, ctx); if (lctx->lights.size) {
create_light_matrices (lctx); build_shadow_maps (lctx, ctx);
locate_lights (model, lctx); create_light_matrices (lctx);
for (size_t i = 0; i < lctx->lights.size; i++) { locate_lights (model, lctx);
dump_light (&lctx->lights.a[i], lctx->lightleafs.a[i], for (size_t i = 0; i < lctx->lights.size; i++) {
lctx->lightmats.a[i]); dump_light (&lctx->lights.a[i], lctx->lightleafs.a[i],
lctx->lightmats.a[i]);
}
} }
} }