Skip to content

Commit

Permalink
Show model names in /listVBOs command
Browse files Browse the repository at this point in the history
Also don't quit if the model name is bigger than the buffer. It doesn't
really matter.
  • Loading branch information
slipher committed Aug 7, 2024
1 parent 293f1e2 commit 7b4d9bb
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 44 deletions.
4 changes: 2 additions & 2 deletions src/engine/renderer/tr_local.h
Original file line number Diff line number Diff line change
Expand Up @@ -736,7 +736,7 @@ enum class dynamicLightRenderer_t { LEGACY, TILED };

struct VBO_t
{
char name[ MAX_QPATH ];
char name[ 96 ]; // only for debugging with /listVBOs

uint32_t vertexesVBO;

Expand All @@ -754,7 +754,7 @@ enum class dynamicLightRenderer_t { LEGACY, TILED };

struct IBO_t
{
char name[ MAX_QPATH ];
char name[ 96 ]; // only for debugging with /listVBOs

uint32_t indexesVBO;
uint32_t indexesSize; // amount of memory data allocated for all triangles in bytes
Expand Down
6 changes: 4 additions & 2 deletions src/engine/renderer/tr_model_iqm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -808,15 +808,17 @@ bool R_LoadIQModel( model_t *mod, const void *buffer, int filesize,
vboData.boneWeights = (vec4_t *)weightbuf;
vboData.numVerts = IQModel->num_vertexes;

vbo = R_CreateStaticVBO( "IQM surface VBO", vboData,
std::string name = mod->name;
vbo = R_CreateStaticVBO( ( "IQM surface VBO " + name ).c_str(), vboData,
vboLayout_t::VBO_LAYOUT_SKELETAL );

ri.Hunk_FreeTempMemory( qtangentbuf );
ri.Hunk_FreeTempMemory( weightbuf );
ri.Hunk_FreeTempMemory( indexbuf );

// create IBO
ibo = R_CreateStaticIBO( "IQM surface IBO", ( glIndex_t* )IQModel->triangles, IQModel->num_triangles * 3 );
ibo = R_CreateStaticIBO( ( "IQM surface IBO " + name ).c_str(),
( glIndex_t* )IQModel->triangles, IQModel->num_triangles * 3 );
} else {
vbo = nullptr;
ibo = nullptr;
Expand Down
5 changes: 3 additions & 2 deletions src/engine/renderer/tr_model_md3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,8 @@ bool R_LoadMD3( model_t *mod, int lod, const void *buffer, const char *modName )
vboSurf->numIndexes = surf->numTriangles * 3;
vboSurf->numVerts = surf->numVerts;

vboSurf->vbo = R_CreateStaticVBO( va( "staticMD3Mesh_VBO '%s'", surf->name ), data, vboLayout_t::VBO_LAYOUT_VERTEX_ANIMATION );
std::string name = Str::Format( "%s '%s'", modName , surf->name );
vboSurf->vbo = R_CreateStaticVBO( ( "MD3 surface VBO " + name ).c_str(), data, vboLayout_t::VBO_LAYOUT_VERTEX_ANIMATION );

// MD3 does not have color, but shaders always request it and the "vertex animation"
// vertex layout includes a color field, which is zeroed by default.
Expand All @@ -360,7 +361,7 @@ bool R_LoadMD3( model_t *mod, int lod, const void *buffer, const char *modName )
indexes[ f++ ] = surf->triangles[ j ].indexes[ k ];
}
}
vboSurf->ibo = R_CreateStaticIBO2( va( "staticMD3Mesh_IBO %s", surf->name ), surf->numTriangles, indexes );
vboSurf->ibo = R_CreateStaticIBO2( ( "MD3 surface IBO " + name ).c_str(), surf->numTriangles, indexes );

ri.Hunk_FreeTempMemory(indexes);
}
Expand Down
4 changes: 3 additions & 1 deletion src/engine/renderer/tr_model_md5.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,9 @@ bool R_LoadMD5( model_t *mod, const char *buffer, const char *modName )
break;
}

R_AddSurfaceToVBOSurfacesList( vboSurfaces, vboTriangles, md5, surf, i, boneReferences );
std::string name = Str::Format( "%s %d", modName, vboSurfaces.size() );
vboSurfaces.push_back( R_GenerateMD5VBOSurface(
name, vboTriangles, md5, surf, i, boneReferences ) );
numRemaining -= vboTriangles.size();
}
}
Expand Down
11 changes: 6 additions & 5 deletions src/engine/renderer/tr_model_skel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ bool R_AddTriangleToVBOTriangleList(
return hasWeights;
}

void R_AddSurfaceToVBOSurfacesList(
std::vector<srfVBOMD5Mesh_t *> &vboSurfaces, const std::vector<skelTriangle_t> &vboTriangles,
srfVBOMD5Mesh_t *R_GenerateMD5VBOSurface(
Str::StringRef surfName, const std::vector<skelTriangle_t> &vboTriangles,
md5Model_t *md5, md5Surface_t *surf, int skinIndex, int boneReferences[ MAX_BONES ] )
{
int j;
Expand All @@ -110,7 +110,6 @@ void R_AddSurfaceToVBOSurfacesList(

// create surface
vboSurf = (srfVBOMD5Mesh_t*) ri.Hunk_Alloc( sizeof( *vboSurf ), ha_pref::h_low );
vboSurfaces.push_back( vboSurf );

vboSurf->surfaceType = surfaceType_t::SF_VBO_MD5MESH;
vboSurf->md5Model = md5;
Expand Down Expand Up @@ -178,9 +177,9 @@ void R_AddSurfaceToVBOSurfacesList(
}
}

vboSurf->vbo = R_CreateStaticVBO( va( "staticMD5Mesh_VBO %i", ( int )vboSurfaces.size() ), data, vboLayout_t::VBO_LAYOUT_SKELETAL );
vboSurf->vbo = R_CreateStaticVBO( ( "MD5 surface VBO " + surfName ).c_str(), data, vboLayout_t::VBO_LAYOUT_SKELETAL );

vboSurf->ibo = R_CreateStaticIBO( va( "staticMD5Mesh_IBO %i", ( int )vboSurfaces.size() ), indexes, indexesNum );
vboSurf->ibo = R_CreateStaticIBO( ( "MD5 surface IBO " + surfName ).c_str(), indexes, indexesNum );

// MD5 does not have color, but shaders always request it and the skeletal animation
// vertex layout includes a color field, which is zeroed by default.
Expand All @@ -192,4 +191,6 @@ void R_AddSurfaceToVBOSurfacesList(
ri.Hunk_FreeTempMemory( data.boneIndexes );
ri.Hunk_FreeTempMemory( data.qtangent );
ri.Hunk_FreeTempMemory( data.xyz );

return vboSurf;
}
4 changes: 2 additions & 2 deletions src/engine/renderer/tr_model_skel.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
bool R_AddTriangleToVBOTriangleList(
const skelTriangle_t *tri, int *numBoneReferences, int boneReferences[ MAX_BONES ] );

void R_AddSurfaceToVBOSurfacesList(
std::vector<srfVBOMD5Mesh_t *> &vboSurfaces, const std::vector<skelTriangle_t> &vboTriangles,
srfVBOMD5Mesh_t *R_GenerateMD5VBOSurface(
Str::StringRef surfName, const std::vector<skelTriangle_t> &vboTriangles,
md5Model_t *md5, md5Surface_t *surf, int skinIndex, int boneReferences[ MAX_BONES ] );

#endif // TR_MODEL_SKEL_H
30 changes: 0 additions & 30 deletions src/engine/renderer/tr_vbo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -471,11 +471,6 @@ VBO_t *R_CreateDynamicVBO( const char *name, int numVertexes, uint32_t stateBits
return nullptr;
}

if ( strlen( name ) >= MAX_QPATH )
{
Sys::Drop( "R_CreateDynamicVBO: \"%s\" is too long", name );
}

// make sure the render thread is stopped
R_SyncRenderThread();

Expand Down Expand Up @@ -522,11 +517,6 @@ R_CreateVBO
*/
VBO_t *R_CreateStaticVBO( const char *name, vboData_t data, vboLayout_t layout )
{
if ( strlen( name ) >= MAX_QPATH )
{
Sys::Drop( "R_CreateVBO: \"%s\" is too long", name );
}

// make sure the render thread is stopped
R_SyncRenderThread();

Expand Down Expand Up @@ -586,11 +576,6 @@ VBO_t *R_CreateStaticVBO2( const char *name, int numVertexes, shaderVertex_t *ve
return nullptr;
}

if ( strlen( name ) >= MAX_QPATH )
{
Sys::Drop( "R_CreateVBO2: \"%s\" is too long", name );
}

// make sure the render thread is stopped
R_SyncRenderThread();

Expand Down Expand Up @@ -639,11 +624,6 @@ IBO_t *R_CreateDynamicIBO( const char *name, int numIndexes )
{
IBO_t *ibo;

if ( strlen( name ) >= MAX_QPATH )
{
Sys::Drop( "R_CreateIBO: \"%s\" is too long", name );
}

// make sure the render thread is stopped
R_SyncRenderThread();

Expand Down Expand Up @@ -689,11 +669,6 @@ IBO_t *R_CreateStaticIBO( const char *name, glIndex_t *indexes, int numIndexes )
return nullptr;
}

if ( strlen( name ) >= MAX_QPATH )
{
Sys::Drop( "R_CreateIBO: \"%s\" is too long", name );
}

// make sure the render thread is stopped
R_SyncRenderThread();

Expand Down Expand Up @@ -733,11 +708,6 @@ IBO_t *R_CreateStaticIBO2( const char *name, int numTriangles, glIndex_t *indexe
return nullptr;
}

if ( strlen( name ) >= MAX_QPATH )
{
Sys::Drop( "R_CreateIBO2: \"%s\" is too long", name );
}

// make sure the render thread is stopped
R_SyncRenderThread();

Expand Down

0 comments on commit 7b4d9bb

Please sign in to comment.