r_shadow_compilingrtlight->static_shadowmap_casters &= ~(1 << i);
}
+#define RSURF_MAX_BATCHSURFACES 8192
+
+static const msurface_t *batchsurfacelist[RSURF_MAX_BATCHSURFACES];
+
void R_Q1BSP_DrawShadowMap(int side, entity_render_t *ent, const vec3_t relativelightorigin, const vec3_t relativelightdirection, float lightradius, int modelnumsurfaces, const int *modelsurfacelist, const unsigned char *surfacesides, const vec3_t lightmins, const vec3_t lightmaxs)
{
dp_model_t *model = ent->model;
- const msurface_t *surface, *batch[1024];
- int modelsurfacelistindex, batchsize;
+ const msurface_t *surface;
+ int modelsurfacelistindex, batchnumsurfaces;
// check the box in modelspace, it was already checked in worldspace
if (!BoxesOverlap(model->normalmins, model->normalmaxs, lightmins, lightmaxs))
return;
continue;
r_refdef.stats.lights_dynamicshadowtriangles += surface->num_triangles;
r_refdef.stats.lights_shadowtriangles += surface->num_triangles;
- batch[0] = surface;
- batchsize = 1;
- while(++modelsurfacelistindex < modelnumsurfaces && batchsize < (int)(sizeof(batch)/sizeof(batch[0])))
+ batchsurfacelist[0] = surface;
+ batchnumsurfaces = 1;
+ while(++modelsurfacelistindex < modelnumsurfaces && batchnumsurfaces < RSURF_MAX_BATCHSURFACES)
{
surface = model->data_surfaces + modelsurfacelist[modelsurfacelistindex];
if (surfacesides && !(surfacesides[modelsurfacelistindex] & (1 << side)))
continue;
- if (surface->texture != batch[0]->texture)
+ if (surface->texture != batchsurfacelist[0]->texture)
break;
if (!BoxesOverlap(lightmins, lightmaxs, surface->mins, surface->maxs))
continue;
r_refdef.stats.lights_dynamicshadowtriangles += surface->num_triangles;
r_refdef.stats.lights_shadowtriangles += surface->num_triangles;
- batch[batchsize++] = surface;
+ batchsurfacelist[batchnumsurfaces++] = surface;
}
--modelsurfacelistindex;
GL_CullFace(rsurface.texture->currentmaterialflags & MATERIALFLAG_NOCULLFACE ? GL_NONE : r_refdef.view.cullface_back);
- RSurf_PrepareVerticesForBatch(false, false, batchsize, batch);
- RSurf_DrawBatch_Simple(batchsize, batch);
- GL_LockArrays(0, 0);
+ RSurf_PrepareVerticesForBatch(false, false, batchnumsurfaces, batchsurfacelist);
+ RSurf_DrawBatch_Simple(batchnumsurfaces, batchsurfacelist);
}
}
R_Shadow_RenderMode_End();
}
-#define RSURF_MAX_BATCHSURFACES 8192
-
extern qboolean r_shadow_usingdeferredprepass;
void R_Q1BSP_DrawLight(entity_render_t *ent, int numsurfaces, const int *surfacelist, const unsigned char *lighttrispvs)
{
dp_model_t *model = ent->model;
const msurface_t *surface;
int i, k, kend, l, m, mend, endsurface, batchnumsurfaces, batchnumtriangles, batchfirstvertex, batchlastvertex, batchfirsttriangle;
- qboolean usebufferobject;
const int *element3i;
- static msurface_t *batchsurfacelist[RSURF_MAX_BATCHSURFACES];
static int batchelements[BATCHSIZE*3];
texture_t *tex;
CHECKGLERROR
RSurf_PrepareVerticesForBatch(true, true, 1, &surface);
for (m = surface->num_firsttriangle, mend = m + surface->num_triangles;m < mend;m++)
{
- if (lighttrispvs && r_test.integer)
- {
- if (!CHECKPVSBIT(lighttrispvs, m))
- {
- usebufferobject = false;
- continue;
- }
- }
+ if (lighttrispvs && r_test.integer && !CHECKPVSBIT(lighttrispvs, m))
+ continue;
if (batchnumtriangles >= BATCHSIZE)
{
r_refdef.stats.lights_lighttriangles += batchnumtriangles;
R_Shadow_RenderLighting(batchfirstvertex, batchlastvertex + 1 - batchfirstvertex, batchfirsttriangle, batchnumtriangles, ent->model->surfmesh.data_element3i, ent->model->surfmesh.data_element3s, ent->model->surfmesh.ebo3i, ent->model->surfmesh.ebo3s);
else
R_Shadow_RenderLighting(batchfirstvertex, batchlastvertex + 1 - batchfirstvertex, 0, batchnumtriangles, batchelements, NULL, 0, 0);
- usebufferobject = true;
batchnumtriangles = 0;
batchfirsttriangle = m;
}