Skip to content

Commit

Permalink
Upstream vulkan updates (#190)
Browse files Browse the repository at this point in the history
* Vulkan: Upstream changes from quake3e

Cherrypicked: ec-/Quake3e@526944c
(cherry picked from commit 7de282a)

* Vulkan: Replace PATCH_STITCHING preprocessor define with r_patchStitching cvar

Cherrypicked: (JACoders@540edeb)
Pull request:   (JACoders#1199)

Co-Authored-By: razor <[email protected]>

(cherry picked from commit 7aca568)

* Renderers: Replace PATCH_STITCHING preprocessor define with r_patchStitching cvar

Cherrypicked: (JACoders@540edeb)
Pull request: (JACoders#1199)

Co-Authored-By: razor <[email protected]>

(cherry picked from commit 3ae2bbd)

* Vulkan: Remove unused variable from refraction extract

(b6f5ff5)

Co-Authored-By: razor <[email protected]>

(cherry picked from commit 386024c)

* Vulkan: Cherry pick changes from TaystJK

 (cf5f509)

Co-Authored-By: razor <[email protected]>

(cherry picked from commit 38997d3)

* Renderers: Move struct skinSurface_t and skin_t to tr_local.h and cleanup miniEntities

Cherrypicked: (0c78978)
Co-Authored-By: tayst <[email protected]>

(cherry picked from commit 90d4de9)

* Renderers: Revert whitespace changes in tr_image_load.cpp

(cherry picked from commit ba9c5e8)

---------

Co-authored-by: JKSunny <[email protected]>
  • Loading branch information
taysta and JKSunny authored Apr 24, 2024
1 parent 0f18e9e commit c7590df
Show file tree
Hide file tree
Showing 19 changed files with 41 additions and 226 deletions.
25 changes: 11 additions & 14 deletions codemp/rd-common/tr_image_load.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,37 +107,34 @@ void R_LoadImage( const char *shortname, byte **pic, int *width, int *height ) {
*height = 0;

// Try loading the image with the original extension (if possible).
const char *extension = COM_GetExtension(shortname);
const ImageLoaderMap *imageLoader = FindImageLoader(extension);
if (imageLoader != NULL)
const char *extension = COM_GetExtension (shortname);
const ImageLoaderMap *imageLoader = FindImageLoader (extension);
if ( imageLoader != NULL )
{
imageLoader->loader(shortname, pic, width, height);
if (*pic)
imageLoader->loader (shortname, pic, width, height);
if ( *pic )
{
return;
}
}

// Loop through all the image loaders trying to load this image.
char extensionlessName[MAX_QPATH];
COM_StripExtension(shortname, extensionlessName, sizeof(extensionlessName));
for (int i = 0; i < numImageLoaders; i++)
COM_StripExtension(shortname, extensionlessName, sizeof( extensionlessName ));
for ( int i = 0; i < numImageLoaders; i++ )
{
const ImageLoaderMap *tryLoader = &imageLoaders[i];
if (tryLoader == imageLoader)
if ( tryLoader == imageLoader )
{
// Already tried this one.
continue;
}

const char *name = va("%s.%s", extensionlessName, tryLoader->extension);

tryLoader->loader(name, pic, width, height);
if (*pic)
const char *name = va ("%s.%s", extensionlessName, tryLoader->extension);
tryLoader->loader (name, pic, width, height);
if ( *pic )
{
return;
}
}

return;
}
5 changes: 1 addition & 4 deletions codemp/rd-dedicated/tr_init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,7 @@ Ghoul2 Insert End

cvar_t *r_aviMotionJpegQuality;
cvar_t *r_screenshotJpegQuality;

cvar_t *r_patchStitching;
cvar_t *r_patchStitching;

/*
** R_GetModeInfo
Expand Down Expand Up @@ -455,9 +454,7 @@ 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");
Expand Down
5 changes: 2 additions & 3 deletions codemp/rd-dedicated/tr_local.h
Original file line number Diff line number Diff line change
Expand Up @@ -543,12 +543,11 @@ typedef struct {
} skinSurface_t;

typedef struct skin_s {
char name[MAX_QPATH]; // game path, including extension
int numSurfaces;
char name[MAX_QPATH]; // game path, including extension
int numSurfaces;
skinSurface_t *surfaces[128];
} skin_t;


typedef struct fog_s {
int originalBrushNumber;
vec3_t bounds[2];
Expand Down
4 changes: 2 additions & 2 deletions codemp/rd-vanilla/tr_bsp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1393,13 +1393,13 @@ static void R_LoadSurfaces( lump_t *surfs, lump_t *verts, lump_t *indexLump, wor
}

if ( r_patchStitching->integer ) {
R_StitchAllPatches(worldData);
R_StitchAllPatches( worldData );
}

R_FixSharedVertexLodError(worldData);

if ( r_patchStitching->integer ) {
R_MovePatchSurfacesToHunk(worldData);
R_MovePatchSurfacesToHunk( worldData );
}

ri.Printf( PRINT_ALL, "...loaded %d faces, %i meshes, %i trisurfs, %i flares\n", numFaces, numMeshes, numTriSurfs, numFlares );
Expand Down
2 changes: 1 addition & 1 deletion codemp/rd-vanilla/tr_init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ cvar_t *se_language;
cvar_t *r_aviMotionJpegQuality;
cvar_t *r_screenshotJpegQuality;

cvar_t *r_patchStitching;
cvar_t *r_patchStitching;

#if !defined(__APPLE__)
PFNGLSTENCILOPSEPARATEPROC qglStencilOpSeparate;
Expand Down
7 changes: 3 additions & 4 deletions codemp/rd-vanilla/tr_local.h
Original file line number Diff line number Diff line change
Expand Up @@ -575,12 +575,11 @@ typedef struct {
} skinSurface_t;

typedef struct skin_s {
char name[MAX_QPATH]; // game path, including extension
int numSurfaces;
char name[MAX_QPATH]; // game path, including extension
int numSurfaces;
skinSurface_t *surfaces[128];
} skin_t;


typedef struct fog_s {
int originalBrushNumber;
vec3_t bounds[2];
Expand Down Expand Up @@ -1292,7 +1291,7 @@ extern cvar_t *r_noServerGhoul2;
Ghoul2 Insert End
*/

extern cvar_t *r_patchStitching;
extern cvar_t *r_patchStitching;

//====================================================================

Expand Down
11 changes: 3 additions & 8 deletions codemp/rd-vulkan/tr_bsp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,8 @@ static void R_LoadLightmaps( lump_t *l, lump_t *surfs, world_t &worldData ) {
int len;
byte *image;
int imageSize;
int i, j, numLightmaps = 0; //, textureInternalFormat = 0;
int i, j, numLightmaps = 0;
float maxIntensity = 0;
//double sumIntensity = 0;
int numColorComponents = 3;

const int lightmapSize = DEFAULT_LIGHTMAP_SIZE;
Expand Down Expand Up @@ -221,8 +220,6 @@ static void R_LoadLightmaps( lump_t *l, lump_t *surfs, world_t &worldData ) {

tr.lightmaps = (image_t **)ri.Hunk_Alloc( tr.numLightmaps * sizeof(image_t *), h_low );

//textureInternalFormat = GL_RGBA8;

if ( tr.worldInternalLightmapping )
{
for ( i = 0; i < tr.numLightmaps; i++ )
Expand Down Expand Up @@ -336,8 +333,6 @@ static void R_LoadLightmaps( lump_t *l, lump_t *surfs, world_t &worldData ) {
image[j * 4 + 1] = out[1] * 255;
image[j * 4 + 2] = out[2] * 255;
image[j * 4 + 3] = 255;

//sumIntensity += intensity;
}
else
{
Expand Down Expand Up @@ -1634,13 +1629,13 @@ static void R_LoadSurfaces( const lump_t *surfs, const lump_t *verts, const lump
}

if ( r_patchStitching->integer ) {
R_StitchAllPatches(worldData);
R_StitchAllPatches( worldData );
}

R_FixSharedVertexLodError(worldData);

if ( r_patchStitching->integer ) {
R_MovePatchSurfacesToHunk(worldData);
R_MovePatchSurfacesToHunk( worldData );
}

vk_debug("...loaded %d faces, %i meshes, %i trisurfs, %i flares\n", numFaces, numMeshes, numTriSurfs, numFlares );
Expand Down
5 changes: 0 additions & 5 deletions codemp/rd-vulkan/tr_ghoul2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3553,7 +3553,6 @@ void RB_SurfaceGhoul(CRenderableSurface* surf)

//float *texCoords = tess.texCoords[0][baseVertex];
float* texCoords = tess.texCoords[0][baseVertex];
//int hack = baseVertex;
//rww - since the array is arranged as such we cannot increment
//the relative memory position to get where we want. Maybe this
//is why sof2 has the texCoords array reversed. In any case, I
Expand Down Expand Up @@ -4285,8 +4284,6 @@ qboolean R_LoadMDXM( model_t *mod, void *buffer, const char *mod_name, qboolean
lod = (mdxmLOD_t *) ( (byte *)mdxm + mdxm->ofsLODs );
for ( l = 0 ; l < mdxm->numLODs ; l++)
{
//int triCount = 0;

LL(lod->ofsEnd);
// swap all the surfaces
surf = (mdxmSurface_t *) ( (byte *)lod + sizeof (mdxmLOD_t) + (mdxm->numSurfaces * sizeof(mdxmLODSurfOffset_t)) );
Expand All @@ -4302,8 +4299,6 @@ qboolean R_LoadMDXM( model_t *mod, void *buffer, const char *mod_name, qboolean
LL(surf->ofsBoneReferences);
LL(surf->ofsEnd);

//triCount += surf->numTriangles;

if ( surf->numVerts > SHADER_MAX_VERTEXES ) {
Com_Error (ERR_DROP, "R_LoadMDXM: %s has more than %i verts on a surface (%i)",
mod_name, SHADER_MAX_VERTEXES, surf->numVerts );
Expand Down
5 changes: 3 additions & 2 deletions codemp/rd-vulkan/tr_init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ cvar_t *r_patchStitching;
// Vulkan
cvar_t *r_defaultImage;
cvar_t *r_device;
cvar_t *r_stencilbits;
//cvar_t *r_stencilbits;
cvar_t *r_ext_multisample;
cvar_t *r_ext_supersample;
cvar_t *r_ext_alpha_to_coverage;
Expand Down Expand Up @@ -900,6 +900,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, "" );

Expand All @@ -912,7 +913,7 @@ void R_Register( void )
ri.Cvar_CheckRange(r_device, -2, 8, qtrue);
r_device->modified = qfalse;

r_stencilbits = ri.Cvar_Get("r_stencilbits", "8", CVAR_ARCHIVE_ND | CVAR_LATCH, "");
//r_stencilbits = ri.Cvar_Get("r_stencilbits", "8", CVAR_ARCHIVE_ND | CVAR_LATCH, "");
r_ext_multisample = ri.Cvar_Get("r_ext_multisample", "0", CVAR_ARCHIVE_ND | CVAR_LATCH, "");
ri.Cvar_CheckRange(r_ext_multisample, 0, 64, qtrue);
r_ext_supersample = ri.Cvar_Get("r_ext_supersample", "0", CVAR_ARCHIVE_ND | CVAR_LATCH, "");
Expand Down
7 changes: 3 additions & 4 deletions codemp/rd-vulkan/tr_local.h
Original file line number Diff line number Diff line change
Expand Up @@ -714,12 +714,11 @@ typedef struct {
} skinSurface_t;

typedef struct skin_s {
char name[MAX_QPATH]; // game path, including extension
int numSurfaces;
char name[MAX_QPATH]; // game path, including extension
int numSurfaces;
skinSurface_t *surfaces[128];
} skin_t;


typedef struct fog_s {
int originalBrushNumber;
vec3_t bounds[2];
Expand Down Expand Up @@ -1606,6 +1605,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;
Expand Down Expand Up @@ -2166,7 +2166,6 @@ typedef struct backEndData_s {
dlight_t dlights[MAX_DLIGHTS];
#endif
trRefEntity_t entities[MAX_REFENTITIES];
trMiniRefEntity_t miniEntities[MAX_MINI_ENTITIES];
srfPoly_t *polys;//[MAX_POLYS];
polyVert_t *polyVerts;//[MAX_POLYVERTS];
renderCommandList_t commands;
Expand Down
103 changes: 0 additions & 103 deletions codemp/rd-vulkan/tr_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -290,24 +290,6 @@ void R_TransformModelToClip( const vec3_t src, const float *modelMatrix, const f
}
}

/*
==========================
R_TransformModelToClipMVP
==========================
*/
/*
static void R_TransformModelToClipMVP( const vec3_t src, const float *mvp, vec4_t clip ) {
int i;
for (i = 0; i < 4; i++) {
clip[i] =
src[0] * mvp[i + 0 * 4] +
src[1] * mvp[i + 1 * 4] +
src[2] * mvp[i + 2 * 4] +
1 * mvp[i + 3 * 4];
}
}*/

/*
==========================
R_TransformClipToWindow
Expand Down Expand Up @@ -1050,79 +1032,6 @@ static qboolean SurfIsOffscreen( const drawSurf_t *drawSurf, vec4_t clipDest[128
return qfalse;
}

#if 0
/*
================
R_GetModelViewBounds
================
*/
static void R_GetModelViewBounds( int *mins, int *maxs )
{
float minn[2];
float maxn[2];
float norm[2];
float mvp[16];
float dist[4];
vec4_t clip;
int i, j;

minn[0] = minn[1] = 1.0;
maxn[0] = maxn[1] = -1.0;

// premultiply
myGlMultMatrix(tr.ori.modelMatrix, tr.viewParms.projectionMatrix, mvp);

for (i = 0; i < tess.numVertexes; i++) {
R_TransformModelToClipMVP(tess.xyz[i], mvp, clip);
if (clip[3] <= 0.0) {
dist[0] = DotProduct(tess.xyz[i], tr.viewParms.frustum[0].normal) - tr.viewParms.frustum[0].dist; // right
dist[1] = DotProduct(tess.xyz[i], tr.viewParms.frustum[1].normal) - tr.viewParms.frustum[1].dist; // left
dist[2] = DotProduct(tess.xyz[i], tr.viewParms.frustum[2].normal) - tr.viewParms.frustum[2].dist; // bottom
dist[3] = DotProduct(tess.xyz[i], tr.viewParms.frustum[3].normal) - tr.viewParms.frustum[3].dist; // top
if (dist[0] <= 0 && dist[1] <= 0) {
if (dist[0] < dist[1]) {
maxn[0] = 1.0f;
}
else {
minn[0] = -1.0f;
}
}
else {
if (dist[0] <= 0) maxn[0] = 1.0f;
if (dist[1] <= 0) minn[0] = -1.0f;
}
if (dist[2] <= 0 && dist[3] <= 0) {
if (dist[2] < dist[3])
minn[1] = -1.0f;
else
maxn[1] = 1.0f;
}
else {
if (dist[2] <= 0) minn[1] = -1.0f;
if (dist[3] <= 0) maxn[1] = 1.0f;
}
}
else {
for (j = 0; j < 2; j++) {
if (clip[j] > clip[3]) clip[j] = clip[3]; else
if (clip[j] < -clip[3]) clip[j] = -clip[3];
}
norm[0] = clip[0] / clip[3];
norm[1] = clip[1] / clip[3];
for (j = 0; j < 2; j++) {
if (norm[j] < minn[j]) minn[j] = norm[j];
if (norm[j] > maxn[j]) maxn[j] = norm[j];
}
}
}

mins[0] = (int)(-0.5 + 0.5 * (1.0 + minn[0]) * tr.viewParms.viewportWidth);
mins[1] = (int)(-0.5 + 0.5 * (1.0 + minn[1]) * tr.viewParms.viewportHeight);
maxs[0] = (int)(0.5 + 0.5 * (1.0 + maxn[0]) * tr.viewParms.viewportWidth);
maxs[1] = (int)(0.5 + 0.5 * (1.0 + maxn[1]) * tr.viewParms.viewportHeight);
}
#endif

/*
========================
R_MirrorViewBySurface
Expand Down Expand Up @@ -1174,18 +1083,6 @@ static qboolean R_MirrorViewBySurface( const drawSurf_t *drawSurf, int entityNum
}
#endif

#if 0
// causing artifacts with mirrors.
if (tess.numVertexes > 2 && r_fastsky->integer && vk.fastSky) {
int mins[2], maxs[2];
R_GetModelViewBounds(mins, maxs);
newParms.scissorX = newParms.viewportX + mins[0];
newParms.scissorY = newParms.viewportY + mins[1];
newParms.scissorWidth = maxs[0] - mins[0];
newParms.scissorHeight = maxs[1] - mins[1];
}
#endif

R_MirrorPoint(oldParms.ori.origin, &surface, &camera, newParms.ori.origin);

VectorSubtract(vec3_origin, camera.axis[0], newParms.portalPlane.normal);
Expand Down
Loading

0 comments on commit c7590df

Please sign in to comment.