Skip to content

Commit

Permalink
Renderers: Move struct skinSurface_t and skin_t to tr_local.h and cle…
Browse files Browse the repository at this point in the history
…anup miniEntities

Cherrypicked: (taysta@0c78978)
Co-Authored-By: tayst <19374635+taysta@users.noreply.github.com>
  • Loading branch information
JKSunny and taysta committed Apr 15, 2024
1 parent 2f760d6 commit 65585d8
Show file tree
Hide file tree
Showing 10 changed files with 32 additions and 82 deletions.
14 changes: 0 additions & 14 deletions codemp/rd-common/tr_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -283,20 +283,6 @@ Ghoul2 Insert Start
#include "rd-common/mdx_format.h"
#include "qcommon/qfiles.h"

// skins allow models to be retextured without modifying the model file
//this is a mock copy, renderers may have their own implementation.
// try not to break the ghoul2 code which is very implicit :/
typedef struct _skinSurface_s {
char name[MAX_QPATH];
void *shader;
} _skinSurface_t;

typedef struct skin_s {
char name[MAX_QPATH]; // game path, including extension
int numSurfaces;
_skinSurface_t *surfaces[128];
} skin_t;

/*
Ghoul2 Insert End
*/
Expand Down
9 changes: 8 additions & 1 deletion codemp/rd-dedicated/tr_local.h
Original file line number Diff line number Diff line change
Expand Up @@ -537,11 +537,18 @@ typedef struct trRefdef_s {
//=================================================================================

// skins allow models to be retextured without modifying the model file
typedef struct skinSurface_s {
typedef struct {
char name[MAX_QPATH];
shader_t *shader;
} skinSurface_t;

typedef struct skin_s {
char name[MAX_QPATH]; // game path, including extension
int numSurfaces;
skinSurface_t *surfaces[128];
} skin_t;


typedef struct fog_s {
int originalBrushNumber;
vec3_t bounds[2];
Expand Down
4 changes: 2 additions & 2 deletions codemp/rd-dedicated/tr_skin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ qhandle_t RE_RegisterIndividualSkin( const char *name , qhandle_t hSkin)
break;
}
surf = (skinSurface_t *) Hunk_Alloc( sizeof( *skin->surfaces[0] ), h_low );
skin->surfaces[skin->numSurfaces] = (_skinSurface_t *)surf;
skin->surfaces[skin->numSurfaces] = (skinSurface_t *)surf;

Q_strncpyz( surf->name, surfName, sizeof( surf->name ) );

Expand Down Expand Up @@ -378,7 +378,7 @@ void R_InitSkins( void ) {
skin = tr.skins[0] = (struct skin_s *)ri.Hunk_Alloc( sizeof( skin_t ), h_low );
Q_strncpyz( skin->name, "<default skin>", sizeof( skin->name ) );
skin->numSurfaces = 1;
skin->surfaces[0] = (_skinSurface_t *)ri.Hunk_Alloc( sizeof( skinSurface_t ), h_low );
skin->surfaces[0] = (skinSurface_t *)ri.Hunk_Alloc( sizeof( skinSurface_t ), h_low );
skin->surfaces[0]->shader = tr.defaultShader;
}

Expand Down
8 changes: 7 additions & 1 deletion codemp/rd-vanilla/tr_local.h
Original file line number Diff line number Diff line change
Expand Up @@ -570,11 +570,17 @@ typedef struct trRefdef_s {
//=================================================================================

// skins allow models to be retextured without modifying the model file
typedef struct skinSurface_s {
typedef struct {
char name[MAX_QPATH];
shader_t *shader;
} skinSurface_t;

typedef struct skin_s {
char name[MAX_QPATH]; // game path, including extension
int numSurfaces;
skinSurface_t *surfaces[128];
} skin_t;

typedef struct fog_s {
int originalBrushNumber;
vec3_t bounds[2];
Expand Down
4 changes: 2 additions & 2 deletions codemp/rd-vanilla/tr_skin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ qhandle_t RE_RegisterIndividualSkin( const char *name , qhandle_t hSkin)
break;
}
surf = (skinSurface_t *) Hunk_Alloc( sizeof( *skin->surfaces[0] ), h_low );
skin->surfaces[skin->numSurfaces] = (_skinSurface_t *)surf;
skin->surfaces[skin->numSurfaces] = (skinSurface_t *)surf;

Q_strncpyz( surf->name, surfName, sizeof( surf->name ) );

Expand Down Expand Up @@ -393,7 +393,7 @@ void R_InitSkins( void ) {
skin = tr.skins[0] = (struct skin_s *)ri.Hunk_Alloc( sizeof( skin_t ), h_low );
Q_strncpyz( skin->name, "<default skin>", sizeof( skin->name ) );
skin->numSurfaces = 1;
skin->surfaces[0] = (_skinSurface_t *)ri.Hunk_Alloc( sizeof( skinSurface_t ), h_low );
skin->surfaces[0] = (skinSurface_t *)ri.Hunk_Alloc( sizeof( skinSurface_t ), h_low );
skin->surfaces[0]->shader = tr.defaultShader;
}

Expand Down
11 changes: 7 additions & 4 deletions codemp/rd-vulkan/tr_local.h
Original file line number Diff line number Diff line change
Expand Up @@ -717,7 +717,6 @@ typedef struct trRefdef_s {

int num_entities;
trRefEntity_t *entities;
trMiniRefEntity_t *miniEntities;

int num_dlights;
struct dlight_s *dlights;
Expand All @@ -741,11 +740,17 @@ typedef struct trRefdef_s {
//=================================================================================

// skins allow models to be retextured without modifying the model file
typedef struct skinSurface_s {
typedef struct {
char name[MAX_QPATH];
shader_t *shader;
} skinSurface_t;

typedef struct skin_s {
char name[MAX_QPATH]; // game path, including extension
int numSurfaces;
skinSurface_t *surfaces[128];
} skin_t;

typedef struct fog_s {
int originalBrushNumber;
vec3_t bounds[2];
Expand Down Expand Up @@ -2346,7 +2351,6 @@ typedef struct backEndData_s {
dlight_t dlights[MAX_DLIGHTS];
#endif
trRefEntity_t entities[MAX_REFENTITIES];
trMiniRefEntity_t miniEntities[MAX_MINI_ENTITIES];
srfPoly_t *polys;//[MAX_POLYS];
polyVert_t *polyVerts;//[MAX_POLYVERTS];
renderCommandList_t commands;
Expand All @@ -2358,7 +2362,6 @@ extern int max_polyverts;
extern backEndData_t *backEndData;

void *R_GetCommandBuffer( int bytes );
void RB_ExecuteRenderCommands( const void *data );

void R_AddDrawSurfCmd( drawSurf_t *drawSurfs, int numDrawSurfs );

Expand Down
56 changes: 3 additions & 53 deletions codemp/rd-vulkan/tr_scene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,6 @@ static int r_firstSceneDlight;
static int r_numentities;
static int r_firstSceneEntity;

static int r_numminientities;
static int r_firstSceneMiniEntity;

static int refEntParent = -1;

static int r_numpolys;
static int r_firstScenePoly;

Expand Down Expand Up @@ -71,9 +66,6 @@ void R_InitNextFrame( void ) {

r_numentities = 0;
r_firstSceneEntity = 0;
refEntParent = -1;
r_numminientities = 0;
r_firstSceneMiniEntity = 0;

r_numpolys = 0;
r_firstScenePoly = 0;
Expand All @@ -93,8 +85,6 @@ void RE_ClearScene( void ) {
r_firstSceneDlight = r_numdlights;
r_firstSceneEntity = r_numentities;
r_firstScenePoly = r_numpolys;
refEntParent = -1;
r_firstSceneMiniEntity = r_numminientities;
}

/*
Expand Down Expand Up @@ -246,6 +236,9 @@ void RE_AddRefEntityToScene( const refEntity_t *ent ) {
}
#endif

// not adding these flags yet
// if ( (int)ent->reType < 0 || ent->reType >= RT_MAX_SP_REF_ENTITY_TYPE || ent->reType == RT_MAX_MP_REF_ENTITY_TYPE ) {

if ( (int)ent->reType < 0 || ent->reType >= RT_MAX_REF_ENTITY_TYPE ) {
Com_Error( ERR_DROP, "RE_AddRefEntityToScene: bad reType %i", ent->reType );
}
Expand All @@ -263,19 +256,6 @@ void RE_AddRefEntityToScene( const refEntity_t *ent ) {
}
}

/*
if (ent->reType == RT_ENT_CHAIN)
{
refEntParent = r_numentities;
backEndData->entities[r_numentities].e.uRefEnt.uMini.miniStart = r_numminientities - r_firstSceneMiniEntity;
backEndData->entities[r_numentities].e.uRefEnt.uMini.miniCount = 0;
}
else
{
*/
refEntParent = -1;
//}

r_numentities++;
}

Expand Down Expand Up @@ -304,40 +284,14 @@ void RE_AddMiniRefEntityToScene( const miniRefEntity_t *ent )
}
if (!ent)
{
refEntParent = -1;
return;
}

#if 1 //i hate you minirefent!
refEntity_t tempEnt;

memcpy(&tempEnt, ent, sizeof(*ent));
memset(((char *)&tempEnt)+sizeof(*ent), 0, sizeof(tempEnt) - sizeof(*ent));
RE_AddRefEntityToScene(&tempEnt);
#else
if ( ent->reType < 0 || ent->reType >= RT_MAX_REF_ENTITY_TYPE )
{
Com_Error( ERR_DROP, "RE_AddMiniRefEntityToScene: bad reType %i", ent->reType );
}
if (!r_numentities || refEntParent == -1 || r_numminientities >= MAX_MINI_ENTITIES)
{ //rww - add it as a refent also if we run out of minis
// Com_Error( ERR_DROP, "RE_AddMiniRefEntityToScene: mini without parent ref ent");
refEntity_t tempEnt;
memcpy(&tempEnt, ent, sizeof(*ent));
memset(((char *)&tempEnt)+sizeof(*ent), 0, sizeof(tempEnt) - sizeof(*ent));
RE_AddRefEntityToScene(&tempEnt);
return;
}
parent = &backEndData->entities[refEntParent].e;
parent->uRefEnt.uMini.miniCount++;
backEndData->miniEntities[r_numminientities].e = *ent;
r_numminientities++;
#endif
}

/*
Expand Down Expand Up @@ -569,7 +523,6 @@ void RE_RenderScene( const refdef_t *fd ) {

tr.refdef.num_entities = r_numentities - r_firstSceneEntity;
tr.refdef.entities = &backEndData->entities[r_firstSceneEntity];
tr.refdef.miniEntities = &backEndData->miniEntities[r_firstSceneMiniEntity];

tr.refdef.num_dlights = r_numdlights - r_firstSceneDlight;
tr.refdef.dlights = &backEndData->dlights[r_firstSceneDlight];
Expand Down Expand Up @@ -671,12 +624,9 @@ void RE_RenderScene( const refdef_t *fd ) {
r_firstSceneLitSurf = tr.refdef.numLitSurfs;
#endif
r_firstSceneEntity = r_numentities;
r_firstSceneMiniEntity = r_numminientities;
r_firstSceneDlight = r_numdlights;
r_firstScenePoly = r_numpolys;

refEntParent = -1;

tr.frontEndMsec += ri.Milliseconds()*ri.Cvar_VariableValue( "timescale" ) - startTime;

RE_RenderWorldEffects();
Expand Down
4 changes: 2 additions & 2 deletions codemp/rd-vulkan/tr_skin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ qhandle_t RE_RegisterIndividualSkin( const char *name , qhandle_t hSkin)
break;
}
surf = (skinSurface_t *) Hunk_Alloc( sizeof( *skin->surfaces[0] ), h_low );
skin->surfaces[skin->numSurfaces] = (_skinSurface_t *)surf;
skin->surfaces[skin->numSurfaces] = (skinSurface_t *)surf;

Q_strncpyz( surf->name, surfName, sizeof( surf->name ) );

Expand Down Expand Up @@ -392,7 +392,7 @@ void R_InitSkins( void ) {
skin = tr.skins[0] = (struct skin_s *)ri.Hunk_Alloc( sizeof( skin_t ), h_low );
Q_strncpyz( skin->name, "<default skin>", sizeof( skin->name ) );
skin->numSurfaces = 1;
skin->surfaces[0] = (_skinSurface_t *)ri.Hunk_Alloc( sizeof( skinSurface_t ), h_low );
skin->surfaces[0] = (skinSurface_t *)ri.Hunk_Alloc( sizeof( skinSurface_t ), h_low );
skin->surfaces[0]->shader = tr.defaultShader;
}

Expand Down
2 changes: 1 addition & 1 deletion codemp/rd-vulkan/tr_surface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2092,7 +2092,7 @@ void RB_SurfaceEntity( const surfaceType_t *surfType ) {

for ( int i = 0, j = start; i < count; i++, j++ )
{
memcpy(&backEnd.currentEntity->e, &backEnd.refdef.miniEntities[j], sizeof(backEnd.refdef.miniEntities[j]));
backEnd.currentEntity->e = backEnd.refdef.entities[j].e;

assert(backEnd.currentEntity->e.renderfx >= 0);

Expand Down
2 changes: 0 additions & 2 deletions codemp/rd-vulkan/vk_shade_geometry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2259,8 +2259,6 @@ void RB_StageIteratorGeneric( void )
// use an excisting pipeline with the same def or create a new one.
def.face_culling = CT_TWO_SIDED;
tess.xstages[stage]->vk_2d_pipeline = vk_find_pipeline_ext(0, &def, qfalse);
}else{
Com_Printf("test me");
}

pipeline = pStage->vk_2d_pipeline;
Expand Down

0 comments on commit 65585d8

Please sign in to comment.