Code path clean up

This commit is contained in:
Denis Pauk 2023-09-10 18:00:29 +03:00
parent ede4069a44
commit 24933bce91
8 changed files with 138 additions and 206 deletions

View file

@ -341,9 +341,9 @@ REFVK_OBJS_ := \
src/vk/vk_mesh.o \ src/vk/vk_mesh.o \
src/vk/vk_model.o \ src/vk/vk_model.o \
src/vk/vk_pipeline.o \ src/vk/vk_pipeline.o \
src/vk/vk_rmain.o \ src/vk/vk_main.o \
src/vk/vk_rmisc.o \ src/vk/vk_misc.o \
src/vk/vk_rsurf.o \ src/vk/vk_surf.o \
src/vk/vk_shaders.o \ src/vk/vk_shaders.o \
src/vk/vk_swapchain.o \ src/vk/vk_swapchain.o \
src/vk/vk_validation.o \ src/vk/vk_validation.o \

View file

@ -1,23 +1,29 @@
/* /*
Copyright (C) 1997-2001 Id Software, Inc. * Copyright (C) 1997-2001 Id Software, Inc.
Copyright (C) 2018-2019 Krzysztof Kondrak * Copyright (C) 2018-2019 Krzysztof Kondrak
*
This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or modify
modify it under the terms of the GNU General Public License * it under the terms of the GNU General Public License as published by
as published by the Free Software Foundation; either version 2 * the Free Software Foundation; either version 2 of the License, or (at
of the License, or (at your option) any later version. * your option) any later version.
*
This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful, but
but WITHOUT ANY WARRANTY; without even the implied warranty of * WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
See the GNU General Public License for more details. * See the GNU General Public License for more details.
*
You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*/ *
* =======================================================================
*
* Header for the model stuff.
*
* =======================================================================
*/
#ifndef __VK_MODEL_H__ #ifndef __VK_MODEL_H__
#define __VK_MODEL_H__ #define __VK_MODEL_H__
@ -66,7 +72,6 @@ typedef struct msurface_s
short texturemins[2]; short texturemins[2];
short extents[2]; short extents[2];
short lmshift; short lmshift;
int light_s, light_t; // gl lightmap coordinates int light_s, light_t; // gl lightmap coordinates
@ -92,11 +97,7 @@ typedef struct msurface_s
byte *samples; // [numstyles*surfsize] byte *samples; // [numstyles*surfsize]
} msurface_t; } msurface_t;
//=================================================================== /* Whole model */
//
// Whole model
//
typedef struct model_s typedef struct model_s
{ {

View file

@ -1,37 +1,34 @@
/* /*
Copyright (C) 1997-2001 Id Software, Inc. * Copyright (C) 1997-2001 Id Software, Inc.
Copyright (C) 2018-2019 Krzysztof Kondrak * Copyright (C) 2018-2019 Krzysztof Kondrak
*
This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or modify
modify it under the terms of the GNU General Public License * it under the terms of the GNU General Public License as published by
as published by the Free Software Foundation; either version 2 * the Free Software Foundation; either version 2 of the License, or (at
of the License, or (at your option) any later version. * your option) any later version.
*
This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful, but
but WITHOUT ANY WARRANTY; without even the implied warranty of * WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
See the GNU General Public License for more details. * See the GNU General Public License for more details.
*
You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*/ *
// vk_light.c * =======================================================================
*
* Lightmaps and dynamic lighting
*
* =======================================================================
*/
#include "header/local.h" #include "header/local.h"
int r_dlightframecount; int r_dlightframecount;
/*
=============================================================================
DYNAMIC LIGHTS BLEND RENDERING
=============================================================================
*/
static void static void
R_RenderDlight(dlight_t *light) R_RenderDlight(dlight_t *light)
{ {
@ -119,19 +116,15 @@ DYNAMIC LIGHTS
============================================================================= =============================================================================
*/ */
/*
=============
R_MarkSurfaceLights
=============
*/
void void
R_MarkSurfaceLights(dlight_t *light, int bit, mnode_t *node, int r_dlightframecount) R_MarkSurfaceLights(dlight_t *light, int bit, mnode_t *node, int r_dlightframecount)
{ {
msurface_t *surf; msurface_t *surf;
int i; int i;
// mark the polygons /* mark the polygons */
surf = r_worldmodel->surfaces + node->firstsurface; surf = r_worldmodel->surfaces + node->firstsurface;
for (i=0 ; i<node->numsurfaces ; i++, surf++) for (i=0 ; i<node->numsurfaces ; i++, surf++)
{ {
if (surf->dlightframe != r_dlightframecount) if (surf->dlightframe != r_dlightframecount)
@ -293,11 +286,6 @@ RecursiveLightPoint(mnode_t *node, vec3_t start, vec3_t end, vec3_t pointcolor)
return RecursiveLightPoint(node->children[!side], mid, end, pointcolor); return RecursiveLightPoint(node->children[!side], mid, end, pointcolor);
} }
/*
===============
R_LightPoint
===============
*/
void void
R_LightPoint(vec3_t p, vec3_t color, entity_t *currententity) R_LightPoint(vec3_t p, vec3_t color, entity_t *currententity)
{ {
@ -327,22 +315,21 @@ R_LightPoint(vec3_t p, vec3_t color, entity_t *currententity)
VectorCopy(pointcolor, color); VectorCopy(pointcolor, color);
} }
// /* add dynamic lights */
// add dynamic lights
//
dl = r_newrefdef.dlights; dl = r_newrefdef.dlights;
for (lnum = 0; lnum < r_newrefdef.num_dlights; lnum++, dl++) for (lnum = 0; lnum < r_newrefdef.num_dlights; lnum++, dl++)
{ {
float add; float add;
VectorSubtract(currententity->origin, VectorSubtract(currententity->origin,
dl->origin, dl->origin, dist);
dist);
add = dl->intensity - VectorLength(dist); add = dl->intensity - VectorLength(dist);
add *= (1.0/256); add *= (1.0 / 256);
if (add > 0) if (add > 0)
{ {
VectorMA (color, add, dl->color, color); VectorMA(color, add, dl->color, color);
} }
} }
@ -620,12 +607,11 @@ store:
{ {
for (j = 0; j < smax; j++) for (j = 0; j < smax; j++)
{ {
r = Q_ftol(bl[0]); r = Q_ftol(bl[0]);
g = Q_ftol(bl[1]); g = Q_ftol(bl[1]);
b = Q_ftol(bl[2]); b = Q_ftol(bl[2]);
// catch negative lights /* catch negative lights */
if (r < 0) if (r < 0)
{ {
r = 0; r = 0;
@ -641,9 +627,7 @@ store:
b = 0; b = 0;
} }
/* /* determine the brightest of the three color components */
** determine the brightest of the three color components
*/
if (r > g) if (r > g)
{ {
max = r; max = r;
@ -658,17 +642,14 @@ store:
max = b; max = b;
} }
/* /* alpha is ONLY used for the mono lightmap case. For this
** alpha is ONLY used for the mono lightmap case. For this reason reason we set it to the brightest of the color components
** we set it to the brightest of the color components so that so that things don't get too dim. */
** things don't get too dim.
*/
a = max; a = max;
/* /* rescale all the color components if the
** rescale all the color components if the intensity of the greatest intensity of the greatest channel exceeds
** channel exceeds 1.0 1.0 */
*/
if (max > 255) if (max > 255)
{ {
float t = 255.0F / max; float t = 255.0F / max;

View file

@ -1,24 +1,29 @@
/* /*
Copyright (C) 1997-2001 Id Software, Inc. * Copyright (C) 1997-2001 Id Software, Inc.
Copyright (C) 2018-2019 Krzysztof Kondrak * Copyright (C) 2018-2019 Krzysztof Kondrak
*
This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or modify
modify it under the terms of the GNU General Public License * it under the terms of the GNU General Public License as published by
as published by the Free Software Foundation; either version 2 * the Free Software Foundation; either version 2 of the License, or (at
of the License, or (at your option) any later version. * your option) any later version.
*
This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful, but
but WITHOUT ANY WARRANTY; without even the implied warranty of * WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
See the GNU General Public License for more details. * See the GNU General Public License for more details.
*
You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*/ *
// vk_model.c -- model loading and caching * =======================================================================
*
* Model loading and caching. Includes the .bsp file format
*
* =======================================================================
*/
#include "header/local.h" #include "header/local.h"
@ -33,12 +38,6 @@ static int models_known_max = 0;
int registration_sequence; int registration_sequence;
/*
==============
Mod_ClusterPVS
==============
*/
const byte * const byte *
Mod_ClusterPVS(int cluster, const model_t *model) Mod_ClusterPVS(int cluster, const model_t *model)
{ {
@ -55,11 +54,6 @@ Mod_ClusterPVS(int cluster, const model_t *model)
//=============================================================================== //===============================================================================
/*
===============
Mod_Reallocate
===============
*/
static void static void
Mod_Reallocate (void) Mod_Reallocate (void)
{ {
@ -88,11 +82,6 @@ Mod_Reallocate (void)
models_known = calloc(models_known_max, sizeof(model_t)); models_known = calloc(models_known_max, sizeof(model_t));
} }
/*
===============
Mod_Init
===============
*/
void void
Mod_Init(void) Mod_Init(void)
{ {
@ -107,12 +96,8 @@ Mod_Init(void)
Mod_Reallocate (); Mod_Reallocate ();
} }
/* static void
================ Mod_Free(model_t *mod)
Mod_Free
================
*/
static void Mod_Free (model_t *mod)
{ {
if (!mod->extradata) if (!mod->extradata)
{ {
@ -135,12 +120,8 @@ static void Mod_Free (model_t *mod)
} }
} }
/* void
================ Mod_FreeAll (void)
Mod_FreeAll
================
*/
void Mod_FreeAll (void)
{ {
int i; int i;
@ -151,30 +132,13 @@ void Mod_FreeAll (void)
} }
} }
/* void
================ Mod_FreeModelsKnown (void)
Mod_FreeModelsKnown
================
*/
void Mod_FreeModelsKnown (void)
{ {
free(models_known); free(models_known);
models_known = NULL; models_known = NULL;
} }
/*
===============================================================================
BRUSHMODEL LOADING
===============================================================================
*/
/*
=================
Mod_LoadSubmodels
=================
*/
static void static void
Mod_LoadSubmodels (model_t *loadmodel, const byte *mod_base, const lump_t *l) Mod_LoadSubmodels (model_t *loadmodel, const byte *mod_base, const lump_t *l)
{ {
@ -220,9 +184,9 @@ Mod_LoadSubmodels (model_t *loadmodel, const byte *mod_base, const lump_t *l)
} }
out->radius = Mod_RadiusFromBounds(out->mins, out->maxs); out->radius = Mod_RadiusFromBounds(out->mins, out->maxs);
out->firstnode = LittleLong (in->headnode); out->firstnode = LittleLong(in->headnode);
out->firstmodelsurface = LittleLong (in->firstface); out->firstmodelsurface = LittleLong(in->firstface);
out->nummodelsurfaces = LittleLong (in->numfaces); out->nummodelsurfaces = LittleLong(in->numfaces);
// visleafs // visleafs
out->numleafs = 0; out->numleafs = 0;
// check limits // check limits
@ -235,12 +199,8 @@ Mod_LoadSubmodels (model_t *loadmodel, const byte *mod_base, const lump_t *l)
} }
/* /*
================ * Fills in s->texturemins[] and s->extents[]
CalcSurfaceExtents */
Fills in s->texturemins[] and s->extents[]
================
*/
static void static void
CalcSurfaceExtents(model_t *loadmodel, msurface_t *s) CalcSurfaceExtents(model_t *loadmodel, msurface_t *s)
{ {
@ -489,7 +449,7 @@ Mod_LoadBSPX(int filesize, byte* mod_base)
} }
static void static void
SetSurfaceLighting(model_t* loadmodel, msurface_t* out, byte* styles, int lightofs) SetSurfaceLighting(model_t *loadmodel, msurface_t *out, byte *styles, int lightofs)
{ {
int i; int i;
@ -703,11 +663,6 @@ Mod_LoadLeafs(model_t *loadmodel, const byte *mod_base, const lump_t *l)
} }
} }
/*
=================
Mod_LoadMarksurfaces
=================
*/
static void static void
Mod_LoadMarksurfaces(model_t *loadmodel, const byte *mod_base, const lump_t *l) Mod_LoadMarksurfaces(model_t *loadmodel, const byte *mod_base, const lump_t *l)
{ {
@ -732,7 +687,6 @@ Mod_LoadMarksurfaces(model_t *loadmodel, const byte *mod_base, const lump_t *l)
for (i = 0; i < count; i++) for (i = 0; i < count; i++)
{ {
int j; int j;
j = LittleShort(in[i]); j = LittleShort(in[i]);
if ((j < 0) || (j >= loadmodel->numsurfaces)) if ((j < 0) || (j >= loadmodel->numsurfaces))
@ -1032,12 +986,6 @@ RE_BeginRegistration (char *model)
r_viewcluster = -1; r_viewcluster = -1;
} }
/*
=====================
RE_RegisterModel
=====================
*/
struct model_s * struct model_s *
RE_RegisterModel(char *name) RE_RegisterModel(char *name)
{ {
@ -1098,12 +1046,8 @@ Mod_HasFreeSpace(void)
return (mod_loaded + mod_max) < models_known_max; return (mod_loaded + mod_max) < models_known_max;
} }
/* void
================ Mod_Modellist_f (void)
Mod_Modellist_f
================
*/
void Mod_Modellist_f (void)
{ {
int i, total, used; int i, total, used;
model_t *mod; model_t *mod;

View file

@ -1,24 +1,30 @@
/* /*
Copyright (C) 1997-2001 Id Software, Inc. * Copyright (C) 1997-2001 Id Software, Inc.
Copyright (C) 2018-2019 Krzysztof Kondrak * Copyright (C) 2018-2019 Krzysztof Kondrak
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* =======================================================================
*
* Surface generation and drawing
*
* =======================================================================
*/
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// vk_rsurf.c: surface-related refresh code
#include <assert.h> #include <assert.h>
#include "header/local.h" #include "header/local.h"

View file

@ -684,7 +684,7 @@ void R_DrawSkyBox (void)
/* /*
============ ============
RE_SetSky_s RE_SetSky
============ ============
*/ */
// 3dstudio environment map names // 3dstudio environment map names