Skip to content

Commit

Permalink
Calc vertex buffer size after removing sky faces.
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/refresh/surf.c
  • Loading branch information
skullernet authored and Paril committed Dec 20, 2024
1 parent 800a7bc commit 90473c8
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/refresh/surf.c
Original file line number Diff line number Diff line change
Expand Up @@ -1148,19 +1148,20 @@ void GL_LoadWorld(const char *name)
}
}

// calculate vertex buffer size in bytes
size = 0;
// setup drawflags, etc
for (i = n64surfs = 0, surf = bsp->faces; i < bsp->numfaces; i++, surf++) {
// hack surface flags into drawflags for faster access
surf->drawflags |= surf->texinfo->c.flags & ~DSURF_PLANEBACK;

// clear statebits from previous load
surf->statebits = GLS_DEFAULT;

// don't count sky surfaces
// don't count sky surfaces unless using cubemaps
if (surf->drawflags & SURF_SKY) {
if (!gl_static.use_cubemaps)
if (!gl_static.use_cubemaps) {
surf->drawflags |= SURF_NODRAW; // simplify other code
continue;
}
surf->drawflags &= ~SURF_NODRAW;
}

Expand All @@ -1173,14 +1174,17 @@ void GL_LoadWorld(const char *name)

if (surf->drawflags & SURF_N64_UV)
n64surfs++;

size += surf->numsurfedges * VERTEX_SIZE * sizeof(vec_t);
}

// remove fake sky faces in vanilla maps
if (!bsp->has_bspx && gl_static.use_cubemaps)
remove_fake_sky_faces(bsp);

// calculate vertex buffer size in bytes
for (i = size = 0, surf = bsp->faces; i < bsp->numfaces; i++, surf++)
if (!(surf->drawflags & SURF_NODRAW))
size += surf->numsurfedges * VERTEX_SIZE * sizeof(vec_t);

// try VBO first, then allocate on heap
if (create_surface_vbo(size)) {
Com_DPrintf("%s: %zu bytes of vertex data as VBO\n", __func__, size);
Expand Down

0 comments on commit 90473c8

Please sign in to comment.