Skip to content

Commit

Permalink
Calc vertex buffer size after removing sky faces.
Browse files Browse the repository at this point in the history
  • Loading branch information
skullernet committed Nov 30, 2024
1 parent 945ee65 commit b55563e
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/refresh/surf.c
Original file line number Diff line number Diff line change
Expand Up @@ -895,8 +895,6 @@ static void upload_world_surfaces(void)
currvert = 0;
lastvert = 0;
for (i = 0, surf = bsp->faces; i < bsp->numfaces; i++, surf++) {
if (surf->drawflags & SURF_SKY && !gl_static.use_cubemaps)
continue;
if (surf->drawflags & SURF_NODRAW)
continue;

Expand Down Expand Up @@ -1127,19 +1125,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 @@ -1152,14 +1151,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 b55563e

Please sign in to comment.