From 932151c47504b5fa84865cf7a3f1348fb6db3771 Mon Sep 17 00:00:00 2001 From: Razish Date: Thu, 8 Feb 2024 16:04:17 +1100 Subject: [PATCH] replace PATCH_STITCHING preprocessor define with r_patchStitching cvar --- codemp/rd-dedicated/tr_init.cpp | 5 ++ codemp/rd-dedicated/tr_local.h | 7 +-- codemp/rd-rend2/tr_bsp.cpp | 86 ++++++++++++++++---------------- codemp/rd-rend2/tr_curve.cpp | 22 +-------- codemp/rd-rend2/tr_init.cpp | 88 +++++++++++++++++---------------- codemp/rd-rend2/tr_local.h | 44 ++++++++--------- codemp/rd-vanilla/tr_bsp.cpp | 12 ++--- codemp/rd-vanilla/tr_curve.cpp | 11 ----- codemp/rd-vanilla/tr_init.cpp | 4 ++ codemp/rd-vanilla/tr_local.h | 5 +- 10 files changed, 135 insertions(+), 149 deletions(-) diff --git a/codemp/rd-dedicated/tr_init.cpp b/codemp/rd-dedicated/tr_init.cpp index fe48457a87..794c307989 100644 --- a/codemp/rd-dedicated/tr_init.cpp +++ b/codemp/rd-dedicated/tr_init.cpp @@ -212,6 +212,8 @@ Ghoul2 Insert End cvar_t *r_aviMotionJpegQuality; cvar_t *r_screenshotJpegQuality; +cvar_t *r_patchStitching; + /* ** R_GetModeInfo */ @@ -453,6 +455,9 @@ Ghoul2 Insert Start /* Ghoul2 Insert End */ + + r_patchStitching = ri.Cvar_Get("r_patchStitching", "1", CVAR_ARCHIVE, "Enable stitching of neighbouring patch surfaces" ); + r_modelpoolmegs = ri.Cvar_Get("r_modelpoolmegs", "20", CVAR_ARCHIVE, "" ); if (ri.Sys_LowPhysicalMemory() ) ri.Cvar_Set("r_modelpoolmegs", "0"); diff --git a/codemp/rd-dedicated/tr_local.h b/codemp/rd-dedicated/tr_local.h index aa558b35da..8915ac5b57 100644 --- a/codemp/rd-dedicated/tr_local.h +++ b/codemp/rd-dedicated/tr_local.h @@ -860,7 +860,7 @@ typedef struct model_s { char name[MAX_QPATH]; modtype_t type; int index; // model = tr.models[model->mod_index] - + int dataSize; // just for listing purposes bmodel_t *bmodel; // only if type == MOD_BRUSH md3Header_t *md3[MD3_MAX_LODS]; // only if type == MOD_MESH @@ -1265,6 +1265,9 @@ extern cvar_t *r_noServerGhoul2; /* Ghoul2 Insert End */ + +extern cvar_t *r_patchStitching; + //==================================================================== float R_NoiseGet4f( float x, float y, float z, float t ); @@ -1572,8 +1575,6 @@ CURVE TESSELATION ============================================================ */ -#define PATCH_STITCHING - srfGridMesh_t *R_SubdividePatchToGrid( int width, int height, drawVert_t points[MAX_PATCH_SIZE*MAX_PATCH_SIZE] ); diff --git a/codemp/rd-rend2/tr_bsp.cpp b/codemp/rd-rend2/tr_bsp.cpp index a573fe316c..172174d318 100644 --- a/codemp/rd-rend2/tr_bsp.cpp +++ b/codemp/rd-rend2/tr_bsp.cpp @@ -114,7 +114,7 @@ static void R_ColorShiftLightingBytes( byte in[4], byte out[4] ) { r = in[0] << shift; g = in[1] << shift; b = in[2] << shift; - + // normalize by color instead of saturating to white if ( ( r | g | b ) > 255 ) { int max; @@ -242,7 +242,7 @@ static void R_LoadLightmaps( world_t *worldData, lump_t *l, lump_t *surfs ) { // we are about to upload textures R_IssuePendingRenderCommands(); - + // check for deluxe mapping if (numLightmaps <= 1) { @@ -376,7 +376,7 @@ static void R_LoadLightmaps( world_t *worldData, lump_t *l, lump_t *surfs ) { R_LoadImage(filename, &externalLightmap, &lightmapWidth, &lightmapHeight); } } - + if (externalLightmap) { int newImageSize = lightmapWidth * lightmapHeight * 4 * 2; @@ -451,7 +451,7 @@ static void R_LoadLightmaps( world_t *worldData, lump_t *l, lump_t *surfs ) { else if (buf_p && hdr_capable) { vec4_t color; - + //hack: convert LDR lightmap to HDR one color[0] = MAX(buf_p[j*numColorComponents + 0], 0.499f); color[1] = MAX(buf_p[j*numColorComponents + 1], 0.499f); @@ -734,7 +734,7 @@ static int FatLightmap(int lightmapnum) if (tr.lightmapAtlasSize[0] > 0) return 0; - + return lightmapnum; } @@ -2174,8 +2174,8 @@ static void R_CreateWorldVBOs( world_t *worldData ) ri.Printf(PRINT_ALL, "...calculating world VBO %d ( %i verts %i tris )\n", k, numVerts, numIndexes / 3); // create arrays - verts = (packedVertex_t *)ri.Hunk_AllocateTempMemory(numVerts * sizeof(packedVertex_t)); - indexes = (glIndex_t *)ri.Hunk_AllocateTempMemory(numIndexes * sizeof(glIndex_t)); + verts = (packedVertex_t *)ri.Hunk_AllocateTempMemory(numVerts * sizeof(packedVertex_t)); + indexes = (glIndex_t *)ri.Hunk_AllocateTempMemory(numIndexes * sizeof(glIndex_t)); // set up indices and copy vertices numVerts = 0; @@ -2319,7 +2319,7 @@ static void R_LoadSurfaces( world_t *worldData, lump_t *surfs, lump_t *verts, lu if ( indexLump->filelen % sizeof(*indexes)) ri.Error (ERR_DROP, "LoadMap: funny lump size in %s",worldData->name); - out = (msurface_t *)ri.Hunk_Alloc ( count * sizeof(*out), h_low ); + out = (msurface_t *)ri.Hunk_Alloc ( count * sizeof(*out), h_low ); worldData->surfaces = out; worldData->numsurfaces = count; @@ -2427,17 +2427,17 @@ static void R_LoadSurfaces( world_t *worldData, lump_t *surfs, lump_t *verts, lu ri.FS_FreeFile(hdrVertColors); } -#ifdef PATCH_STITCHING - R_StitchAllPatches(worldData); -#endif + if ( r_patchStitching->integer ) { + R_StitchAllPatches(worldData); + } R_FixSharedVertexLodError(worldData); -#ifdef PATCH_STITCHING - R_MovePatchSurfacesToHunk(worldData); -#endif + if ( r_patchStitching->integer ) { + R_MovePatchSurfacesToHunk(worldData); + } - ri.Printf( PRINT_ALL, "...loaded %d faces, %i meshes, %i trisurfs, %i flares\n", + ri.Printf( PRINT_ALL, "...loaded %d faces, %i meshes, %i trisurfs, %i flares\n", numFaces, numMeshes, numTriSurfs, numFlares ); } @@ -2538,7 +2538,7 @@ static void R_LoadNodesAndLeafs (world_t *worldData, lump_t *nodeLump, lump_t *l numNodes = nodeLump->filelen / sizeof(dnode_t); numLeafs = leafLump->filelen / sizeof(dleaf_t); - out = (mnode_t *)ri.Hunk_Alloc ( (numNodes + numLeafs) * sizeof(*out), h_low); + out = (mnode_t *)ri.Hunk_Alloc ( (numNodes + numLeafs) * sizeof(*out), h_low); worldData->nodes = out; worldData->numnodes = numNodes + numLeafs; @@ -2552,7 +2552,7 @@ static void R_LoadNodesAndLeafs (world_t *worldData, lump_t *nodeLump, lump_t *l out->mins[j] = LittleLong (in->mins[j]); out->maxs[j] = LittleLong (in->maxs[j]); } - + p = LittleLong(in->planeNum); out->plane = worldData->planes + p; @@ -2567,7 +2567,7 @@ static void R_LoadNodesAndLeafs (world_t *worldData, lump_t *nodeLump, lump_t *l out->children[j] = worldData->nodes + numNodes + (-1 - p); } } - + // load leafs inLeaf = (dleaf_t *)(fileBase + leafLump->fileofs); for ( i=0 ; ifirstmarksurface = LittleLong(inLeaf->firstLeafSurface); out->nummarksurfaces = LittleLong(inLeaf->numLeafSurfaces); - } + } // chain decendants R_SetParent (worldData->nodes, NULL); @@ -2600,10 +2600,10 @@ static void R_LoadNodesAndLeafs (world_t *worldData, lump_t *nodeLump, lump_t *l R_LoadShaders ================= */ -static void R_LoadShaders( world_t *worldData, lump_t *l ) { +static void R_LoadShaders( world_t *worldData, lump_t *l ) { int i, count; dshader_t *in, *out; - + in = (dshader_t *)(fileBase + l->fileofs); if (l->filelen % sizeof(*in)) ri.Error (ERR_DROP, "LoadMap: funny lump size in %s",worldData->name); @@ -2628,16 +2628,16 @@ R_LoadMarksurfaces ================= */ static void R_LoadMarksurfaces (world_t *worldData, lump_t *l) -{ +{ int i, j, count; int *in; int *out; - + in = (int *)(fileBase + l->fileofs); if (l->filelen % sizeof(*in)) ri.Error (ERR_DROP, "LoadMap: funny lump size in %s",worldData->name); count = l->filelen / sizeof(*in); - out = (int *)ri.Hunk_Alloc ( count*sizeof(*out), h_low); + out = (int *)ri.Hunk_Alloc ( count*sizeof(*out), h_low); worldData->marksurfaces = out; worldData->nummarksurfaces = count; @@ -2661,13 +2661,13 @@ static void R_LoadPlanes( world_t *worldData, lump_t *l ) { dplane_t *in; int count; int bits; - + in = (dplane_t *)(fileBase + l->fileofs); if (l->filelen % sizeof(*in)) ri.Error (ERR_DROP, "LoadMap: funny lump size in %s",worldData->name); count = l->filelen / sizeof(*in); - out = (cplane_t *)ri.Hunk_Alloc ( count*2*sizeof(*out), h_low); - + out = (cplane_t *)ri.Hunk_Alloc ( count*2*sizeof(*out), h_low); + worldData->planes = out; worldData->numplanes = count; @@ -2797,8 +2797,8 @@ static void R_LoadFogs( world_t *worldData, lump_t *l, lump_t *brushesLump, lump out->parms = shader->fogParms; VectorSet4(out->color, - shader->fogParms.color[0] * tr.identityLight, - shader->fogParms.color[1] * tr.identityLight, + shader->fogParms.color[0] * tr.identityLight, + shader->fogParms.color[1] * tr.identityLight, shader->fogParms.color[2] * tr.identityLight, 1.0); @@ -2851,7 +2851,7 @@ void R_LoadLightGrid( world_t *worldData, lump_t *l ) { Com_Memcpy( worldData->lightGridData, (void *)(fileBase + l->fileofs), l->filelen ); // deal with overbright bits - for ( i = 0 ; i < numGridDataElements ; i++ ) + for ( i = 0 ; i < numGridDataElements ; i++ ) { for(int j = 0; j < MAXLIGHTMAPS; j++) { @@ -2954,7 +2954,7 @@ void R_LoadEntities( world_t *worldData, lump_t *l ) { } // only parse the world spawn - while ( 1 ) { + while ( 1 ) { // parse key token = COM_ParseExt( &p, qtrue ); @@ -3064,7 +3064,7 @@ static qboolean R_ParseSpawnVars( char *spawnVarChars, int maxSpawnVarChars, int } // go through all the key / value pairs - while ( 1 ) { + while ( 1 ) { int keyLength, tokenLength; // parse key @@ -3077,7 +3077,7 @@ static qboolean R_ParseSpawnVars( char *spawnVarChars, int maxSpawnVarChars, int break; } - // parse value + // parse value if ( !R_GetEntityToken( com_token, sizeof( com_token ) ) ) { ri.Printf( PRINT_ALL, "R_ParseSpawnVars: EOF without closing brace\n" ); return qfalse; @@ -3301,7 +3301,7 @@ static void R_RenderAllCubemaps() { cubemapFormat = GL_RGBA16F; } - + for (int k = 0; k <= r_cubeMappingBounces->integer; k++) { bool bounce = k != 0; @@ -3462,7 +3462,7 @@ static void R_MergeLeafSurfaces(world_t *worldData) if (worldData->surfacesViewCount[surfNum2] != -1) continue; - + surf2 = worldData->surfaces + surfNum2; if ((*surf2->data != SF_GRID) && @@ -3512,7 +3512,7 @@ static void R_MergeLeafSurfaces(world_t *worldData) if (!merges) worldData->surfacesViewCount[i] = -1; - } + } // count merged/unmerged surfaces numMergedSurfaces = 0; @@ -3543,7 +3543,7 @@ static void R_MergeLeafSurfaces(world_t *worldData) (int *)ri.Hunk_Alloc( sizeof(*worldData->mergedSurfacesPshadowBits) * numMergedSurfaces, h_low); worldData->numMergedSurfaces = numMergedSurfaces; - + // view surfaces are like mark surfaces, except negative ones represent merged surfaces // -1 represents 0, -2 represents 1, and so on worldData->viewSurfaces = @@ -3707,7 +3707,7 @@ static void R_MergeLeafSurfaces(world_t *worldData) endTime = ri.Milliseconds(); - ri.Printf(PRINT_ALL, "Processed %d surfaces into %d merged, %d unmerged in %5.2f seconds\n", + ri.Printf(PRINT_ALL, "Processed %d surfaces into %d merged, %d unmerged in %5.2f seconds\n", numWorldSurfaces, numMergedSurfaces, numUnmergedSurfaces, (endTime - startTime) / 1000.0f); // reset viewcounts @@ -4147,8 +4147,8 @@ static void R_GenerateSurfaceSprites( const world_t *world, int worldIndex ) { VBO_t *vbo = R_CreateVBO((byte *)sprites_data.data(), sizeof(sprite_t) * sprites_data.size(), VBO_USAGE_STATIC); - - for (srfSprites_t *sp : currentBatch) + + for (srfSprites_t *sp : currentBatch) { sp->vbo = vbo; sp->ibo = ibo; @@ -4249,7 +4249,7 @@ world_t *R_LoadBSP(const char *name, int *bspIndex) { ri.Error( ERR_DROP, - "R_LoadBSP: %s has wrong version number (%i should be %i)", + "R_LoadBSP: %s has wrong version number (%i should be %i)", name, bspVersion, BSP_VERSION); @@ -4296,7 +4296,7 @@ world_t *R_LoadBSP(const char *name, int *bspIndex) &header->lumps[LUMP_BRUSHSIDES]); R_GenerateSurfaceSprites(worldData, worldIndex + 1); - + // load cubemaps if (r_cubeMapping->integer && bspIndex == nullptr) { @@ -4321,7 +4321,7 @@ world_t *R_LoadBSP(const char *name, int *bspIndex) if (tr.numCubemaps) break; } - + } if (tr.numCubemaps) diff --git a/codemp/rd-rend2/tr_curve.cpp b/codemp/rd-rend2/tr_curve.cpp index bdb8494242..90c24c4950 100644 --- a/codemp/rd-rend2/tr_curve.cpp +++ b/codemp/rd-rend2/tr_curve.cpp @@ -347,7 +347,7 @@ static void InvertErrorTable( float errorTable[2][MAX_GRID_SIZE], int width, int PutPointsOnCurve ================== */ -static void PutPointsOnCurve( srfVert_t ctrl[MAX_GRID_SIZE][MAX_GRID_SIZE], +static void PutPointsOnCurve( srfVert_t ctrl[MAX_GRID_SIZE][MAX_GRID_SIZE], int width, int height ) { int i, j; srfVert_t prev, next; @@ -386,7 +386,6 @@ srfBspSurface_t *R_CreateSurfaceGridMesh(int width, int height, // copy the results out to a grid size = (width * height - 1) * sizeof( srfVert_t ) + sizeof( *grid ); -#ifdef PATCH_STITCHING grid = /*ri.Hunk_Alloc*/ (srfBspSurface_t *)Z_Malloc( size, TAG_GRIDMESH ); Com_Memset(grid, 0, size); @@ -402,23 +401,6 @@ srfBspSurface_t *R_CreateSurfaceGridMesh(int width, int height, grid->numVerts = (width * height); grid->verts = (srfVert_t *)Z_Malloc(grid->numVerts * sizeof(srfVert_t), TAG_GRIDMESH); -#else - grid = ri.Hunk_Alloc( size ); - Com_Memset(grid, 0, size); - - grid->widthLodError = ri.Hunk_Alloc( width * 4 ); - Com_Memcpy( grid->widthLodError, errorTable[0], width * 4 ); - - grid->heightLodError = ri.Hunk_Alloc( height * 4 ); - Com_Memcpy( grid->heightLodError, errorTable[1], height * 4 ); - - grid->numIndexes = numIndexes; - grid->indexes = (glIndex_t *)ri.Hunk_Alloc(grid->numIndexes * sizeof(glIndex_t), h_low); - Com_Memcpy(grid->indexes, indexes, numIndexes * sizeof(glIndex_t)); - - grid->numVerts = (width * height); - grid->verts = ri.Hunk_Alloc(grid->numVerts * sizeof(srfVert_t), h_low); -#endif grid->width = width; grid->height = height; @@ -476,7 +458,7 @@ srfBspSurface_t *R_SubdividePatchToGrid( int width, int height, int numIndexes; static glIndex_t indexes[(MAX_GRID_SIZE-1)*(MAX_GRID_SIZE-1)*2*3]; int consecutiveComplete; - + Com_Memset (&prev, 0, sizeof (prev)); Com_Memset (&next, 0, sizeof (next)); Com_Memset (&mid, 0, sizeof (mid)); diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index 490eda6664..183fbcae90 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -273,6 +273,8 @@ cvar_t *r_debugWeather; cvar_t *r_aspectCorrectFonts; +cvar_t *r_patchStitching; + extern void RB_SetGL2D (void); static void R_Splash() { @@ -624,8 +626,8 @@ we use statics to store a count and start writing the first screenshot/screensho (with FS_FileExists / FS_FOpenFileWrite calls) FIXME: the statics don't get a reinit between fs_game changes -============================================================================== -*/ +============================================================================== +*/ /* ================== @@ -682,10 +684,10 @@ static void ConvertRGBtoBGR( *dst++ = pixelRGB[2]; *dst++ = pixelRGB[1]; *dst++ = temp; - + pixelRGB += 3; } - + row += stride; } } @@ -718,11 +720,11 @@ static void R_SaveTGA( ri.Hunk_FreeTempMemory(buffer); } -/* -================== +/* +================== R_SaveScreenshotTGA -================== -*/ +================== +*/ static void R_SaveScreenshotTGA( const screenshotReadback_t *screenshotReadback, byte *pixels) { @@ -735,9 +737,9 @@ static void R_SaveScreenshotTGA( } /* -================== +================== R_SaveScreenshotPNG -================== +================== */ static void R_SaveScreenshotPNG( const screenshotReadback_t *screenshotReadback, byte *pixels) @@ -822,7 +824,7 @@ R_TakeScreenshotCmd */ const void *RB_TakeScreenshotCmd( const void *data ) { const screenshotCommand_t *cmd; - + cmd = (const screenshotCommand_t *)data; // finish any 2D drawing if needed @@ -832,13 +834,13 @@ const void *RB_TakeScreenshotCmd( const void *data ) { const int frameNumber = backEndData->realFrameNumber; gpuFrame_t *thisFrame = &backEndData->frames[frameNumber % MAX_FRAMES]; screenshotReadback_t *screenshot = &thisFrame->screenshotReadback; - + GLint packAlign; qglGetIntegerv(GL_PACK_ALIGNMENT, &packAlign); - + const int linelen = cmd->width * 3; const int strideInBytes = PAD(linelen, packAlign); - + qglGenBuffers(1, &screenshot->pbo); qglBindBuffer(GL_PIXEL_PACK_BUFFER, screenshot->pbo); qglBufferData( @@ -856,8 +858,8 @@ const void *RB_TakeScreenshotCmd( const void *data ) { screenshot->format = cmd->format; Q_strncpyz( screenshot->filename, cmd->fileName, sizeof(screenshot->filename)); - - return (const void *)(cmd + 1); + + return (const void *)(cmd + 1); } /* @@ -884,11 +886,11 @@ void R_TakeScreenshot( int x, int y, int width, int height, char *name, screensh cmd->format = format; } -/* -================== +/* +================== R_ScreenshotFilename -================== -*/ +================== +*/ void R_ScreenshotFilename( char *buf, int bufSize, const char *ext ) { time_t rawtime; char timeStr[32] = {0}; // should really only reach ~19 chars @@ -968,8 +970,8 @@ static void R_LevelShot( void ) { ri.Printf( PRINT_ALL, "Wrote %s\n", checkname ); } -/* -================== +/* +================== R_ScreenShotTGA_f screenshot @@ -978,8 +980,8 @@ screenshot [levelshot] screenshot [filename] Doesn't print the pacifier message if there is a second arg -================== -*/ +================== +*/ void R_ScreenShotTGA_f (void) { char checkname[MAX_OSPATH] = {0}; qboolean silent = qfalse; @@ -1001,7 +1003,7 @@ void R_ScreenShotTGA_f (void) { R_ScreenshotFilename( checkname, sizeof( checkname ), ".tga" ); if ( ri.FS_FileExists( checkname ) ) { - Com_Printf( "ScreenShot: Couldn't create a file\n"); + Com_Printf( "ScreenShot: Couldn't create a file\n"); return; } } @@ -1033,7 +1035,7 @@ void R_ScreenShotPNG_f (void) { R_ScreenshotFilename( checkname, sizeof( checkname ), ".png" ); if ( ri.FS_FileExists( checkname ) ) { - Com_Printf( "ScreenShot: Couldn't create a file\n"); + Com_Printf( "ScreenShot: Couldn't create a file\n"); return; } } @@ -1065,7 +1067,7 @@ void R_ScreenShotJPEG_f (void) { R_ScreenshotFilename( checkname, sizeof( checkname ), ".jpg" ); if ( ri.FS_FileExists( checkname ) ) { - Com_Printf( "ScreenShot: Couldn't create a file\n"); + Com_Printf( "ScreenShot: Couldn't create a file\n"); return; } } @@ -1096,7 +1098,7 @@ const void *RB_TakeVideoFrameCmd( const void *data ) RB_EndSurface(); cmd = (const videoFrameCommand_t *)data; - + qglGetIntegerv(GL_PACK_ALIGNMENT, &packAlign); linelen = cmd->width * 3; @@ -1109,7 +1111,7 @@ const void *RB_TakeVideoFrameCmd( const void *data ) avipadlen = avipadwidth - linelen; cBuf = (byte*)(PADP(cmd->captureBuffer, packAlign)); - + qglReadPixels(0, 0, cmd->width, cmd->height, GL_RGB, GL_UNSIGNED_BYTE, cBuf); @@ -1130,11 +1132,11 @@ const void *RB_TakeVideoFrameCmd( const void *data ) { byte *lineend, *memend; byte *srcptr, *destptr; - + srcptr = cBuf; destptr = cmd->encodeBuffer; memend = srcptr + memcount; - + // swap R and B and remove line paddings while(srcptr < memend) { @@ -1146,17 +1148,17 @@ const void *RB_TakeVideoFrameCmd( const void *data ) *destptr++ = srcptr[0]; srcptr += 3; } - + Com_Memset(destptr, '\0', avipadlen); destptr += avipadlen; - + srcptr += padlen; } - + ri.CL_WriteAVIVideoFrame(cmd->encodeBuffer, avipadwidth * cmd->height); } - return (const void *)(cmd + 1); + return (const void *)(cmd + 1); } //============================================================================ @@ -1240,7 +1242,7 @@ void R_PrintLongString(const char *string) { GfxInfo_f ================ */ -static void GfxInfo_f( void ) +static void GfxInfo_f( void ) { const char *enablestrings[] = { @@ -1316,7 +1318,7 @@ static void GfxInfo_f( void ) GfxMemInfo_f ================ */ -void GfxMemInfo_f( void ) +void GfxMemInfo_f( void ) { switch (glRefConfig.memInfo) { @@ -1418,7 +1420,7 @@ static const size_t numCommands = ARRAY_LEN( commands ); R_Register =============== */ -void R_Register( void ) +void R_Register( void ) { // // latched and archived variables @@ -1499,7 +1501,7 @@ void R_Register( void ) r_baseNormalX = ri.Cvar_Get( "r_baseNormalX", "1.0", CVAR_ARCHIVE | CVAR_LATCH, "" ); r_baseNormalY = ri.Cvar_Get( "r_baseNormalY", "1.0", CVAR_ARCHIVE | CVAR_LATCH, "" ); r_baseParallax = ri.Cvar_Get( "r_baseParallax", "0.05", CVAR_ARCHIVE | CVAR_LATCH, "" ); - r_baseSpecular = ri.Cvar_Get( "r_baseSpecular", "0.04", CVAR_ARCHIVE | CVAR_LATCH, "" ); + r_baseSpecular = ri.Cvar_Get( "r_baseSpecular", "0.04", CVAR_ARCHIVE | CVAR_LATCH, "" ); r_dlightMode = ri.Cvar_Get( "r_dlightMode", "1", CVAR_ARCHIVE | CVAR_LATCH, "" ); r_pshadowDist = ri.Cvar_Get( "r_pshadowDist", "128", CVAR_ARCHIVE, "" ); r_imageUpsample = ri.Cvar_Get( "r_imageUpsample", "0", CVAR_ARCHIVE | CVAR_LATCH, "" ); @@ -1643,6 +1645,8 @@ Ghoul2 Insert Start Ghoul2 Insert End */ + r_patchStitching = ri.Cvar_Get("r_patchStitching", "1", CVAR_ARCHIVE, "Enable stitching of neighbouring patch surfaces" ); + se_language = ri.Cvar_Get ( "se_language", "english", CVAR_ARCHIVE | CVAR_NORESTART, "" ); for ( size_t i = 0; i < numCommands; i++ ) @@ -1905,14 +1909,14 @@ R_Init void R_Init( void ) { byte *ptr; int i; - + ri.Printf( PRINT_ALL, "----- R_Init -----\n" ); // clear all our internal state Com_Memset( &tr, 0, sizeof( tr ) ); Com_Memset( &backEnd, 0, sizeof( backEnd ) ); Com_Memset( &tess, 0, sizeof( tess ) ); - + // // init function tables @@ -2181,7 +2185,7 @@ Q_EXPORT refexport_t* QDECL GetRefAPI ( int apiVersion, refimport_t *rimp ) { Com_Memset( &re, 0, sizeof( re ) ); if ( apiVersion != REF_API_VERSION ) { - ri.Printf(PRINT_ALL, "Mismatched REF_API_VERSION: expected %i, got %i\n", + ri.Printf(PRINT_ALL, "Mismatched REF_API_VERSION: expected %i, got %i\n", REF_API_VERSION, apiVersion ); return NULL; } diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 52e53503c1..f03215cd0f 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -286,6 +286,8 @@ extern cvar_t *broadsword_dircap; Ghoul2 Insert End */ +extern cvar_t *r_patchStitching; + /* End Cvars */ @@ -497,8 +499,8 @@ typedef enum { GF_SIN, GF_SQUARE, GF_TRIANGLE, - GF_SAWTOOTH, - GF_INVERSE_SAWTOOTH, + GF_SAWTOOTH, + GF_INVERSE_SAWTOOTH, GF_NOISE, GF_RAND @@ -853,7 +855,7 @@ typedef enum ST_GLSL } stageType_t; -typedef enum +typedef enum { SPEC_NONE, // no specular found SPEC_SPECGLOSS, // Specular Gloss @@ -889,7 +891,7 @@ typedef struct { qboolean cloth; AlphaTestType alphaTestType; - + textureBundle_t bundle[NUM_TEXTURE_BUNDLES]; waveForm_t rgbWave; @@ -975,7 +977,7 @@ typedef struct shader_s { qboolean isPortal; cullType_t cullType; // CT_FRONT_SIDED, CT_BACK_SIDED, or CT_TWO_SIDED - qboolean polygonOffset; // set for decals and other items that must be offset + qboolean polygonOffset; // set for decals and other items that must be offset qboolean noMipMaps; // for console fonts, 2D elements, etc. qboolean noPicMip; // for images that must always be full resolution qboolean noTC; // for images that don't want to be texture compressed (eg skies) @@ -991,8 +993,8 @@ typedef struct shader_s { int numSurfaceSpriteStages; GLuint spriteUbo; int ShaderInstanceUboOffset; - - shaderStage_t *stages[MAX_SHADER_STAGES]; + + shaderStage_t *stages[MAX_SHADER_STAGES]; void (*optimalStageIteratorFunc)( void ); qboolean isHDRLit; @@ -1159,7 +1161,7 @@ enum ATTR_BONE_WEIGHTS | ATTR_POSITION2 #ifdef REND2_SP - | + | ATTR_TANGENT2 | ATTR_NORMAL2 #endif // REND2_SP @@ -1180,7 +1182,7 @@ enum #else GENERICDEF_ALL = 0x007F, #endif // REND2_SP - + GENERICDEF_COUNT = GENERICDEF_ALL + 1, }; @@ -1242,7 +1244,7 @@ enum #else LIGHTDEF_ALL = 0x01FF, #endif // REND2_SP - + LIGHTDEF_COUNT = LIGHTDEF_ALL + 1 }; @@ -1757,7 +1759,7 @@ typedef struct srfBspSurface_s // static render data VBO_t *vbo; IBO_t *ibo; - + // SF_GRID specific variables after here // lod information, which may be different @@ -1850,7 +1852,7 @@ SHADOWS typedef struct pshadow_s { float sort; - + int numEntities; int entityNums[8]; vec3_t entityOrigins[8]; @@ -1919,7 +1921,7 @@ typedef struct mnode_s { // node specific cplane_t *plane; - struct mnode_s *children[2]; + struct mnode_s *children[2]; // leaf specific int cluster; @@ -1936,7 +1938,7 @@ typedef struct { int numSurfaces; } bmodel_t; -typedef struct +typedef struct { byte ambientLight[MAXLIGHTMAPS][3]; byte directLight[MAXLIGHTMAPS][3]; @@ -2161,7 +2163,7 @@ typedef struct model_s { void R_ModelInit (void); model_t *R_GetModelByHandle( qhandle_t hModel ); -int R_LerpTag( orientation_t *tag, qhandle_t handle, int startFrame, int endFrame, +int R_LerpTag( orientation_t *tag, qhandle_t handle, int startFrame, int endFrame, float frac, const char *tagName ); void R_ModelBounds( qhandle_t handle, vec3_t mins, vec3_t maxs ); @@ -2315,7 +2317,7 @@ typedef struct { int c_surfaces, c_shaders, c_vertexes, c_indexes, c_totalIndexes; int c_surfBatches; float c_overDraw; - + int c_vboVertexBuffers; int c_vboIndexBuffers; int c_vboVertexes; @@ -2369,7 +2371,7 @@ typedef struct { } backEndState_t; /* -** trGlobals_t +** trGlobals_t ** ** Most renderer globals are defined here. ** backend functions should never modify any of these fields, @@ -2539,7 +2541,7 @@ typedef struct trGlobals_s { viewParms_t viewParms; viewParms_t cachedViewParms[3 + MAX_DLIGHTS * 6 + 3 + MAX_DRAWN_PSHADOWS]; int numCachedViewParms; - + viewParms_t skyPortalParms; byte skyPortalAreaMask[MAX_MAP_AREA_BYTES]; int skyPortalEntities; @@ -2846,7 +2848,7 @@ void R_AddPolygonSurfaces( const trRefdef_t *refdef ); void R_DecomposeSort( uint32_t sort, int *entityNum, shader_t **shader, int *cubemap, int *postRender ); uint32_t R_CreateSortKey(int entityNum, int sortedShaderIndex, int cubemapIndex, int postRender); -void R_AddDrawSurf( surfaceType_t *surface, int entityNum, shader_t *shader, +void R_AddDrawSurf( surfaceType_t *surface, int entityNum, shader_t *shader, int fogIndex, int dlightMap, int postRender, int cubemap ); bool R_IsPostRenderEntity ( const trRefEntity_t *refEntity ); @@ -3006,7 +3008,7 @@ typedef struct stageVars #define MAX_MULTIDRAW_PRIMITIVES 16384 const int NUM_TESS_TEXCOORDS = 1 + MAXLIGHTMAPS; -struct shaderCommands_s +struct shaderCommands_s { glIndex_t indexes[SHADER_MAX_INDEXES] QALIGN(16); vec4_t xyz[SHADER_MAX_VERTEXES] QALIGN(16); @@ -3151,8 +3153,6 @@ CURVE TESSELATION ============================================================ */ -#define PATCH_STITCHING - srfBspSurface_t *R_SubdividePatchToGrid( int width, int height, srfVert_t points[MAX_PATCH_SIZE*MAX_PATCH_SIZE] ); srfBspSurface_t *R_GridInsertColumn( srfBspSurface_t *grid, int column, int row, vec3_t point, float loderror ); diff --git a/codemp/rd-vanilla/tr_bsp.cpp b/codemp/rd-vanilla/tr_bsp.cpp index 7ce2e82eec..ecc3df602f 100644 --- a/codemp/rd-vanilla/tr_bsp.cpp +++ b/codemp/rd-vanilla/tr_bsp.cpp @@ -1391,15 +1391,15 @@ static void R_LoadSurfaces( lump_t *surfs, lump_t *verts, lump_t *indexLump, wor } } -#ifdef PATCH_STITCHING - R_StitchAllPatches(worldData); -#endif + if ( r_patchStitching->integer ) { + R_StitchAllPatches(worldData); + } R_FixSharedVertexLodError(worldData); -#ifdef PATCH_STITCHING - R_MovePatchSurfacesToHunk(worldData); -#endif + if ( r_patchStitching->integer ) { + R_MovePatchSurfacesToHunk(worldData); + } ri.Printf( PRINT_ALL, "...loaded %d faces, %i meshes, %i trisurfs, %i flares\n", numFaces, numMeshes, numTriSurfs, numFlares ); } diff --git a/codemp/rd-vanilla/tr_curve.cpp b/codemp/rd-vanilla/tr_curve.cpp index bc67911d0d..e3d75834f1 100644 --- a/codemp/rd-vanilla/tr_curve.cpp +++ b/codemp/rd-vanilla/tr_curve.cpp @@ -306,7 +306,6 @@ srfGridMesh_t *R_CreateSurfaceGridMesh(int width, int height, // copy the results out to a grid size = (width * height - 1) * sizeof( drawVert_t ) + sizeof( *grid ); -#ifdef PATCH_STITCHING grid = (struct srfGridMesh_s *)/*Hunk_Alloc*/ Z_Malloc( size, TAG_GRIDMESH, qfalse ); memset(grid, 0, size); @@ -315,16 +314,6 @@ srfGridMesh_t *R_CreateSurfaceGridMesh(int width, int height, grid->heightLodError = (float *)/*Hunk_Alloc*/ Z_Malloc( height * 4, TAG_GRIDMESH, qfalse ); memcpy( grid->heightLodError, errorTable[1], height * 4 ); -#else - grid = Hunk_Alloc( size ); - memset(grid, 0, size); - - grid->widthLodError = Hunk_Alloc( width * 4 ); - memcpy( grid->widthLodError, errorTable[0], width * 4 ); - - grid->heightLodError = Hunk_Alloc( height * 4 ); - memcpy( grid->heightLodError, errorTable[1], height * 4 ); -#endif grid->width = width; grid->height = height; diff --git a/codemp/rd-vanilla/tr_init.cpp b/codemp/rd-vanilla/tr_init.cpp index 847bae6257..ef4944ab0c 100644 --- a/codemp/rd-vanilla/tr_init.cpp +++ b/codemp/rd-vanilla/tr_init.cpp @@ -216,6 +216,8 @@ cvar_t *se_language; cvar_t *r_aviMotionJpegQuality; cvar_t *r_screenshotJpegQuality; +cvar_t *r_patchStitching; + #if !defined(__APPLE__) PFNGLSTENCILOPSEPARATEPROC qglStencilOpSeparate; #endif @@ -1705,6 +1707,8 @@ Ghoul2 Insert End ri.Cvar_CheckRange( r_aviMotionJpegQuality, 10, 100, qtrue ); ri.Cvar_CheckRange( r_screenshotJpegQuality, 10, 100, qtrue ); + r_patchStitching = ri.Cvar_Get("r_patchStitching", "1", CVAR_ARCHIVE, "Enable stitching of neighbouring patch surfaces" ); + for ( size_t i = 0; i < numCommands; i++ ) ri.Cmd_AddCommand( commands[i].cmd, commands[i].func, "" ); } diff --git a/codemp/rd-vanilla/tr_local.h b/codemp/rd-vanilla/tr_local.h index 6f9504d682..dcef60d901 100644 --- a/codemp/rd-vanilla/tr_local.h +++ b/codemp/rd-vanilla/tr_local.h @@ -1273,6 +1273,9 @@ extern cvar_t *r_noServerGhoul2; /* Ghoul2 Insert End */ + +extern cvar_t *r_patchStitching; + //==================================================================== void R_SwapBuffers( int ); @@ -1596,8 +1599,6 @@ CURVE TESSELATION ============================================================ */ -#define PATCH_STITCHING - srfGridMesh_t *R_SubdividePatchToGrid( int width, int height, drawVert_t points[MAX_PATCH_SIZE*MAX_PATCH_SIZE] );