Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion source/ref_nri/r_alias.c
Original file line number Diff line number Diff line change
Expand Up @@ -787,7 +787,7 @@ bool R_AddAliasModelToDrawList( const entity_t *e )
if( e->renderfx & RF_WEAPONMODEL ) {
return true;
}
if( rsc.entShadowGroups[R_ENT2NUM(e)] != rn.shadowGroup->id ) {
if( rsc.entShadowGroups[e - rsc.entities] != rn.shadowGroup->id ) {
return true;
}
}
Expand Down
8 changes: 4 additions & 4 deletions source/ref_nri/r_frontend.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

static ref_frontend_t rrf;

static void __ShutdownSwapchainTexture();
static void __DisposeSwapchainTexture();

static void __R_InitVolatileAssets( void )
{
Expand Down Expand Up @@ -60,7 +60,7 @@ static void __R_InitVolatileAssets( void )
}
}

static void __ShutdownSwapchainTexture() {
static void __DisposeSwapchainTexture() {
if(rsh.swapchain) {
for( size_t i = 0; i < arrlen( rsh.backBuffers ); i++ ) {
struct frame_tex_buffers_s *backBuffer = &rsh.backBuffers[i];
Expand Down Expand Up @@ -235,7 +235,7 @@ rserr_t RF_SetMode( int x, int y, int width, int height, int displayFrequency, b
}

NriSwapChainDesc swapChainDesc = { .commandQueue = rsh.nri.graphicsCommandQueue, .width = width, .height = height, .format = DefaultSwapchainFormat, .textureNum = 3, .window = nriWindow };
__ShutdownSwapchainTexture();
__DisposeSwapchainTexture();

assert(rsh.frameFence == NULL);
NRI_ABORT_ON_FAILURE( rsh.nri.coreI.CreateFence( rsh.nri.device, 0, &rsh.frameFence ) );
Expand Down Expand Up @@ -385,7 +385,7 @@ void RF_Shutdown( bool verbose )
FrameCmdBufferFree(&rsh.frameCmds[i]);
}

__ShutdownSwapchainTexture();
__DisposeSwapchainTexture();

ri.Mutex_Destroy( &rf.speedsMsgLock );
ri.Mutex_Destroy( &rf.debugSurfaceLock );
Expand Down
3 changes: 0 additions & 3 deletions source/ref_nri/r_local.h
Original file line number Diff line number Diff line change
Expand Up @@ -418,9 +418,6 @@ extern r_shared_t rsh;
extern r_scene_t rsc;
extern r_globals_t rf;

#define R_ENT2NUM(ent) ((ent)-rsc.entities)
#define R_NUM2ENT(num) (rsc.entities+(num))

extern cvar_t *vid_width;
extern cvar_t *vid_height;
extern cvar_t *vid_xpos; // X coordinate of window position
Expand Down
8 changes: 4 additions & 4 deletions source/ref_nri/r_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1084,15 +1084,15 @@ static void R_EndGL( struct frame_cmd_buffer_s* frame )
static void R_DrawEntities( void )
{
unsigned int i;
entity_t *e;
;
bool shadowmap = ( ( rn.renderFlags & RF_SHADOWMAPVIEW ) != 0 );
bool culled = true;

if( rn.renderFlags & RF_ENVVIEW )
{
for( i = 0; i < rsc.numBmodelEntities; i++ )
{
e = rsc.bmodelEntities[i];
entity_t *e = rsc.bmodelEntities[i];
if( !r_lerpmodels->integer )
e->backlerp = 0;
e->outlineHeight = rsc.worldent->outlineHeight;
Expand All @@ -1104,7 +1104,7 @@ static void R_DrawEntities( void )

for( i = rsc.numLocalEntities; i < rsc.numEntities; i++ )
{
e = R_NUM2ENT(i);
entity_t *e = &rsc.entities[i];
culled = true;

if( !r_lerpmodels->integer )
Expand Down Expand Up @@ -1487,7 +1487,7 @@ void R_RenderDebugSurface( const refdef_t *fd )

R_ClearDrawList( rn.portalmasklist );

if( R_AddSurfToDrawList( rn.meshlist, R_NUM2ENT(tr.ent), NULL, surf->shader, 0, 0, NULL, surf->drawSurf ) ) {
if( R_AddSurfToDrawList( rn.meshlist, &rsc.entities[tr.ent], NULL, surf->shader, 0, 0, NULL, surf->drawSurf ) ) {
if( rn.refdef.rdflags & RDF_FLIPPED ) {
RB_FlipFrontFace(NULL);
}
Expand Down
4 changes: 2 additions & 2 deletions source/ref_nri/r_mesh.c
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ void *R_AddSurfToDrawList( drawList_t *list, const entity_t *e, const mfog_t *fo
sds = &list->drawSurfs[list->numDrawSurfs++];
sds->distKey = R_PackDistKey( shaderSort, (int)dist, order );
sds->sortKey = R_PackSortKey( shader->id, fog ? fog - rsh.worldBrushModel->fogs : -1,
portalSurf ? portalSurf - rn.portalSurfaces : -1, R_ENT2NUM(e) );
portalSurf ? portalSurf - rn.portalSurfaces : -1, (e - rsc.entities) );
sds->drawSurf = ( drawSurfaceType_t * )drawSurf;

return sds;
Expand Down Expand Up @@ -446,7 +446,7 @@ static void _R_DrawSurfaces(struct frame_cmd_buffer_s* frame, drawList_t *list )
R_UnpackSortKey( sortKey, &shaderNum, &fogNum, &portalNum, &entNum );

shader = R_ShaderById( shaderNum );
entity = R_NUM2ENT(entNum);
entity = &rsc.entities[entNum];
fog = fogNum >= 0 ? rsh.worldBrushModel->fogs + fogNum : NULL;
portalSurface = portalNum >= 0 ? rn.portalSurfaces + portalNum : NULL;
entityFX = entity->renderfx;
Expand Down
2 changes: 1 addition & 1 deletion source/ref_nri/r_portals.c
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ static void R_DrawPortalSurface( struct frame_cmd_buffer_s *cmd, portalSurface_t
best_d = 100000000;
for( i = rsc.numLocalEntities; i < rsc.numEntities; i++ )
{
ent = R_NUM2ENT(i);
ent = &rsc.entities[i];
if( ent->rtype != RT_PORTALSURFACE )
continue;

Expand Down
8 changes: 4 additions & 4 deletions source/ref_nri/r_scene.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,21 @@ void R_ClearScene( void )
rsc.numDlights = 0;
rsc.numPolys = 0;

rsc.worldent = R_NUM2ENT( rsc.numLocalEntities );
rsc.worldent = &rsc.entities[rsc.numLocalEntities];
rsc.worldent->scale = 1.0f;
rsc.worldent->model = rsh.worldModel;
rsc.worldent->rtype = RT_MODEL;
Matrix3_Identity( rsc.worldent->axis );
rsc.numLocalEntities++;

rsc.polyent = R_NUM2ENT( rsc.numLocalEntities );
rsc.polyent = &rsc.entities[rsc.numLocalEntities];
rsc.polyent->scale = 1.0f;
rsc.polyent->model = NULL;
rsc.polyent->rtype = RT_MODEL;
Matrix3_Identity( rsc.polyent->axis );
rsc.numLocalEntities++;

rsc.skyent = R_NUM2ENT( rsc.numLocalEntities );
rsc.skyent = &rsc.entities[rsc.numLocalEntities];
*rsc.skyent = *rsc.worldent;
rsc.numLocalEntities++;

Expand Down Expand Up @@ -77,7 +77,7 @@ void R_AddEntityToScene( const entity_t *ent )
if( ( ( rsc.numEntities - rsc.numLocalEntities ) < MAX_ENTITIES ) && ent )
{
int eNum = rsc.numEntities;
entity_t *de = R_NUM2ENT(eNum);
entity_t *de = &rsc.entities[eNum];

*de = *ent;
if( r_outlines_scale->value <= 0 )
Expand Down
3 changes: 2 additions & 1 deletion source/ref_nri/r_shadow.c
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,8 @@ bool R_AddLightOccluder( const entity_t *ent )
return false;
}

rsc.entShadowGroups[R_ENT2NUM(ent)] = group->id;

rsc.entShadowGroups[ent - rsc.entities] = group->id;
if( ent->flags & RF_WEAPONMODEL )
return true;

Expand Down
7 changes: 3 additions & 4 deletions source/ref_nri/r_skm.c
Original file line number Diff line number Diff line change
Expand Up @@ -1246,7 +1246,7 @@ void R_DrawSkeletalSurf(struct frame_cmd_buffer_s* cmd, const entity_t *e, const
bonePoseRelativeDQSize = sizeof( dualquat_t ) * skmodel->numbones;

// fetch bones tranforms from cache (both matrices and dual quaternions)
bonePoseRelativeDQ = ( dualquat_t * )R_GetSkeletalCache( R_ENT2NUM( e ), mod->lodnum );
bonePoseRelativeDQ = ( dualquat_t * )R_GetSkeletalCache( e - rsc.entities, mod->lodnum );
if( bonePoseRelativeDQ ) {
bonePoseRelativeMat = ( mat4_t * )(( uint8_t * )bonePoseRelativeDQ + bonePoseRelativeDQSize);
}
Expand Down Expand Up @@ -1310,8 +1310,7 @@ void R_DrawSkeletalSurf(struct frame_cmd_buffer_s* cmd, const entity_t *e, const
}
}

bonePoseRelativeDQ = ( dualquat_t * )R_AllocSkeletalDataCache( R_ENT2NUM( e ), mod->lodnum,
bonePoseRelativeDQSize + bonePoseRelativeMatSize );
bonePoseRelativeDQ = (dualquat_t *)R_AllocSkeletalDataCache( e - rsc.entities, mod->lodnum, bonePoseRelativeDQSize + bonePoseRelativeMatSize );

// generate dual quaternions for all bones
for( i = 0; i < skmodel->numbones; i++ ) {
Expand Down Expand Up @@ -1460,7 +1459,7 @@ bool R_AddSkeletalModelToDrawList( const entity_t *e )
if( e->renderfx & RF_WEAPONMODEL ) {
return true;
}
if( rsc.entShadowGroups[R_ENT2NUM(e)] != rn.shadowGroup->id ) {
if( rsc.entShadowGroups[(e - rsc.entities)] != rn.shadowGroup->id ) {
return true;
}
}
Expand Down
2 changes: 1 addition & 1 deletion source/ref_nri/r_surf.c
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ bool R_AddBrushModelToDrawList( const entity_t *e )

// never render weapon models or non-occluders into shadowmaps
if( rn.renderFlags & RF_SHADOWMAPVIEW ) {
if( rsc.entShadowGroups[R_ENT2NUM(e)] != rn.shadowGroup->id ) {
if( rsc.entShadowGroups[e - rsc.entities] != rn.shadowGroup->id ) {
return true;
}
}
Expand Down
2 changes: 1 addition & 1 deletion source/ref_nri/r_trace.c
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ static msurface_t *R_TransformedTraceLine( rtrace_t *tr, const vec3_t start, con
tr->shader = trace_surface->shader;
tr->plane = trace_plane;
tr->surfFlags = trace_surface->flags;
tr->ent = R_ENT2NUM(test);
tr->ent = (test - rsc.entities);
}

tr->fraction = trace_fraction;
Expand Down