Merge pull request #552 from w23/E291

Fixes from stream E291
- [x] Late studio models: #546 
- [x] Silence verbose logs: #545 
- [x] Synchronize kusochki updates: #553
This commit is contained in:
Ivan Avdeev 2023-09-07 08:42:43 -07:00 committed by GitHub
commit 4944b5eb05
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 60 additions and 38 deletions

View File

@ -14,6 +14,7 @@
#include "vk_light.h"
#include "vk_mapents.h"
#include "r_speeds.h"
#include "vk_staging.h"
#include "vk_logs.h"
#include "ref_params.h"
@ -1341,7 +1342,7 @@ static rt_light_add_polygon_t loadPolyLight(const model_t *mod, const int surfac
// TODO split, don't clip
if (surf->numedges > 7)
WARN("emissive surface %d has %d vertices; clipping to 7", surface_index, surf->numedges);
WARN_THROTTLED(10, "emissive surface %d has %d vertices; clipping to 7", surface_index, surf->numedges);
VectorCopy(emissive, lpoly.emissive);
@ -1463,6 +1464,16 @@ void R_VkBrushModelCollectEmissiveSurfaces( const struct model_s *mod, qboolean
// RAD data in vk_light.c, so the emissive values are empty. This is the place and time where we actually get to
// know them, so let's fixup things.
// TODO minor optimization: sort geom_indices to have a better chance for them to be sequential
{
// Make sure that staging has been flushed.
// Updating materials leads to staging an upload to the same memory that we've just staged an upload to.
// This doesn't please the validator.
// Ensure that these uploads are not mixed into the same unsynchronized stream.
// TODO this might be not great for performance (extra waiting for GPU), so a better solution should be considered. E.g. tracking and barrier-syncing regions to-be-reuploaded.
R_VkStagingFlushSync();
}
R_RenderModelUpdateMaterials(&bmodel->render_model, geom_indices, emissive_surfaces_count);
INFO("Loaded %d polylights for %s model %s", emissive_surfaces_count, is_static ? "static" : "movable", mod->name);
}

View File

@ -18,34 +18,6 @@
#define Mem_FreePool( pool ) gEngine._Mem_FreePool( pool, __FILE__, __LINE__ )
#define Mem_EmptyPool( pool ) gEngine._Mem_EmptyPool( pool, __FILE__, __LINE__ )
#define PRINT_NOT_IMPLEMENTED_ARGS(msg, ...) do { \
static int called = 0; \
if ((called&1023) == 0) { \
gEngine.Con_Printf( S_ERROR "VK NOT_IMPLEMENTED(x%d): %s " msg "\n", called, __FUNCTION__, ##__VA_ARGS__ ); \
} \
++called; \
} while(0)
#define PRINT_NOT_IMPLEMENTED() do { \
static int called = 0; \
if ((called&1023) == 0) { \
gEngine.Con_Printf( S_ERROR "VK NOT_IMPLEMENTED(x%d): %s\n", called, __FUNCTION__ ); \
} \
++called; \
} while(0)
#define PRINT_THROTTLED(delay, prefix, msg, ...) do { \
static int called = 0; \
static double next_message_time = 0.; \
if (gpGlobals->realtime > next_message_time) { \
gEngine.Con_Printf( prefix "(x%d) " msg "\n", called, ##__VA_ARGS__ ); \
next_message_time = gpGlobals->realtime + delay; \
} \
++called; \
} while(0)
#define ERROR_THROTTLED(delay, msg, ...) PRINT_THROTTLED(delay, S_ERROR, msg, ##__VA_ARGS__)
#define ALIGN_UP(ptr, align) ((((ptr) + (align) - 1) / (align)) * (align))
#define COUNTOF(a) (sizeof(a)/sizeof((a)[0]))

View File

@ -1072,7 +1072,7 @@ int RT_LightAddPolygon(const rt_light_add_polygon_t *addpoly) {
return -1;
if (g_lights_.num_polygons == MAX_SURFACE_LIGHTS) {
ERR("Max number of polygon lights %d reached", MAX_SURFACE_LIGHTS);
ERROR_THROTTLED(10, "Max number of polygon lights %d reached", MAX_SURFACE_LIGHTS);
return -1;
}

View File

@ -20,6 +20,7 @@ extern uint32_t g_log_debug_bits;
// - load bits early at startup somehow. cvar is empty at init for some reason
// - module name in message
// - file:line in message
// - consistent prefixes (see THROTTLED variant)
#define DEBUG(msg, ...) \
do { \
@ -43,5 +44,36 @@ extern uint32_t g_log_debug_bits;
gEngine.Con_Printf("vk: " msg "\n", ##__VA_ARGS__); \
} while(0)
#define PRINT_THROTTLED(delay, prefix, msg, ...) \
do { \
static int called = 0; \
static double next_message_time = 0.; \
if (gpGlobals->realtime > next_message_time) { \
gEngine.Con_Printf( prefix "(x%d) " msg "\n", called, ##__VA_ARGS__ ); \
next_message_time = gpGlobals->realtime + delay; \
} \
++called; \
} while(0)
#define ERROR_THROTTLED(delay, msg, ...) PRINT_THROTTLED(delay, S_ERROR "vk: ", msg, ##__VA_ARGS__)
#define WARN_THROTTLED(delay, msg, ...) PRINT_THROTTLED(delay, S_WARN "vk: ", msg, ##__VA_ARGS__)
#define PRINT_NOT_IMPLEMENTED_ARGS(msg, ...) do { \
static int called = 0; \
if ((called&1023) == 0) { \
gEngine.Con_Printf( S_ERROR "VK NOT_IMPLEMENTED(x%d): %s " msg "\n", called, __FUNCTION__, ##__VA_ARGS__ ); \
} \
++called; \
} while(0)
#define PRINT_NOT_IMPLEMENTED() do { \
static int called = 0; \
if ((called&1023) == 0) { \
gEngine.Con_Printf( S_ERROR "VK NOT_IMPLEMENTED(x%d): %s\n", called, __FUNCTION__ ); \
} \
++called; \
} while(0)
// Read debug-enabled modules from cvar
void VK_LogsReadCvar(void);

View File

@ -8,6 +8,7 @@
#include "vk_renderstate.h"
#include "vk_pipeline.h"
#include "vk_descriptor.h"
#include "vk_logs.h"
#include "com_strings.h"
#include "eiface.h"

View File

@ -9,6 +9,7 @@
#include "vk_light.h"
#include "vk_math.h"
#include "vk_combuf.h"
#include "vk_logs.h"
#include "eiface.h"
#include "xash3d_mathlib.h"
@ -435,7 +436,7 @@ void RT_FrameAddOnce( rt_frame_add_once_t args ) {
for (int i = 0; i < args.geometries_count; ++i) {
if (dyn->geometries_count == MAX_RT_DYNAMIC_GEOMETRIES) {
gEngine.Con_Printf(S_ERROR "Too many dynamic geometries for mode %s\n", group_names[material_mode]);
ERROR_THROTTLED(1, "Too many dynamic geometries for mode %s\n", group_names[material_mode]);
break;
}

View File

@ -14,6 +14,7 @@
#include "vk_rpart.h"
#include "vk_triapi.h"
#include "r_speeds.h"
#include "vk_logs.h"
#include "xash3d_types.h"
#include "com_strings.h"

View File

@ -21,7 +21,8 @@ void CL_InitStudioAPI( void );
float R_StudioEstimateFrame( cl_entity_t *e, mstudioseqdesc_t *pseqdesc, double time );
void R_StudioLerpMovement( cl_entity_t *e, double time, vec3_t origin, vec3_t angles );
qboolean R_StudioModelPreload(model_t *mod);
struct r_studio_model_info_s;
const struct r_studio_model_info_s *R_StudioModelPreload(model_t *mod);
void R_StudioCacheClear( void );

View File

@ -172,7 +172,7 @@ static int studioModelGetSubmodels(const studiohdr_t *hdr, r_studio_submodel_inf
return count;
}
qboolean R_StudioModelPreload(model_t *mod) {
const r_studio_model_info_t* R_StudioModelPreload(model_t *mod) {
const studiohdr_t *const hdr = (const studiohdr_t *)gEngine.Mod_Extradata(mod_studio, mod);
ASSERT(g_studio_cache.models_count < MAX_STUDIO_MODELS);
@ -204,10 +204,10 @@ qboolean R_StudioModelPreload(model_t *mod) {
entry->info.submodels_count = submodels_count;
entry->info.submodels = submodels;
return true;
return &entry->info;
}
r_studio_model_info_t *getStudioModelInfo(model_t *model) {
const r_studio_model_info_t *getStudioModelInfo(model_t *model) {
const studiohdr_t *const hdr = (studiohdr_t *)gEngine.Mod_Extradata( mod_studio, model );
for (int i = 0; i < g_studio_cache.models_count; ++i) {
@ -217,7 +217,9 @@ r_studio_model_info_t *getStudioModelInfo(model_t *model) {
}
}
return NULL;
WARN("Studio model \"%s\" wasn't preloaded. How did that happen?", hdr->name);
return R_StudioModelPreload(model);
}
void VK_StudioModelInit(void) {

View File

@ -48,7 +48,7 @@ typedef struct {
r_studio_submodel_info_t *submodels;
} r_studio_model_info_t;
r_studio_model_info_t *getStudioModelInfo(model_t *model);
const r_studio_model_info_t *getStudioModelInfo(model_t *model);
// Entity model cache/pool
typedef struct {

View File

@ -2,6 +2,7 @@
#include "vk_geometry.h"
#include "vk_render.h"
#include "vk_sprite.h" // R_GetSpriteTexture
#include "vk_logs.h"
#include "vk_textures.h" // FIXME temp
@ -190,7 +191,7 @@ void TriVertex3fv( const float *v ) {
void TriVertex3f( float x, float y, float z ) {
if (g_triapi.num_vertices == MAX_TRIAPI_VERTICES - 1) {
gEngine.Con_Printf(S_ERROR "vk TriApi: trying to emit more than %d vertices in one batch\n", MAX_TRIAPI_VERTICES);
ERROR_THROTTLED(1, "vk TriApi: trying to emit more than %d vertices in one batch\n", MAX_TRIAPI_VERTICES);
return;
}