Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions renderers/vulkan/tr_animation.c
Original file line number Diff line number Diff line change
Expand Up @@ -411,9 +411,6 @@ void RB_MDRSurfaceAnim( mdrSurface_t *surface )
tempVert[1] += w->boneWeight * ( DotProduct( bone->matrix[1], w->offset ) + bone->matrix[1][3] );
tempVert[2] += w->boneWeight * ( DotProduct( bone->matrix[2], w->offset ) + bone->matrix[2][3] );

#ifdef USE_TESS_NEEDS_NORMAL
if ( tess.needsNormal )
#endif
{
tempNormal[0] += w->boneWeight * DotProduct( bone->matrix[0], v->normal );
tempNormal[1] += w->boneWeight * DotProduct( bone->matrix[1], v->normal );
Expand All @@ -425,9 +422,6 @@ void RB_MDRSurfaceAnim( mdrSurface_t *surface )
tess.xyz[baseVertex + j][1] = tempVert[1];
tess.xyz[baseVertex + j][2] = tempVert[2];

#ifdef USE_TESS_NEEDS_NORMAL
if ( tess.needsNormal )
#endif
{
tess.normal[baseVertex + j][0] = tempNormal[0];
tess.normal[baseVertex + j][1] = tempNormal[1];
Expand Down
35 changes: 5 additions & 30 deletions renderers/vulkan/tr_local.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,10 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#define TR_LOCAL_H

#define USE_VK_PBR
#ifdef USE_VK_PBR
#define VK_PBR_BRDFLUT // for inspecting codebase, does not toggle brdflut.
#define VK_CUBEMAP

#ifdef VK_CUBEMAP
#define REF_CUBEMAP_IRRADIANCE_SIZE 64
#define REF_CUBEMAP_SIZE 256
#endif
#endif
#define VK_PBR_BRDFLUT // for inspecting codebase, does not toggle brdflut.
#define VK_CUBEMAP
#define REF_CUBEMAP_IRRADIANCE_SIZE 64
#define REF_CUBEMAP_SIZE 256

#define USE_VBO // store static world geometry in VBO
#define USE_FOG_COLLAPSE // not compatible with legacy dlights
Expand All @@ -42,13 +37,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA

#define MAX_TEXTURE_SIZE 32768

#ifdef USE_VBO
#define USE_VBO_GRID /* put SF_GRID to VBO */
#endif

//#define USE_TESS_NEEDS_NORMAL
//#define USE_TESS_NEEDS_ST2

#define SH_COEFF_COUNT 9

#include "../../qcommon/q_shared.h"
Expand Down Expand Up @@ -856,11 +844,7 @@ typedef struct srfGridMesh_s {
srfVert_t verts[1]; // variable sized
} srfGridMesh_t;

#ifdef USE_VK_PBR
#define VERTEXSIZE 11
#else
#define VERTEXSIZE 8
#endif
#define VERTEXSIZE 11
typedef struct {
surfaceType_t surfaceType;
cplane_t plane;
Expand Down Expand Up @@ -2054,9 +2038,7 @@ image_t *vk_create_pbr_albedo_srgb( const char *albedoMapName, imgFlags_t flags
//
// tr_surface.c
//
#ifdef USE_VBO_GRID
void RB_SurfaceGridEstimate( srfGridMesh_t *cv, int *numVertexes, int *numIndexes );
#endif

/*
====================================================================
Expand Down Expand Up @@ -2123,13 +2105,6 @@ typedef struct shaderCommands_s
#endif

// info extracted from current shader
#ifdef USE_TESS_NEEDS_NORMAL
int needsNormal;
#endif
#ifdef USE_TESS_NEEDS_ST2
int needsST2;
#endif

int numPasses;
shaderStage_t **xstages;

Expand Down
3 changes: 0 additions & 3 deletions renderers/vulkan/tr_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1079,9 +1079,6 @@ static qboolean SurfIsOffscreen( const drawSurf_t *drawSurf, qboolean *isMirror
RB_BeginSurface( shader, fogNum );
#ifdef USE_VBO
tess.allowVBO = qfalse;
#endif
#ifdef USE_TESS_NEEDS_NORMAL
tess.needsNormal = qtrue;
#endif
rb_surfaceTable[ *drawSurf->surface ]( drawSurf->surface );

Expand Down
12 changes: 0 additions & 12 deletions renderers/vulkan/tr_shade.c
Original file line number Diff line number Diff line change
Expand Up @@ -389,18 +389,6 @@ void RB_BeginSurface( shader_t *shader, int fogNum ) {
tess.dlightUpdateParams = qtrue;
}

#ifdef USE_TESS_NEEDS_NORMAL
tess.needsNormal = state->needsNormal || tess.dlightPass || r_shownormals->integer ||
( backEnd.currentEntity == &tr.worldEntity &&
( ( r_shDebugView && r_shDebugView->integer ) ||
( r_shWorldLighting && r_shWorldLighting->integer && r_shLighting && r_shLighting->integer &&
!R_ClassicLightingActive() ) ) );
#endif

#ifdef USE_TESS_NEEDS_ST2
tess.needsST2 = state->needsST2;
#endif

tess.numIndexes = 0;
tess.numVertexes = 0;
tess.sdfUiEdge = -1.0f;
Expand Down
71 changes: 2 additions & 69 deletions renderers/vulkan/tr_surface.c
Original file line number Diff line number Diff line change
Expand Up @@ -389,10 +389,8 @@ static void RB_SurfaceTriangles( const srfTriangles_t *srf ) {
int i;
const srfVert_t *dv;
float *xyz, *normal;
#ifdef USE_VK_PBR
float *qtangent;
float *lightdir;
#endif
float *texCoords0;
float *texCoords1;
uint32_t *color;
Expand Down Expand Up @@ -426,10 +424,8 @@ static void RB_SurfaceTriangles( const srfTriangles_t *srf ) {
dv = srf->verts;
xyz = tess.xyz[ tess.numVertexes ];
normal = tess.normal[ tess.numVertexes ];
#ifdef USE_VK_PBR
qtangent = tess.qtangent[ tess.numVertexes ];
lightdir = tess.lightdir[ tess.numVertexes ];
#endif
texCoords0 = tess.texCoords[0][ tess.numVertexes ];
texCoords1 = tess.texCoords[1][ tess.numVertexes ];
color = &tess.vertexColors[ tess.numVertexes ].u32;
Expand All @@ -439,16 +435,12 @@ static void RB_SurfaceTriangles( const srfTriangles_t *srf ) {
xyz[1] = dv->xyz[1];
xyz[2] = dv->xyz[2];

#ifdef USE_TESS_NEEDS_NORMAL
if ( tess.needsNormal )
#endif
{
normal[0] = dv->normal[0];
normal[1] = dv->normal[1];
normal[2] = dv->normal[2];
}

#ifdef USE_VK_PBR
if( vk.pbrActive ) {
qtangent[0] = dv->qtangent[0];
qtangent[1] = dv->qtangent[1];
Expand All @@ -462,14 +454,10 @@ static void RB_SurfaceTriangles( const srfTriangles_t *srf ) {
lightdir[3] = 0.0;
lightdir += 4;
}
#endif

texCoords0[0] = dv->st[0];
texCoords0[1] = dv->st[1];

#ifdef USE_TESS_NEEDS_ST2
if ( tess.needsST2 )
#endif
{
texCoords1[0] = dv->lightmap[0];
texCoords1[1] = dv->lightmap[1];
Expand Down Expand Up @@ -1011,9 +999,6 @@ static void RB_SurfaceFace( const srfSurfaceFace_t *surf ) {

numPoints = surf->numPoints;

#ifdef USE_TESS_NEEDS_NORMAL
if ( tess.needsNormal )
#endif
{
if ( surf->normals ) {
// per-vertex normals for non-coplanar faces
Expand All @@ -1026,23 +1011,17 @@ static void RB_SurfaceFace( const srfSurfaceFace_t *surf ) {
}
}

#ifdef USE_VK_PBR
if( vk.pbrActive && surf->qtangents )
memcpy( &tess.qtangent[ tess.numVertexes ], surf->qtangents, numPoints * sizeof( vec4_t ) );

if( vk.pbrActive && surf->lightdir )
memcpy( &tess.lightdir[ tess.numVertexes ], surf->lightdir, numPoints * sizeof( vec4_t ) );
#endif

for ( i = 0, v = surf->points[0], ndx = tess.numVertexes; i < numPoints; i++, v += VERTEXSIZE, ndx++ ) {
VectorCopy( v, tess.xyz[ndx]);

#ifdef USE_VK_PBR
tess.texCoords[0][ndx][0] = v[6];
tess.texCoords[0][ndx][1] = v[7];
#ifdef USE_TESS_NEEDS_ST2
if ( tess.needsST2 )
#endif
{
tess.texCoords[1][ndx][0] = v[8];
tess.texCoords[1][ndx][1] = v[9];
Expand All @@ -1052,22 +1031,6 @@ static void RB_SurfaceFace( const srfSurfaceFace_t *surf ) {
Com_Memcpy( &color, &v[10], sizeof( color ) );
Com_Memcpy( &tess.vertexColors[ndx], &color, sizeof( color ) );
}
#else
tess.texCoords[0][ndx][0] = v[3];
tess.texCoords[0][ndx][1] = v[4];
#ifdef USE_TESS_NEEDS_ST2
if ( tess.needsST2 )
#endif
{
tess.texCoords[1][ndx][0] = v[5];
tess.texCoords[1][ndx][1] = v[6];
}
{
uint32_t color;
Com_Memcpy( &color, &v[7], sizeof( color ) );
Com_Memcpy( &tess.vertexColors[ndx], &color, sizeof( color ) );
}
#endif

tess.vertexDlightBits[ndx] = dlightBits;
}
Expand Down Expand Up @@ -1106,7 +1069,6 @@ static float LodErrorForVolume( vec3_t local, float radius ) {
return r_lodCurveError->value / d;
}

#ifdef USE_VBO_GRID
void RB_SurfaceGridEstimate( srfGridMesh_t *cv, int *numVertexes, int *numIndexes )
{
int lodWidth, lodHeight;
Expand Down Expand Up @@ -1170,7 +1132,6 @@ void RB_SurfaceGridEstimate( srfGridMesh_t *cv, int *numVertexes, int *numIndexe
tess.numVertexes = 0;
tess.numIndexes = 0;
}
#endif // USE_VBO_GRID

/*
=============
Expand All @@ -1185,10 +1146,8 @@ static void RB_SurfaceGrid( srfGridMesh_t *cv ) {
float *texCoords0;
float *texCoords1;
float *normal;
#ifdef USE_VK_PBR
float *qtangent;
float *lightdir;
#endif
uint32_t *color;
srfVert_t *dv;
int rows, irows, vrows;
Expand All @@ -1201,30 +1160,22 @@ static void RB_SurfaceGrid( srfGridMesh_t *cv ) {
int dlightBits;
int *vDlightBits;

#ifdef USE_VBO_GRID
if ( tess.allowVBO && cv->vboItemIndex && !cv->dlightBits &&
RB_QueueSurfaceVBO( cv->vboItemIndex, SF_GRID ) ) {
return;
}

VBO_Flush();
#else
#ifdef USE_VBO
VBO_Flush();
#endif
#endif

dlightBits = cv->dlightBits;
tess.dlightBits |= dlightBits;

#ifdef USE_VBO_GRID
tess.surfType = SF_GRID;

// determine the allowable discrepance
if ( cv->vboItemIndex && ( tr.mapLoading || ( tess.dlightPass && tess.shader->isStaticShader ) ) )
lodError = r_lodCurveError->value; // fixed quality for VBO
else
#endif // USE_VBO_GRID
lodError = LodErrorForVolume( cv->lodOrigin, cv->lodRadius );

// determine which rows and columns of the subdivision
Expand Down Expand Up @@ -1265,13 +1216,11 @@ static void RB_SurfaceGrid( srfGridMesh_t *cv ) {
if ( vrows < 2 || irows < 1 ) {
if ( tr.mapLoading ) {
// estimate and flush
#ifdef USE_VBO_GRID
if ( cv->vboItemIndex ) {
VBO_PushData( cv->vboItemIndex, &tess );
tess.numIndexes = 0;
tess.numVertexes = 0;
} else
#endif // USE_VBO_GRID
ri.Error( ERR_DROP, "Unexpected grid flush during map loading!\n" );
} else {
RB_EndSurface();
Expand All @@ -1294,10 +1243,8 @@ static void RB_SurfaceGrid( srfGridMesh_t *cv ) {

xyz = tess.xyz[numVertexes];
normal = tess.normal[numVertexes];
#ifdef USE_VK_PBR
qtangent = tess.qtangent[numVertexes];
lightdir = tess.lightdir[numVertexes];
#endif
texCoords0 = tess.texCoords[0][numVertexes];
texCoords1 = tess.texCoords[1][numVertexes];
color = &tess.vertexColors[numVertexes].u32;
Expand All @@ -1312,25 +1259,18 @@ static void RB_SurfaceGrid( srfGridMesh_t *cv ) {
xyz[2] = dv->xyz[2];
texCoords0[0] = dv->st[0];
texCoords0[1] = dv->st[1];
#ifdef USE_TESS_NEEDS_ST2
if ( tess.needsST2 )
#endif
{
texCoords1[0] = dv->lightmap[0];
texCoords1[1] = dv->lightmap[1];
texCoords1 += 2;
}
#ifdef USE_TESS_NEEDS_NORMAL
if ( tess.needsNormal )
#endif
{
normal[0] = dv->normal[0];
normal[1] = dv->normal[1];
normal[2] = dv->normal[2];
normal += 4;
}

#ifdef USE_VK_PBR
if( vk.pbrActive ) {
qtangent[0] = dv->qtangent[0];
qtangent[1] = dv->qtangent[1];
Expand All @@ -1344,7 +1284,6 @@ static void RB_SurfaceGrid( srfGridMesh_t *cv ) {
lightdir[3] = 0.0;
lightdir += 4;
}
#endif

*color = dv->color.u32;
*vDlightBits++ = dlightBits;
Expand Down Expand Up @@ -1540,7 +1479,6 @@ static void RB_SurfaceSkip( void *surf ) {
(void)surf;
}

#ifdef USE_VK_PBR
/*
================
RB_GLTFRecomputeQtangentsForTessRange
Expand Down Expand Up @@ -1636,8 +1574,7 @@ static void RB_GLTFRecomputeQtangentsForTessRange( int vertBase, int numVerts, i

ri.Hunk_FreeTempMemory( btAcc );
ri.Hunk_FreeTempMemory( tanAcc );
}
#endif /* USE_VK_PBR */
} /* USE_VK_PBR */

/*
=============
Expand Down Expand Up @@ -1787,7 +1724,6 @@ void RB_GLTFSurface( const surfaceType_t *surface ) {
}
}

#ifdef USE_VK_PBR
if ( r_gltfGpu && r_gltfGpu->integer && vk.cmd && vk.pbrActive && tess.shader && tess.shader->hasPBR &&
surf->vbo_vertex != TR_GLTF_VBO_HANDLE_INVALID && surf->vbo_index != TR_GLTF_VBO_HANDLE_INVALID &&
( haveJoints || useMorph ) &&
Expand Down Expand Up @@ -1945,8 +1881,7 @@ void RB_GLTFSurface( const surfaceType_t *surface ) {
}
tess.gltfUseGpuPipeline = qfalse;
tess.gltfGpuMorphActive = qfalse;
tess.gltfGpuMorphCount = 0;
#endif /* USE_VK_PBR */
tess.gltfGpuMorphCount = 0; /* USE_VK_PBR */

if ( surf->vbo_vertex != TR_GLTF_VBO_HANDLE_INVALID && surf->vbo_index != TR_GLTF_VBO_HANDLE_INVALID ) {
/* VBO path: set gltfDrawSurface for vk_bind_geometry to use */
Expand Down Expand Up @@ -2062,11 +1997,9 @@ void RB_GLTFSurface( const surfaceType_t *surface ) {
tess.indexes[tess.numIndexes + j] = (glIndex_t)( base + surf->indices[j] );
}
tess.numIndexes += surf->numIndices;
#ifdef USE_VK_PBR
if ( vk.pbrActive && tess.shader && tess.shader->hasPBR ) {
RB_GLTFRecomputeQtangentsForTessRange( base, surf->numVertices, idxBase, surf->numIndices );
}
#endif
}
}

Expand Down
Loading
Loading