From 7b1fa0e3cc8c106a08ab8d7e12a0c40d2e2a7791 Mon Sep 17 00:00:00 2001 From: Zack Middleton Date: Fri, 12 Jun 2015 14:22:37 -0500 Subject: Move image load function prototypes to tr_common.h The functions themselves are in code/renderercommon/tr_image_*.c --- src/renderergl1/tr_local.h | 14 -------------- 1 file changed, 14 deletions(-) (limited to 'src/renderergl1') diff --git a/src/renderergl1/tr_local.h b/src/renderergl1/tr_local.h index 6264af82..0d8131ec 100644 --- a/src/renderergl1/tr_local.h +++ b/src/renderergl1/tr_local.h @@ -1404,20 +1404,6 @@ int R_IQMLerpTag( orientation_t *tag, iqmData_t *data, int startFrame, int endFrame, float frac, const char *tagName ); -/* -============================================================= - -IMAGE LOADERS - -============================================================= -*/ - -void R_LoadBMP( const char *name, byte **pic, int *width, int *height ); -void R_LoadJPG( const char *name, byte **pic, int *width, int *height ); -void R_LoadPCX( const char *name, byte **pic, int *width, int *height ); -void R_LoadPNG( const char *name, byte **pic, int *width, int *height ); -void R_LoadTGA( const char *name, byte **pic, int *width, int *height ); - /* ============================================================= ============================================================= -- cgit From 00a83e798f7934962facba8e7864b215e1d94701 Mon Sep 17 00:00:00 2001 From: Zack Middleton Date: Sat, 4 Jul 2015 19:17:58 -0500 Subject: Apply greyscaling to fog blocks --- src/renderergl1/tr_shader.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/renderergl1') diff --git a/src/renderergl1/tr_shader.c b/src/renderergl1/tr_shader.c index 2a66afd0..34d6d64e 100644 --- a/src/renderergl1/tr_shader.c +++ b/src/renderergl1/tr_shader.c @@ -1569,6 +1569,23 @@ static qboolean ParseShader( char **text ) return qfalse; } + if ( r_greyscale->integer ) + { + float luminance; + + luminance = LUMA( shader.fogParms.color[0], shader.fogParms.color[1], shader.fogParms.color[2] ); + VectorSet( shader.fogParms.color, luminance, luminance, luminance ); + } + else if ( r_greyscale->value ) + { + float luminance; + + luminance = LUMA( shader.fogParms.color[0], shader.fogParms.color[1], shader.fogParms.color[2] ); + shader.fogParms.color[0] = LERP( shader.fogParms.color[0], luminance, r_greyscale->value ); + shader.fogParms.color[1] = LERP( shader.fogParms.color[1], luminance, r_greyscale->value ); + shader.fogParms.color[2] = LERP( shader.fogParms.color[2], luminance, r_greyscale->value ); + } + token = COM_ParseExt( text, qfalse ); if ( !token[0] ) { -- cgit From a1cb4046bef1a81e8d19a1b2556c285da5cf3229 Mon Sep 17 00:00:00 2001 From: Zack Middleton Date: Sat, 4 Jul 2015 19:33:28 -0500 Subject: Don't fog 3D crosshair sprite --- src/renderergl1/tr_main.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/renderergl1') diff --git a/src/renderergl1/tr_main.c b/src/renderergl1/tr_main.c index 500bb788..b216d38f 100644 --- a/src/renderergl1/tr_main.c +++ b/src/renderergl1/tr_main.c @@ -1012,6 +1012,10 @@ int R_SpriteFogNum( trRefEntity_t *ent ) { return 0; } + if ( ent->e.renderfx & RF_CROSSHAIR ) { + return 0; + } + for ( i = 1 ; i < tr.world->numfogs ; i++ ) { fog = &tr.world->fogs[i]; for ( j = 0 ; j < 3 ; j++ ) { -- cgit From 17abbc7123b1f79467d18c64b67235ce41c115c4 Mon Sep 17 00:00:00 2001 From: Zack Middleton Date: Thu, 9 Jul 2015 22:28:08 -0500 Subject: Fix OpenGL2 ignoring last light grid point on each axis Also change light grid bounds clamping to make it more clear what invalid values are. --- src/renderergl1/tr_light.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/renderergl1') diff --git a/src/renderergl1/tr_light.c b/src/renderergl1/tr_light.c index 779451f1..bd79df55 100644 --- a/src/renderergl1/tr_light.c +++ b/src/renderergl1/tr_light.c @@ -152,7 +152,7 @@ static void R_SetupEntityLightingGrid( trRefEntity_t *ent ) { frac[i] = v - pos[i]; if ( pos[i] < 0 ) { pos[i] = 0; - } else if ( pos[i] >= tr.world->lightGridBounds[i] - 1 ) { + } else if ( pos[i] > tr.world->lightGridBounds[i] - 1 ) { pos[i] = tr.world->lightGridBounds[i] - 1; } } -- cgit From 3021d2b30e8d2b8456484cc9cd8adc30bda0a98e Mon Sep 17 00:00:00 2001 From: Zack Middleton Date: Sun, 12 Jul 2015 17:53:17 -0500 Subject: Backport ignoring values outside lightgrid to OpenGL1 Fixes possibly of reading memory past end of lightGridData or reading wrong light grid data (wrapping around to next row). --- src/renderergl1/tr_light.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/renderergl1') diff --git a/src/renderergl1/tr_light.c b/src/renderergl1/tr_light.c index bd79df55..35233739 100644 --- a/src/renderergl1/tr_light.c +++ b/src/renderergl1/tr_light.c @@ -183,6 +183,9 @@ static void R_SetupEntityLightingGrid( trRefEntity_t *ent ) { data = gridData; for ( j = 0 ; j < 3 ; j++ ) { if ( i & (1< tr.world->lightGridBounds[j] - 1 ) { + break; // ignore values outside lightgrid + } factor *= frac[j]; data += gridStep[j]; } else { @@ -190,6 +193,9 @@ static void R_SetupEntityLightingGrid( trRefEntity_t *ent ) { } } + if ( j != 3 ) { + continue; + } if ( !(data[0]+data[1]+data[2]) ) { continue; // ignore samples in walls } -- cgit From 7ebcf42f808b8c1a209cabdaa6f879b8e1790036 Mon Sep 17 00:00:00 2001 From: Zack Middleton Date: Sun, 12 Jul 2015 20:41:41 -0500 Subject: Fix alloc size for default skin and single shader skin Found by Coverity. --- src/renderergl1/tr_image.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/renderergl1') diff --git a/src/renderergl1/tr_image.c b/src/renderergl1/tr_image.c index 6f58a5b2..e3a1f2eb 100644 --- a/src/renderergl1/tr_image.c +++ b/src/renderergl1/tr_image.c @@ -1556,7 +1556,7 @@ qhandle_t RE_RegisterSkin( const char *name ) { // If not a .skin file, load as a single shader if ( strcmp( name + strlen( name ) - 5, ".skin" ) ) { skin->numSurfaces = 1; - skin->surfaces[0] = ri.Hunk_Alloc( sizeof(skin->surfaces[0]), h_low ); + skin->surfaces[0] = ri.Hunk_Alloc( sizeof( *skin->surfaces[0] ), h_low ); skin->surfaces[0]->shader = R_FindShader( name, LIGHTMAP_NONE, qtrue ); return hSkin; } @@ -1627,7 +1627,7 @@ void R_InitSkins( void ) { skin = tr.skins[0] = ri.Hunk_Alloc( sizeof( skin_t ), h_low ); Q_strncpyz( skin->name, "", sizeof( skin->name ) ); skin->numSurfaces = 1; - skin->surfaces[0] = ri.Hunk_Alloc( sizeof( *skin->surfaces ), h_low ); + skin->surfaces[0] = ri.Hunk_Alloc( sizeof( *skin->surfaces[0] ), h_low ); skin->surfaces[0]->shader = tr.defaultShader; } -- cgit From 0bb0fb2bac331ce4d4a9756b7f62969a6278ee5b Mon Sep 17 00:00:00 2001 From: Zack Middleton Date: Mon, 28 Sep 2015 01:12:17 -0500 Subject: Remove unused define MAC_EVENT_PUMP_MSEC --- src/renderergl1/tr_backend.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'src/renderergl1') diff --git a/src/renderergl1/tr_backend.c b/src/renderergl1/tr_backend.c index 18a033b6..7cd455e8 100644 --- a/src/renderergl1/tr_backend.c +++ b/src/renderergl1/tr_backend.c @@ -496,8 +496,6 @@ void RB_BeginDrawingView (void) { } -#define MAC_EVENT_PUMP_MSEC 5 - /* ================== RB_RenderDrawSurfList -- cgit From 2680cae42a9009628ded887d9470ed8abf45fc0f Mon Sep 17 00:00:00 2001 From: Zack Middleton Date: Fri, 16 Oct 2015 03:16:26 -0500 Subject: Add support for uncompressed image upload flag to OpenGL1 --- src/renderergl1/tr_image.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/renderergl1') diff --git a/src/renderergl1/tr_image.c b/src/renderergl1/tr_image.c index e3a1f2eb..2ed43ef0 100644 --- a/src/renderergl1/tr_image.c +++ b/src/renderergl1/tr_image.c @@ -558,6 +558,7 @@ static void Upload32( unsigned *data, qboolean mipmap, qboolean picmip, qboolean lightMap, + qboolean allowCompression, int *format, int *pUploadWidth, int *pUploadHeight ) { @@ -693,11 +694,11 @@ static void Upload32( unsigned *data, } else { - if ( glConfig.textureCompression == TC_S3TC_ARB ) + if ( allowCompression && glConfig.textureCompression == TC_S3TC_ARB ) { internalFormat = GL_COMPRESSED_RGBA_S3TC_DXT1_EXT; } - else if ( glConfig.textureCompression == TC_S3TC ) + else if ( allowCompression && glConfig.textureCompression == TC_S3TC ) { internalFormat = GL_RGB4_S3TC; } @@ -893,6 +894,7 @@ image_t *R_CreateImage( const char *name, byte *pic, int width, int height, image->flags & IMGFLAG_MIPMAP, image->flags & IMGFLAG_PICMIP, isLightmap, + !(image->flags & IMGFLAG_NO_COMPRESSION), &image->internalFormat, &image->uploadWidth, &image->uploadHeight ); -- cgit From 27b955ed8aae71e0a4a15d75e1c06ffa6516fbe5 Mon Sep 17 00:00:00 2001 From: Zack Middleton Date: Fri, 16 Oct 2015 19:18:38 -0500 Subject: Fix not swapping buffers because out of cmd buffer space Reserve space for end of list and swap buffer commands. These are absolutely required and cannot be dropped. Dropping swap buffer command causes screen to not update and possible crash from drawsurf buffer overflow if not enough cmd buffer space for many continous frames. --- src/renderergl1/tr_cmds.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'src/renderergl1') diff --git a/src/renderergl1/tr_cmds.c b/src/renderergl1/tr_cmds.c index 23aa9897..0ff7faee 100644 --- a/src/renderergl1/tr_cmds.c +++ b/src/renderergl1/tr_cmds.c @@ -115,19 +115,19 @@ void R_IssuePendingRenderCommands( void ) { /* ============ -R_GetCommandBuffer +R_GetCommandBufferReserved make sure there is enough command space ============ */ -void *R_GetCommandBuffer( int bytes ) { +void *R_GetCommandBufferReserved( int bytes, int reservedBytes ) { renderCommandList_t *cmdList; cmdList = &backEndData->commands; bytes = PAD(bytes, sizeof(void *)); // always leave room for the end of list command - if ( cmdList->used + bytes + 4 > MAX_RENDER_COMMANDS ) { + if ( cmdList->used + bytes + 4 + reservedBytes > MAX_RENDER_COMMANDS ) { if ( bytes > MAX_RENDER_COMMANDS - 4 ) { ri.Error( ERR_FATAL, "R_GetCommandBuffer: bad size %i", bytes ); } @@ -140,6 +140,17 @@ void *R_GetCommandBuffer( int bytes ) { return cmdList->cmds + cmdList->used - bytes; } +/* +============= +R_GetCommandBuffer + +returns NULL if there is not enough space for important commands +============= +*/ +void *R_GetCommandBuffer( int bytes ) { + return R_GetCommandBufferReserved( bytes, sizeof ( swapBuffersCommand_t ) ); +} + /* ============= @@ -540,7 +551,7 @@ void RE_EndFrame( int *frontEndMsec, int *backEndMsec ) { if ( !tr.registered ) { return; } - cmd = R_GetCommandBuffer( sizeof( *cmd ) ); + cmd = R_GetCommandBufferReserved( sizeof( *cmd ), 0 ); if ( !cmd ) { return; } -- cgit From 0972dc8edfdadae375ab0a517e324178f8ec99f0 Mon Sep 17 00:00:00 2001 From: Zack Middleton Date: Fri, 16 Oct 2015 20:12:51 -0500 Subject: Fix crash from reading past end of tr.refdef.drawSurfs The number of draw surfaces was range checked against number of surfaces for the current view but needs to check total for the frame otherwise can read past the end of the tr.refdef.drawSurfs array when there are multiple views. --- src/renderergl1/tr_main.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'src/renderergl1') diff --git a/src/renderergl1/tr_main.c b/src/renderergl1/tr_main.c index b216d38f..7df28230 100644 --- a/src/renderergl1/tr_main.c +++ b/src/renderergl1/tr_main.c @@ -1147,13 +1147,6 @@ void R_SortDrawSurfs( drawSurf_t *drawSurfs, int numDrawSurfs ) { return; } - // if we overflowed MAX_DRAWSURFS, the drawsurfs - // wrapped around in the buffer and we will be missing - // the first surfaces, not the last ones - if ( numDrawSurfs > MAX_DRAWSURFS ) { - numDrawSurfs = MAX_DRAWSURFS; - } - // sort the drawsurfs by sort type, then orientation, then shader R_RadixSort( drawSurfs, numDrawSurfs ); @@ -1362,6 +1355,7 @@ or a mirror / remote location */ void R_RenderView (viewParms_t *parms) { int firstDrawSurf; + int numDrawSurfs; if ( parms->viewportWidth <= 0 || parms->viewportHeight <= 0 ) { return; @@ -1384,7 +1378,15 @@ void R_RenderView (viewParms_t *parms) { R_GenerateDrawSurfs(); - R_SortDrawSurfs( tr.refdef.drawSurfs + firstDrawSurf, tr.refdef.numDrawSurfs - firstDrawSurf ); + // if we overflowed MAX_DRAWSURFS, the drawsurfs + // wrapped around in the buffer and we will be missing + // the first surfaces, not the last ones + numDrawSurfs = tr.refdef.numDrawSurfs; + if ( numDrawSurfs > MAX_DRAWSURFS ) { + numDrawSurfs = MAX_DRAWSURFS; + } + + R_SortDrawSurfs( tr.refdef.drawSurfs + firstDrawSurf, numDrawSurfs - firstDrawSurf ); // draw main system development information (surface outlines, etc) R_DebugGraphics(); -- cgit From 6c232efd91fd288342bc6865a36fa1c8c0a23575 Mon Sep 17 00:00:00 2001 From: Zack Middleton Date: Fri, 16 Oct 2015 20:50:25 -0500 Subject: Fix reserved size for swap buffer command being too small on x86_64 --- src/renderergl1/tr_cmds.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/renderergl1') diff --git a/src/renderergl1/tr_cmds.c b/src/renderergl1/tr_cmds.c index 0ff7faee..58f199e3 100644 --- a/src/renderergl1/tr_cmds.c +++ b/src/renderergl1/tr_cmds.c @@ -148,7 +148,7 @@ returns NULL if there is not enough space for important commands ============= */ void *R_GetCommandBuffer( int bytes ) { - return R_GetCommandBufferReserved( bytes, sizeof ( swapBuffersCommand_t ) ); + return R_GetCommandBufferReserved( bytes, PAD( sizeof( swapBuffersCommand_t ), sizeof(void *) ) ); } -- cgit From 802eb6dfaffb6efba11705fcce16eed8a6e34bad Mon Sep 17 00:00:00 2001 From: Zack Middleton Date: Sat, 17 Oct 2015 21:57:16 -0500 Subject: Replace 4 with sizeof( int ) in R_GetCommandBufferReserved --- src/renderergl1/tr_cmds.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/renderergl1') diff --git a/src/renderergl1/tr_cmds.c b/src/renderergl1/tr_cmds.c index 58f199e3..d92a8b94 100644 --- a/src/renderergl1/tr_cmds.c +++ b/src/renderergl1/tr_cmds.c @@ -127,8 +127,8 @@ void *R_GetCommandBufferReserved( int bytes, int reservedBytes ) { bytes = PAD(bytes, sizeof(void *)); // always leave room for the end of list command - if ( cmdList->used + bytes + 4 + reservedBytes > MAX_RENDER_COMMANDS ) { - if ( bytes > MAX_RENDER_COMMANDS - 4 ) { + if ( cmdList->used + bytes + sizeof( int ) + reservedBytes > MAX_RENDER_COMMANDS ) { + if ( bytes > MAX_RENDER_COMMANDS - sizeof( int ) ) { ri.Error( ERR_FATAL, "R_GetCommandBuffer: bad size %i", bytes ); } // if we run out of room, just start dropping commands -- cgit