remove unused vk_previous_frame module

This commit is contained in:
Ivan Avdeev 2023-08-28 13:12:02 -04:00
parent ffa9603747
commit e978871470
6 changed files with 9 additions and 147 deletions

View File

@ -13,7 +13,6 @@
#include "vk_geometry.h"
#include "vk_light.h"
#include "vk_mapents.h"
#include "vk_previous_frame.h"
#include "r_speeds.h"
#include "ref_params.h"
@ -36,6 +35,7 @@ typedef struct vk_brush_model_s {
int animated_indexes_count;
matrix4x4 prev_transform;
float prev_time;
struct {
int surfaces_count;
@ -124,7 +124,7 @@ static void addWarpVertIndCounts(const msurface_t *warp, int *num_vertices, int
}
typedef struct {
int ent_index;
float prev_time;
float scale;
const msurface_t *warp;
qboolean reverse;
@ -138,7 +138,6 @@ typedef struct {
static void brushComputeWaterPolys( compute_water_polys_t args ) {
const float time = gpGlobals->time;
const float prev_time = R_PrevFrame_Time(args.ent_index);
#define MAX_WATER_VERTICES 16
vk_vertex_t poly_vertices[MAX_WATER_VERTICES];
@ -176,8 +175,8 @@ static void brushComputeWaterPolys( compute_water_polys_t args ) {
nv = (r_turbsin[(int)(v[0] * 5.0f + time * 171.0f - v[1]) & 255] + 8.0f ) * 0.8f + nv;
nv = nv * scale + v[2];
prev_nv = r_turbsin[(int)(prev_time * 160.0f + v[1] + v[0]) & 255] + 8.0f;
prev_nv = (r_turbsin[(int)(v[0] * 5.0f + prev_time * 171.0f - v[1]) & 255] + 8.0f ) * 0.8f + prev_nv;
prev_nv = r_turbsin[(int)(args.prev_time * 160.0f + v[1] + v[0]) & 255] + 8.0f;
prev_nv = (r_turbsin[(int)(v[0] * 5.0f + args.prev_time * 171.0f - v[1]) & 255] + 8.0f ) * 0.8f + prev_nv;
prev_nv = prev_nv * scale + v[2];
}
else prev_nv = nv = v[2];
@ -341,8 +340,8 @@ static void fillWaterSurfaces( const cl_entity_t *ent, vk_brush_model_t *bmodel,
int vertices = 0, indices = 0;
brushComputeWaterPolys((compute_water_polys_t){
.prev_time = bmodel->prev_time,
.scale = scale,
.ent_index = ent ? ent->index : -1,
.reverse = false, // ??? is it ever true?
.warp = bmodel->engine_model->surfaces + surf_index,
@ -689,6 +688,7 @@ void VK_BrushModelDraw( const cl_entity_t *ent, int render_mode, float blend, co
});
Matrix4x4_Copy(bmodel->prev_transform, transform);
bmodel->prev_time = gpGlobals->time;
}
static model_sizes_t computeSizes( const model_t *mod ) {
@ -981,6 +981,9 @@ qboolean VK_BrushModelLoad( model_t *mod ) {
bmodel->engine_model = mod;
mod->cache.data = bmodel;
Matrix4x4_LoadIdentity(bmodel->prev_transform);
bmodel->prev_time = gpGlobals->time;
const model_sizes_t sizes = computeSizes( mod );
if (sizes.num_surfaces != 0) {

View File

@ -1,127 +0,0 @@
#include "vk_studio.h"
#include "vk_common.h"
#include "vk_textures.h"
#include "vk_render.h"
#include "vk_geometry.h"
#include "camera.h"
#include "xash3d_mathlib.h"
#include "const.h"
#include "r_studioint.h"
#include "triangleapi.h"
#include "studio.h"
#include "pm_local.h"
#include "pmtrace.h"
#include "protocol.h"
#include "enginefeatures.h"
#include "pm_movevars.h"
#include "xash3d_types.h"
#include <memory.h>
#include <stdlib.h>
#define PREV_STATES_COUNT 1024
#define PREV_FRAMES_COUNT 2
typedef struct {
matrix3x4 bones_worldtransform[MAXSTUDIOBONES];
matrix4x4 model_transform;
float time;
uint bones_frame_updated;
uint frame_updated;
} prev_state_t;
typedef struct {
prev_state_t prev_states[PREV_FRAMES_COUNT][PREV_STATES_COUNT];
uint frame_index;
uint prev_frame_index;
uint current_frame_id;
uint previous_frame_id;
} prev_states_storage_t;
prev_states_storage_t g_prev = { 0 };
prev_state_t* prevStateInArrayBounds( int frame_storage_id, int entity_id )
{
int clamped_entity_id = entity_id;
if (entity_id >= PREV_STATES_COUNT)
{
gEngine.Con_Printf("Previous frame states data for entity %d overflows storage (size is %d). Increase it\n", entity_id, PREV_STATES_COUNT);
clamped_entity_id = PREV_STATES_COUNT - 1; // fallback to last correct value
}
else if (entity_id < 0)
{
clamped_entity_id = 0; // fallback to correct value
}
return &g_prev.prev_states[frame_storage_id][clamped_entity_id];
}
#define PREV_FRAME(entity_id) prevStateInArrayBounds( g_prev.previous_frame_id, (entity_id) )
#define CURRENT_FRAME(entity_id) prevStateInArrayBounds( g_prev.current_frame_id, (entity_id) )
void R_PrevFrame_StartFrame( void )
{
g_prev.frame_index++;
g_prev.current_frame_id = g_prev.frame_index % PREV_FRAMES_COUNT;
g_prev.previous_frame_id = (g_prev.frame_index - 1) % PREV_FRAMES_COUNT;
}
void R_PrevFrame_SaveCurrentBoneTransforms( int entity_id, matrix3x4* bones_transforms, const matrix4x4 rotationmatrix_inv )
{
prev_state_t *current_frame = CURRENT_FRAME(entity_id);
if (current_frame->bones_frame_updated == g_prev.frame_index)
return; // already updated for this entity
current_frame->bones_frame_updated = g_prev.frame_index;
for( int i = 0; i < MAXSTUDIOBONES; i++ )
Matrix3x4_ConcatTransforms( current_frame->bones_worldtransform[i], rotationmatrix_inv, bones_transforms[i] );
}
void R_PrevFrame_SaveCurrentState( int entity_id, matrix4x4 model_transform )
{
prev_state_t* current_frame = CURRENT_FRAME(entity_id);
if (current_frame->frame_updated == g_prev.frame_index)
return; // already updated for this entity
Matrix4x4_Copy( current_frame->model_transform, model_transform );
current_frame->time = gpGlobals->time;
current_frame->frame_updated = g_prev.frame_index;
}
matrix3x4* R_PrevFrame_BoneTransforms( int entity_id )
{
prev_state_t* prev_frame = PREV_FRAME(entity_id);
// fallback to current frame if previous is outdated
if (prev_frame->bones_frame_updated != g_prev.frame_index - 1)
return CURRENT_FRAME(entity_id)->bones_worldtransform;
return prev_frame->bones_worldtransform;
}
void R_PrevFrame_ModelTransform( int entity_id, matrix4x4 model_matrix )
{
prev_state_t* prev_frame = PREV_FRAME(entity_id);
// fallback to current frame if previous is outdated
if (prev_frame->frame_updated != g_prev.frame_index - 1)
prev_frame = CURRENT_FRAME(entity_id);
Matrix4x4_Copy(model_matrix, prev_frame->model_transform);
}
float R_PrevFrame_Time( int entity_id )
{
prev_state_t* prev_frame = PREV_FRAME(entity_id);
// fallback to current frame if previous is outdated
if (prev_frame->frame_updated != g_prev.frame_index - 1)
return gpGlobals->time;
return prev_frame->time;
}

View File

@ -1,10 +0,0 @@
#pragma once
#include "vk_common.h"
void R_PrevFrame_StartFrame(void);
void R_PrevFrame_SaveCurrentBoneTransforms(int entity_id, matrix3x4* bones_transforms, const matrix4x4 rotationmatrix_inv);
void R_PrevFrame_SaveCurrentState(int entity_id, matrix4x4 model_transform);
matrix3x4* R_PrevFrame_BoneTransforms(int entity_id);
void R_PrevFrame_ModelTransform(int entity_id, matrix4x4 model_matrix);
float R_PrevFrame_Time(int entity_id);

View File

@ -12,7 +12,6 @@
#include "vk_rtx.h"
#include "vk_descriptor.h"
#include "vk_framectl.h" // FIXME needed for dynamic models cmdbuf
#include "vk_previous_frame.h"
#include "alolcator.h"
#include "profiler.h"
#include "r_speeds.h"

View File

@ -15,7 +15,6 @@
#include "vk_ray_internal.h"
#include "vk_staging.h"
#include "vk_textures.h"
#include "vk_previous_frame.h"
#include "vk_combuf.h"
#include "alolcator.h"
@ -135,7 +134,6 @@ void VK_RayFrameBegin( void ) {
RT_VkAccelFrameBegin();
XVK_RayModel_ClearForNextFrame();
R_PrevFrame_StartFrame();
RT_LightsFrameBegin();
}

View File

@ -4,7 +4,6 @@
#include "vk_textures.h"
#include "vk_render.h"
#include "vk_geometry.h"
#include "vk_previous_frame.h"
#include "vk_renderstate.h"
#include "vk_math.h"
#include "vk_cvar.h"