Skip to content

Commit

Permalink
Update renderers with latest changes
Browse files Browse the repository at this point in the history
  • Loading branch information
ensiform committed Nov 22, 2023
1 parent bb2baf1 commit 95b9803
Show file tree
Hide file tree
Showing 49 changed files with 1,770 additions and 718 deletions.
2 changes: 2 additions & 0 deletions src/renderer/tr_animation_mdm.c
Original file line number Diff line number Diff line change
Expand Up @@ -1423,7 +1423,9 @@ void RB_MDM_SurfaceAnim( mdmSurface_t *surface ) {
ldt = dt;
#endif

#ifdef USE_VBO
VBO_Flush();
#endif

refent = &backEnd.currentEntity->e;
boneList = ( int * )( (byte *)surface + surface->ofsBoneReferences );
Expand Down
2 changes: 2 additions & 0 deletions src/renderer/tr_animation_mds.c
Original file line number Diff line number Diff line change
Expand Up @@ -1239,7 +1239,9 @@ void RB_SurfaceAnim( mdsSurface_t *surface ) {
ldt = dt;
#endif

#ifdef USE_VBO
VBO_Flush();
#endif

refent = &backEnd.currentEntity->e;
boneList = ( int * )( (byte *)surface + surface->ofsBoneReferences );
Expand Down
18 changes: 16 additions & 2 deletions src/renderer/tr_arb.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,16 @@ typedef struct frameBuffer_s {
qboolean multiSampled;
} frameBuffer_t;

#ifdef USE_FBO
static GLuint commonDepthStencil;

static frameBuffer_t frameBufferMS;
static frameBuffer_t frameBuffers[ FBO_COUNT ];

static qboolean frameBufferMultiSampling = qfalse;

qboolean blitMSfbo = qfalse;
#endif

#ifndef GL_TEXTURE_IMAGE_FORMAT
#define GL_TEXTURE_IMAGE_FORMAT 0x828F
Expand Down Expand Up @@ -670,6 +673,7 @@ static const char *spriteFP = {
};


#ifdef USE_FBO
static char *ARB_BuildGreyscaleProgram( char *buf ) {
char *s;

Expand Down Expand Up @@ -991,6 +995,7 @@ static void ARB_BlurParams( int width, int height, int ksize, qboolean horizonta
qglProgramLocalParameter4fARB( GL_FRAGMENT_PROGRAM_ARB, i, 0.0, offset[i][1], 0.0, weight[i] );
}
}
#endif // USE_FBO


static void ARB_DeletePrograms( void )
Expand Down Expand Up @@ -1038,7 +1043,9 @@ qboolean ARB_UpdatePrograms( void )
const char *program;
int i;
#endif
#if defined (USE_FBO) || defined (USE_PMLIGHT)
char buf[4096];
#endif

if ( !qglGenProgramsARB )
return qfalse;
Expand Down Expand Up @@ -1073,6 +1080,7 @@ qboolean ARB_UpdatePrograms( void )
if ( !ARB_CompileProgram( Fragment, spriteFP, programs[ SPRITE_FRAGMENT ] ) )
return qfalse;

#ifdef USE_FBO
if ( !ARB_CompileProgram( Fragment, va( gammaFP, ARB_BuildGreyscaleProgram( buf ) ), programs[ GAMMA_FRAGMENT ] ) )
return qfalse;

Expand All @@ -1096,12 +1104,15 @@ qboolean ARB_UpdatePrograms( void )

if ( !ARB_CompileProgram( Fragment, va( blend2gammaFP, ARB_BuildGreyscaleProgram( buf ) ), programs[ BLEND2_GAMMA_FRAGMENT ] ) )
return qfalse;
#endif // USE_FBO

programCompiled = 1;

return qtrue;
}

#ifdef USE_FBO

static void FBO_Bind( GLuint target, GLuint buffer );

void FBO_Clean( frameBuffer_t *fb )
Expand Down Expand Up @@ -2066,7 +2077,6 @@ void FBO_PostProcess( void )
}



void QGL_SetRenderScale( qboolean verbose )
{
windowAdjusted = qfalse;
Expand Down Expand Up @@ -2229,21 +2239,25 @@ void QGL_InitFBO( void )
QGL_DoneFBO();
}
}
#endif // USE_FBO


void QGL_InitARB( void )
{
ARB_UpdatePrograms();
#ifdef USE_FBO
QGL_SetRenderScale( qtrue );
QGL_InitFBO();
#endif
ri.Cvar_ResetGroup( CVG_RENDERER, qtrue );
}


void QGL_DoneARB( void )
{
#ifdef USE_FBO
QGL_DoneFBO();

#endif
if ( programCompiled )
{
ARB_ProgramDisable();
Expand Down
52 changes: 49 additions & 3 deletions src/renderer/tr_backend.c
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,9 @@ static void RB_Hyperspace( void ) {
RB_BeginSurface( tr.whiteShader, 0 );
}

#ifdef USE_VBO
VBO_UnBind();
#endif

RB_SetGL2D();

Expand Down Expand Up @@ -658,7 +660,9 @@ static void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) {
int i;
drawSurf_t *drawSurf;
unsigned int oldSort;
#ifdef USE_PMLIGHT
float oldShaderSort;
#endif
double originalTime; // -EC-

// save original time for entity shader offsets
Expand All @@ -671,7 +675,9 @@ static void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) {
oldDepthRange = qfalse;
wasCrosshair = qfalse;
oldSort = MAX_UINT;
#ifdef USE_PMLIGHT
oldShaderSort = -1;
#endif
depthRange = qfalse;

backEnd.pc.c_surfaces += numDrawSurfs;
Expand Down Expand Up @@ -1188,14 +1194,18 @@ static const void *RB_StretchPic( const void *data ) {
RB_BeginSurface( shader, 0 );
}

#ifdef USE_VBO
VBO_UnBind();
#endif

if ( !backEnd.projection2D ) {
RB_SetGL2D();
}

#ifdef USE_FBO
//Check if it's time for BLOOM!
R_BloomScreen();
#endif

RB_AddQuadStamp2( cmd->x, cmd->y, cmd->w, cmd->h, cmd->s1, cmd->t1, cmd->s2, cmd->t2, backEnd.color2D );

Expand All @@ -1209,10 +1219,13 @@ static void RB_LightingPass( void )
dlight_t *dl;
int i;

#ifdef USE_VBO
VBO_Flush();

tess.dlightPass = qtrue;
tess.allowVBO = qfalse; // for now
#endif

tess.dlightPass = qtrue;

for ( i = 0; i < backEnd.viewParms.num_dlights; i++ )
{
Expand Down Expand Up @@ -1248,14 +1261,18 @@ static const void* RB_Draw2dPolys( const void* data ) {
RB_BeginSurface( shader, 0 );
}

#ifdef USE_VBO
VBO_UnBind();
#endif

if ( !backEnd.projection2D ) {
RB_SetGL2D();
}

#ifdef USE_FBO
//Check if it's time for BLOOM!
R_BloomScreen();
#endif

RB_CHECKOVERFLOW( cmd->numverts, ( cmd->numverts - 2 ) * 3 );

Expand Down Expand Up @@ -1308,14 +1325,18 @@ static const void *RB_RotatedPic( const void *data ) {
RB_BeginSurface( shader, 0 );
}

#ifdef USE_VBO
VBO_UnBind();
#endif

if ( !backEnd.projection2D ) {
RB_SetGL2D();
}

#ifdef USE_FBO
//Check if it's time for BLOOM!
R_BloomScreen();
#endif

RB_CHECKOVERFLOW( 4, 6 );
numVerts = tess.numVertexes;
Expand Down Expand Up @@ -1393,14 +1414,18 @@ static const void *RB_StretchPicGradient( const void *data ) {
RB_BeginSurface( shader, 0 );
}

#ifdef USE_VBO
VBO_UnBind();
#endif

if ( !backEnd.projection2D ) {
RB_SetGL2D();
}

#ifdef USE_FBO
//Check if it's time for BLOOM!
R_BloomScreen();
#endif

RB_CHECKOVERFLOW( 4, 6 );
numVerts = tess.numVertexes;
Expand Down Expand Up @@ -1586,14 +1611,18 @@ static const void *RB_DrawSurfs( const void *data ) {
backEnd.refdef = cmd->refdef;
backEnd.viewParms = cmd->viewParms;

#ifdef USE_VBO
VBO_UnBind();
#endif

// clear the z buffer, set the modelview, etc
RB_BeginDrawingView();

RB_RenderDrawSurfList( cmd->drawSurfs, cmd->numDrawSurfs );

#ifdef USE_VBO
VBO_UnBind();
#endif

RB_DrawSun();

Expand All @@ -1610,11 +1639,13 @@ static const void *RB_DrawSurfs( const void *data ) {
}
#endif

#ifdef USE_FBO
if ( !backEnd.doneSurfaces && tr.needScreenMap ) {
if ( backEnd.viewParms.frameSceneNum == 1 ) {
FBO_CopyScreen();
}
}
#endif

// draw main system development information (surface outlines, etc)
R_FogOff();
Expand All @@ -1640,12 +1671,16 @@ static const void *RB_DrawBuffer( const void *data ) {

cmd = (const drawBufferCommand_t *)data;

#ifdef USE_FBO
if ( fboEnabled ) {
FBO_BindMain();
qglDrawBuffer( GL_COLOR_ATTACHMENT0 );
} else {
qglDrawBuffer( cmd->buffer );
}
#else
qglDrawBuffer( cmd->buffer );
#endif

// clear screen for debugging
if ( r_clear->integer ) {
Expand Down Expand Up @@ -1793,6 +1828,7 @@ static const void *RB_ClearColor( const void *data )
RB_FinishBloom
=============
*/
#ifdef USE_FBO
static const void *RB_FinishBloom( const void *data )
{
const finishBloomCommand_t *cmd = data;
Expand Down Expand Up @@ -1830,6 +1866,7 @@ static const void *RB_FinishBloom( const void *data )

return (const void *)(cmd + 1);
}
#endif // USE_FBO


static const void *RB_SwapBuffers( const void *data ) {
Expand All @@ -1838,7 +1875,10 @@ static const void *RB_SwapBuffers( const void *data ) {

// finish any 2D drawing if needed
RB_EndSurface();

#ifdef USE_VBO
VBO_UnBind();
#endif

// texture swapping test
if ( r_showImages->integer && !backEnd.drawConsole ) {
Expand All @@ -1851,21 +1891,23 @@ static const void *RB_SwapBuffers( const void *data ) {
qglFinish();
}

#ifdef USE_FBO
if ( fboEnabled ) {
FBO_PostProcess();
}
#endif

// buffer swap may take undefined time to complete, we can't measure it in a reliable way
backEnd.pc.msec = ri.Milliseconds() - backEnd.pc.msec;

if ( backEnd.screenshotMask && tr.frameCount > 1 ) {

#ifdef USE_FBO
if ( superSampled ) {
qglScissor( 0, 0, gls.captureWidth, gls.captureHeight );
qglViewport( 0, 0, gls.captureWidth, gls.captureHeight );
FBO_BlitSS();
}

#endif
if ( backEnd.screenshotMask & SCREENSHOT_TGA && backEnd.screenshotTGA[0] ) {
RB_TakeScreenshot( 0, 0, gls.captureWidth, gls.captureHeight, backEnd.screenshotTGA );
if ( !backEnd.screenShotTGAsilent ) {
Expand Down Expand Up @@ -1896,7 +1938,9 @@ static const void *RB_SwapBuffers( const void *data ) {

ri.GLimp_EndFrame();

#ifdef USE_FBO
FBO_BindMain();
#endif

backEnd.projection2D = qfalse;
backEnd.doneBloom = qfalse;
Expand Down Expand Up @@ -2044,9 +2088,11 @@ void RB_ExecuteRenderCommands( const void *data ) {
case RC_SWAP_BUFFERS:
data = RB_SwapBuffers( data );
break;
#ifdef USE_FBO
case RC_FINISHBLOOM:
data = RB_FinishBloom(data);
break;
#endif
case RC_COLORMASK:
data = RB_ColorMask(data);
break;
Expand Down
4 changes: 3 additions & 1 deletion src/renderer/tr_bsp.c
Original file line number Diff line number Diff line change
Expand Up @@ -2307,7 +2307,7 @@ void RE_LoadWorldMap( const char *name ) {
tr.sunDirection[1] = 0.3f;
tr.sunDirection[2] = 0.9f;

tr.sunShader = 0; // clear sunshader so it's not there if the level doesn't specify it
tr.sunShader = NULL; // clear sunshader so it's not there if the level doesn't specify it

// invalidate fogs (likely to be re-initialized to new values by the current map)
// TODO:(SA)this is sort of silly. I'm going to do a general cleanup on fog stuff
Expand Down Expand Up @@ -2405,7 +2405,9 @@ void RE_LoadWorldMap( const char *name ) {
R_LoadLightGrid( &header->lumps[LUMP_LIGHTGRID] );
ri.SCR_UpdateScreen();

#ifdef USE_VBO
R_BuildWorldVBO( s_worldData.surfaces, s_worldData.numsurfaces );
#endif

tr.mapLoading = qfalse;

Expand Down
Loading

0 comments on commit 95b9803

Please sign in to comment.