From df17bc6614f0804ac535f55a723bf27c551a3ab2 Mon Sep 17 00:00:00 2001 From: JKSunny <60109631+JKSunny@users.noreply.github.com> Date: Mon, 15 Apr 2024 10:14:49 +0200 Subject: [PATCH] Vulkan: Replace PATCH_STITCHING preprocessor define with r_patchStitching cvar Cherrypicked: (https://github.com/JACoders/OpenJK/commit/540edeb67fd65cd08642fe4d324e3e49101755a4) Pull request: (https://github.com/JACoders/OpenJK/pull/1199) Co-Authored-By: razor <844370+razish@users.noreply.github.com> --- codemp/rd-vulkan/tr_bsp.cpp | 12 ++++++------ codemp/rd-vulkan/tr_curve.cpp | 11 ----------- codemp/rd-vulkan/tr_init.cpp | 2 ++ codemp/rd-vulkan/tr_local.h | 2 +- 4 files changed, 9 insertions(+), 18 deletions(-) diff --git a/codemp/rd-vulkan/tr_bsp.cpp b/codemp/rd-vulkan/tr_bsp.cpp index 081d3eb4c7..755a6449e4 100644 --- a/codemp/rd-vulkan/tr_bsp.cpp +++ b/codemp/rd-vulkan/tr_bsp.cpp @@ -2109,15 +2109,15 @@ static void R_LoadSurfaces( const lump_t *surfs, const lump_t *verts, const lump } } -#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 ); + } vk_debug("...loaded %d faces, %i meshes, %i trisurfs, %i flares\n", numFaces, numMeshes, numTriSurfs, numFlares ); } diff --git a/codemp/rd-vulkan/tr_curve.cpp b/codemp/rd-vulkan/tr_curve.cpp index b0338823d7..7b5bbee7ec 100644 --- a/codemp/rd-vulkan/tr_curve.cpp +++ b/codemp/rd-vulkan/tr_curve.cpp @@ -332,7 +332,6 @@ static srfGridMesh_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 = (struct srfGridMesh_s *)/*Hunk_Alloc*/ Z_Malloc( size, TAG_GRIDMESH, qfalse ); memset(grid, 0, size); @@ -341,16 +340,6 @@ static 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-vulkan/tr_init.cpp b/codemp/rd-vulkan/tr_init.cpp index 2d7decd382..d7bbb3df5d 100644 --- a/codemp/rd-vulkan/tr_init.cpp +++ b/codemp/rd-vulkan/tr_init.cpp @@ -178,6 +178,7 @@ cvar_t *r_marksOnTriangleMeshes; cvar_t *r_aspectCorrectFonts; cvar_t *cl_ratioFix; +cvar_t *r_patchStitching; // Vulkan cvar_t *r_defaultImage; @@ -914,6 +915,7 @@ void R_Register( void ) r_marksOnTriangleMeshes = ri.Cvar_Get( "r_marksOnTriangleMeshes", "0", CVAR_ARCHIVE_ND, "" ); r_aspectCorrectFonts = ri.Cvar_Get( "r_aspectCorrectFonts", "0", CVAR_ARCHIVE, "" ); cl_ratioFix = ri.Cvar_Get( "cl_ratioFix", "1", CVAR_ARCHIVE, "" ); + r_patchStitching = ri.Cvar_Get( "r_patchStitching", "1", CVAR_ARCHIVE, "Enable stitching of neighbouring patch surfaces" ); r_maxpolys = ri.Cvar_Get( "r_maxpolys", XSTRING( DEFAULT_MAX_POLYS ), CVAR_NONE, "" ); r_maxpolyverts = ri.Cvar_Get( "r_maxpolyverts", XSTRING( DEFAULT_MAX_POLYVERTS ), CVAR_NONE, "" ); diff --git a/codemp/rd-vulkan/tr_local.h b/codemp/rd-vulkan/tr_local.h index 910dcacbe8..09a52ccde7 100644 --- a/codemp/rd-vulkan/tr_local.h +++ b/codemp/rd-vulkan/tr_local.h @@ -1907,6 +1907,7 @@ extern cvar_t *r_marksOnTriangleMeshes; extern cvar_t *r_aspectCorrectFonts; extern cvar_t *cl_ratioFix; +extern cvar_t *r_patchStitching; // Vulkan extern cvar_t *r_defaultImage; @@ -2252,7 +2253,6 @@ CURVE TESSELATION ============================================================ */ -#define PATCH_STITCHING srfGridMesh_t *R_SubdividePatchToGrid( int width, int height, srfVert_t points[MAX_PATCH_SIZE * MAX_PATCH_SIZE] ); srfGridMesh_t *R_GridInsertColumn( srfGridMesh_t *grid, int column, int row, vec3_t point, float loderror );