rtx: fix missing flashlight in c1a4i

Just increase point lights limit per light cell.

Also:
- update infotool to show point lights info
- move light cluster finalization to vk_scene to make sure infotool has
  the recentmost data
This commit is contained in:
Ivan Avdeev 2021-12-26 23:12:50 -08:00
parent f86da445b7
commit b67668430b
6 changed files with 38 additions and 16 deletions

View File

@ -102,7 +102,7 @@ void XVK_CameraDebugPrintCenterEntity( void ) {
const vk_lights_cell_t *cell = (cell_index >= 0 && cell_index < MAX_LIGHT_CLUSTERS) ? g_lights.cells + cell_index : NULL;
p += Q_snprintf(p, end - p,
"light raw=(%d, %d, %d) cell=(%d, %d, %d) index=%d surf=%d point=%d\n%s",
"light raw=(%d, %d, %d) cell=(%d, %d, %d) index=%d surf=%d point=%d\n",
cell_raw[0],
cell_raw[1],
cell_raw[2],
@ -111,12 +111,22 @@ void XVK_CameraDebugPrintCenterEntity( void ) {
light_cell[2],
cell_index,
cell ? cell->num_emissive_surfaces : -1,
cell ? cell->num_point_lights : -1,
cell && cell->num_emissive_surfaces ? "surf:" : "");
if (cell) {
cell ? cell->num_point_lights : -1);
if (cell && cell->num_emissive_surfaces > 0) {
p += Q_snprintf(p, end - p, "surf:");
for (int i = 0; i < cell->num_emissive_surfaces; ++i) {
p += Q_snprintf(p, end - p, " %d", cell->emissive_surfaces[i]);
}
p += Q_snprintf(p, end - p, "\n");
}
if (cell && cell->num_point_lights > 0) {
p += Q_snprintf(p, end - p, "point:");
for (int i = 0; i < cell->num_point_lights; ++i) {
p += Q_snprintf(p, end - p, " %d", cell->point_lights[i]);
}
p += Q_snprintf(p, end - p, "\n");
}
}

View File

@ -19,7 +19,7 @@
layout (constant_id = 0) const uint MAX_POINT_LIGHTS = 32;
layout (constant_id = 1) const uint MAX_EMISSIVE_KUSOCHKI = 256;
layout (constant_id = 2) const uint MAX_VISIBLE_POINT_LIGHTS = 31;
layout (constant_id = 2) const uint MAX_VISIBLE_POINT_LIGHTS = 63;
layout (constant_id = 3) const uint MAX_VISIBLE_SURFACE_LIGHTS = 255;
#endif

View File

@ -15,7 +15,7 @@
#define MAX_POINT_LIGHTS 256
// indexed by uint8_t
#define MAX_VISIBLE_POINT_LIGHTS 31
#define MAX_VISIBLE_POINT_LIGHTS 63
// indexed by uint8_t
#define MAX_VISIBLE_SURFACE_LIGHTS 255

View File

@ -519,6 +519,10 @@ static qboolean addLightToCell( int cell_index, int light_index ) {
if (cluster->num_point_lights == MAX_VISIBLE_POINT_LIGHTS)
return false;
if (debug_dump_lights.enabled) {
gEngine.Con_Reportf(" adding point light %d to cell %d (count=%d)\n", light_index, cell_index, cluster->num_point_lights+1);
}
cluster->point_lights[cluster->num_point_lights++] = light_index;
return true;
}
@ -700,6 +704,15 @@ static void addLightIndexToleaf( const mleaf_t *leaf, int index ) {
const int max_y = ceilf(leaf->minmaxs[4] / LIGHT_GRID_CELL_SIZE);
const int max_z = ceilf(leaf->minmaxs[5] / LIGHT_GRID_CELL_SIZE);
if (debug_dump_lights.enabled) {
gEngine.Con_Reportf(" adding leaf %d min=(%d, %d, %d), max=(%d, %d, %d) total=%d\n",
leaf->cluster,
min_x, min_y, min_z,
max_x, max_y, max_z,
(max_x - min_x) * (max_y - min_y) * (max_z - min_z)
);
}
for (int x = min_x; x < max_x; ++x)
for (int y = min_y; y < max_y; ++y)
for (int z = min_z; z < max_z; ++z) {
@ -836,9 +849,6 @@ static void addDlight( const dlight_t *dlight ) {
int index;
float scaler;
if( !dlight || dlight->die < gpGlobals->time || !dlight->radius )
return;
max_comp = Q_max(dlight->color.r, Q_max(dlight->color.g, dlight->color.b));
if (max_comp < k_threshold || dlight->radius <= k_light_radius)
return;
@ -996,6 +1006,8 @@ void VK_LightsFrameFinalize( void ) {
APROF_SCOPE_BEGIN(dlights);
for (int i = 0; i < MAX_DLIGHTS; ++i) {
const dlight_t *dlight = gEngine.GetDynamicLight(i);
if( !dlight || dlight->die < gpGlobals->time || !dlight->radius )
continue;
addDlight(dlight);
}
APROF_SCOPE_END(dlights);

View File

@ -339,6 +339,7 @@ void VK_RayFrameBegin( void )
XVK_RayModel_ClearForNextFrame();
// TODO: move all lighting update to scene?
if (g_rtx.reload_lighting) {
g_rtx.reload_lighting = false;
VK_LightsLoadMapStaticLights();
@ -784,10 +785,7 @@ LIST_GBUFFER_IMAGES(GBUFFER_WRITE_BARRIER)
}
// Finalize and update dynamic lights
static void updateLights( void )
{
VK_LightsFrameFinalize();
static void uploadLights ( void ) {
// Upload light grid
{
vk_ray_shader_light_grid *grid = g_rtx.light_grid_buffer.mapped;
@ -988,7 +986,7 @@ void VK_RayFrameEnd(const vk_ray_frame_render_args_t* args)
g_rtx.reload_pipeline = false;
}
updateLights();
uploadLights();
if (g_ray_model_state.frame.num_models == 0) {
const xvk_blit_args blit_args = {

View File

@ -595,8 +595,7 @@ static void drawEntity( cl_entity_t *ent, int render_mode )
static float g_frametime = 0;
void VK_SceneRender( const ref_viewpass_t *rvp )
{
void VK_SceneRender( const ref_viewpass_t *rvp ) {
int current_pipeline_index = kRenderNormal;
g_frametime = /*FIXME VK RP_NORMALPASS( )) ? */
@ -662,6 +661,9 @@ void VK_SceneRender( const ref_viewpass_t *rvp )
VK_RenderDebugLabelEnd();
if (vk_core.rtx)
VK_LightsFrameFinalize();
if (ui_infotool->value > 0)
XVK_CameraDebugPrintCenterEntity();
}