[vulkan] Use separate tracy GPU context for light culling

My efforts (especially the collect zone (what was I thinking)) got
tracy's knickers in a twist resulting in vanishing zones in the server.
It looks like there are some synchronisation issues between cpu and gpu,
but I'm not *too* worried about it at this stage.
This commit is contained in:
Bill Currie 2023-12-16 14:00:01 +09:00
parent f282bfc045
commit 00ecb7d71a
4 changed files with 24 additions and 12 deletions

View file

@ -56,7 +56,7 @@ enum {
enum {
lighting_main,
lighting_shadow,
lighting_debug,
lighting_hull,
};
typedef struct qfv_light_render_s {
@ -100,6 +100,8 @@ typedef struct lightingframe_s {
light_queue_t stage_queue[LIGHTING_STAGES];
// map_id (0,5) first layer (5,11)
uint16_t *stage_targets;
qftVkCtx_t *qftVkCtx;
} lightingframe_t;
typedef struct lightingframeset_s

View file

@ -45,7 +45,7 @@ static inline void __qftVkZoneEnd (___tracy_vkctx_scope ***zone)
#define qftCVkContextHostCalibrated(instance, physdev, device, instanceProcAddr, deviceProcAddr)
#define qftCVkContextDestroy(ctx)
#define qftCVkContextName(ctx, name, size)
#define qftCVkContextCollect(ctx, cmdbuf)
#define qftCVkCollect(ctx, cmdbuf)
#define qftVkZone(ctx, cmdbuf, name) \
do { (void)(ctx); (void) (cmdbuf); } while (0)

View file

@ -1374,7 +1374,7 @@ renderpasses = {
color = $color.lights;
tasks = (
{ func = lighting_bind_descriptors;
params = (debug, none); },
params = (hull, none); },
{ func = lighting_draw_hulls; },
);
@ -1921,7 +1921,7 @@ renderpasses = {
color = $color.lights;
tasks = (
{ func = lighting_bind_descriptors;
params = (debug, none); },
params = (hull, none); },
{ func = lighting_draw_splats; },
);
@ -1975,7 +1975,7 @@ renderpasses = {
color = $color.lights;
tasks = (
{ func = lighting_bind_descriptors;
params = (debug, none); },
params = (hull, none); },
{ func = lighting_draw_splats; },
);

View file

@ -927,7 +927,7 @@ lighting_bind_descriptors (const exprval_t **params, exprval_t *result,
auto shadow_type = *(int *) params[0]->value;
auto stage = *(int *) params[1]->value;
if (stage == lighting_debug) {
if (stage == lighting_hull) {
VkDescriptorSet sets[] = {
Vulkan_Matrix_Descriptors (ctx, ctx->curFrame),
lframe->lights_set,
@ -1009,12 +1009,13 @@ lighting_cull_lights (const exprval_t **params, exprval_t *result,
.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO,
.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT,
});
{
qftVkScopedZoneC (taskctx->frame->qftVkCtx, cmd, "reset", 0xc0a000);
dfunc->vkCmdResetQueryPool (cmd, lframe->query, 0, MaxLights);
}
qftCVkCollect (lframe->qftVkCtx, cmd);
dfunc->vkCmdResetQueryPool (cmd, lframe->query, 0, MaxLights);
auto qftVkCtx = taskctx->frame->qftVkCtx;
taskctx->frame->qftVkCtx = lframe->qftVkCtx;
auto renderpass = &render->renderpasses[0];
QFV_RunRenderPassCmd (cmd, ctx, renderpass, 0);
taskctx->frame->qftVkCtx = qftVkCtx;
dfunc->vkEndCommandBuffer (cmd);
qfMessageL ("submit");
@ -1128,12 +1129,12 @@ static exprtype_t lighting_stage_type = {
static int lighting_stage_values[] = {
lighting_main,
lighting_shadow,
lighting_debug,
lighting_hull,
};
static exprsym_t lighting_stage_symbols[] = {
{"main", &lighting_stage_type, lighting_stage_values + 0},
{"shadow", &lighting_stage_type, lighting_stage_values + 1},
{"debug", &lighting_stage_type, lighting_stage_values + 2},
{"hull", &lighting_stage_type, lighting_stage_values + 2},
{}
};
static exprtab_t lighting_stage_symtab = { .symbols = lighting_stage_symbols };
@ -1672,6 +1673,15 @@ Vulkan_Lighting_Setup (vulkan_ctx_t *ctx)
.queryCount = MaxLights,
}, 0, &lframe->query);
lframe->fence = QFV_CreateFence (device, 1);
#ifdef TRACY_ENABLE
auto instance = ctx->instance->instance;
auto physdev = ctx->device->physDev->dev;
auto gipa = ctx->vkGetInstanceProcAddr;
auto gdpa = ctx->instance->funcs->vkGetDeviceProcAddr;
lframe->qftVkCtx = qftCVkContextHostCalibrated (instance, physdev,
device->dev,
gipa, gdpa);
#endif
}
size_t target_count = MaxLights * 6;
size_t target_size = frames * sizeof (uint16_t[target_count]);