Skip to content

Commit

Permalink
Minor fix-ups
Browse files Browse the repository at this point in the history
  • Loading branch information
VReaperV committed Feb 5, 2025
1 parent c2c8487 commit 635926f
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 26 deletions.
7 changes: 3 additions & 4 deletions src/engine/renderer/GeometryCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
// GeometryCache.cpp

#include "common/Common.h"

#include "GeometryCache.h"

#include "tr_local.h"
Expand All @@ -59,9 +61,6 @@ void GeometryCache::FreeGLBuffers() {
VAO.DelVAO();
}

void GeometryCache::Free() {
}

void GeometryCache::AllocBuffers() {
VBO.BufferData( mapVerticesNumber * 8, nullptr, GL_STATIC_DRAW );

Expand Down Expand Up @@ -89,7 +88,7 @@ void GeometryCache::AddMapGeometry( const uint32_t verticesNumber, const uint32_
for ( const vertexAttributeSpec_t* spec = attrBegin; spec < attrEnd; spec++ ) {
vboAttributeLayout_t& attr = VAO.attrs[spec->attrIndex];

CopyVertexAttribute( attr, *spec, mapVerticesNumber, ( byte* ) VBOVerts );
R_CopyVertexAttribute( attr, *spec, mapVerticesNumber, ( byte* ) VBOVerts );
}
VBO.UnmapBuffer();

Expand Down
2 changes: 0 additions & 2 deletions src/engine/renderer/GeometryCache.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ class GeometryCache {
void InitGLBuffers();
void FreeGLBuffers();

void Free();

void AllocBuffers();
void AddMapGeometry( const uint32_t verticesNumber, const uint32_t indicesNumber,
const vertexAttributeSpec_t* attrBegin,
Expand Down
3 changes: 1 addition & 2 deletions src/engine/renderer/gl_shader.h
Original file line number Diff line number Diff line change
Expand Up @@ -1552,7 +1552,6 @@ class GLVAO {
for ( const vertexAttributeSpec_t* spec = attrBegin; spec < attrEnd; spec++ ) {
vboAttributeLayout_t& attr = attrs[spec->attrIndex];
ASSERT_NQ( spec->numComponents, 0U );
// vbo->attribBits |= 1 << spec->attrIndex;
attr.componentType = spec->componentStorageType;
if ( attr.componentType == GL_HALF_FLOAT && !glConfig2.halfFloatVertexAvailable ) {
attr.componentType = GL_FLOAT;
Expand All @@ -1561,7 +1560,7 @@ class GLVAO {
attr.normalize = spec->attrOptions & ATTR_OPTION_NORMALIZE ? GL_TRUE : GL_FALSE;

attr.ofs = ofs;
ofs += attr.numComponents * ComponentSize( attr.componentType );
ofs += attr.numComponents * R_ComponentSize( attr.componentType );
ofs = ( ofs + 3 ) & ~3; // 4 is minimum alignment for any vertex attribute

enabledAttrs |= 1 << spec->attrIndex;
Expand Down
6 changes: 0 additions & 6 deletions src/engine/renderer/tr_init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Cvar::Cvar<bool> r_gpuFrustumCulling( "r_gpuFrustumCulling", "Use frustum culling on the GPU for the Material System", Cvar::NONE, true );
Cvar::Cvar<bool> r_gpuOcclusionCulling( "r_gpuOcclusionCulling", "Use occlusion culling on the GPU for the Material System", Cvar::NONE, false );
Cvar::Cvar<bool> r_materialSystemSkip( "r_materialSystemSkip", "Temporarily skip Material System rendering, using only core renderer instead", Cvar::NONE, false );
Cvar::Cvar<bool> r_geometryCache( "r_geometryCache", "Use Geometry Cache", Cvar::NONE, true );
cvar_t *r_lightStyles;
cvar_t *r_exportTextures;
cvar_t *r_heatHaze;
Expand Down Expand Up @@ -1240,7 +1239,6 @@ ScreenshotCmd screenshotPNGRegistration("screenshotPNG", ssFormat_t::SSF_PNG, "p
Cvar::Latch( r_realtimeLightLayers );
Cvar::Latch( r_preferBindlessTextures );
Cvar::Latch( r_materialSystem );
Cvar::Latch( r_geometryCache );

r_drawworld = Cvar_Get( "r_drawworld", "1", CVAR_CHEAT );
r_max_portal_levels = Cvar_Get( "r_max_portal_levels", "5", 0 );
Expand Down Expand Up @@ -1570,10 +1568,6 @@ ScreenshotCmd screenshotPNGRegistration("screenshotPNG", ssFormat_t::SSF_PNG, "p
materialSystem.Free();
}

if ( glConfig2.usingGeometryCache ) {
geometryCache.Free();
}

// shut down platform specific OpenGL stuff
if ( destroyWindow )
{
Expand Down
5 changes: 2 additions & 3 deletions src/engine/renderer/tr_local.h
Original file line number Diff line number Diff line change
Expand Up @@ -2966,7 +2966,6 @@ enum class shaderProfilerRenderSubGroupsMode {
extern Cvar::Cvar<bool> r_gpuFrustumCulling;
extern Cvar::Cvar<bool> r_gpuOcclusionCulling;
extern Cvar::Cvar<bool> r_materialSystemSkip;
extern Cvar::Cvar<bool> r_geometryCache;
extern cvar_t *r_lightStyles;
extern cvar_t *r_exportTextures;
extern cvar_t *r_heatHaze;
Expand Down Expand Up @@ -3716,8 +3715,8 @@ inline bool checkGLErrors()
============================================================
*/
uint32_t ComponentSize( GLenum type );
void CopyVertexAttribute( const vboAttributeLayout_t& attrib, const vertexAttributeSpec_t& spec,
uint32_t R_ComponentSize( GLenum type );
void R_CopyVertexAttribute( const vboAttributeLayout_t& attrib, const vertexAttributeSpec_t& spec,
uint32_t count, byte* interleavedData );

VBO_t *R_CreateStaticVBO(
Expand Down
3 changes: 1 addition & 2 deletions src/engine/renderer/tr_shade.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,7 @@ static void EnableAvailableFeatures()
glConfig2.usingMaterialSystem = r_materialSystem.Get() && glConfig2.materialSystemAvailable;
glConfig2.usingBindlessTextures = glConfig2.usingMaterialSystem ||
( r_preferBindlessTextures.Get() && glConfig2.bindlessTexturesAvailable );
glConfig2.usingGeometryCache = glConfig2.usingMaterialSystem
|| ( r_geometryCache.Get() && glConfig2.geometryCacheAvailable );
glConfig2.usingGeometryCache = glConfig2.usingMaterialSystem && glConfig2.geometryCacheAvailable;
}

// For shaders that require map data for compile-time values
Expand Down
14 changes: 7 additions & 7 deletions src/engine/renderer/tr_vbo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ static void R_SetVBOAttributeLayouts( VBO_t *vbo )
}
}

uint32_t ComponentSize( GLenum type )
uint32_t R_ComponentSize( GLenum type )
{
switch ( type )
{
Expand All @@ -91,7 +91,7 @@ uint32_t ComponentSize( GLenum type )
return 4;
}

Sys::Error( "VBO ComponentSize: unknown type %d", type );
Sys::Error( "VBO R_ComponentSize: unknown type %d", type );
}

#if defined( GL_ARB_buffer_storage ) && defined( GL_ARB_sync )
Expand Down Expand Up @@ -209,7 +209,7 @@ VBO_t *R_CreateDynamicVBO( const char *name, int numVertexes, uint32_t stateBits
return vbo;
}

void CopyVertexAttribute(
void R_CopyVertexAttribute(
const vboAttributeLayout_t &attrib, const vertexAttributeSpec_t &spec,
uint32_t count, byte *interleavedData )
{
Expand All @@ -226,7 +226,7 @@ void CopyVertexAttribute(

if ( attrib.componentType == spec.componentInputType )
{
uint32_t size = attrib.numComponents * ComponentSize( attrib.componentType );
uint32_t size = attrib.numComponents * R_ComponentSize( attrib.componentType );

for ( uint32_t v = count; ; )
{
Expand Down Expand Up @@ -333,7 +333,7 @@ VBO_t *R_CreateStaticVBO(

uint32_t &ofs = spec->attrOptions & ATTR_OPTION_HAS_FRAMES ? ofsFrameful : ofsFrameless;
attrib.ofs = ofs;
ofs += attrib.numComponents * ComponentSize( attrib.componentType );
ofs += attrib.numComponents * R_ComponentSize( attrib.componentType );
ofs = ( ofs + 3 ) & ~3; // 4 is minimum alignment for any vertex attribute
}

Expand All @@ -353,12 +353,12 @@ VBO_t *R_CreateStaticVBO(
attrib.stride = ofsFrameful;
attrib.frameOffset = numVerts * ofsFrameful;
attrib.ofs += framelessSize;
CopyVertexAttribute( attrib, *spec, numVerts * numFrames, interleavedData );
R_CopyVertexAttribute( attrib, *spec, numVerts * numFrames, interleavedData );
}
else
{
attrib.stride = ofsFrameless;
CopyVertexAttribute( attrib, *spec, numVerts, interleavedData );
R_CopyVertexAttribute( attrib, *spec, numVerts, interleavedData );
}
}

Expand Down

0 comments on commit 635926f

Please sign in to comment.