Rather than creating and destroying the occlusion buffer every frame, cache it.
This improves performance slightly.
From: Alex Goins <agoins@nvidia.com>
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@12095
d7cf8633-e32d-0410-b094-
e92efae38249
vec3_t currentcolor;
/// used by corona updates, due to occlusion query
float corona_visibility;
vec3_t currentcolor;
/// used by corona updates, due to occlusion query
float corona_visibility;
- unsigned int occlusion_buf;
unsigned int corona_queryindex_visiblepixels;
unsigned int corona_queryindex_allpixels;
/// this is R_GetCubemap(rtlight->cubemapname)
unsigned int corona_queryindex_visiblepixels;
unsigned int corona_queryindex_allpixels;
/// this is R_GetCubemap(rtlight->cubemapname)
// lights are reloaded when this changes
char r_shadow_mapname[MAX_QPATH];
// lights are reloaded when this changes
char r_shadow_mapname[MAX_QPATH];
+// buffer for doing corona fading
+unsigned int r_shadow_occlusion_buf = 0;
+
// used only for light filters (cubemaps)
rtexturepool_t *r_shadow_filters_texturepool;
// used only for light filters (cubemaps)
rtexturepool_t *r_shadow_filters_texturepool;
rtlight->cached_numshadowentities = 0;
rtlight->cached_numshadowentities_noselfshadow = 0;
rtlight->cached_numsurfaces = 0;
rtlight->cached_numshadowentities = 0;
rtlight->cached_numshadowentities_noselfshadow = 0;
rtlight->cached_numsurfaces = 0;
- rtlight->occlusion_buf = 0;
rtlight->cached_lightentities = NULL;
rtlight->cached_lightentities_noselfshadow = NULL;
rtlight->cached_shadowentities = NULL;
rtlight->cached_lightentities = NULL;
rtlight->cached_lightentities_noselfshadow = NULL;
rtlight->cached_shadowentities = NULL;
// See if we can use the GPU-side method to prevent implicit sync
if (vid.support.arb_query_buffer_object) {
#define BUFFER_OFFSET(i) ((void*)NULL + (i))
// See if we can use the GPU-side method to prevent implicit sync
if (vid.support.arb_query_buffer_object) {
#define BUFFER_OFFSET(i) ((void*)NULL + (i))
- qglGenBuffersARB(1, &rtlight->occlusion_buf);
- qglBindBufferARB(GL_QUERY_BUFFER_ARB, rtlight->occlusion_buf);
- qglBufferDataARB(GL_QUERY_BUFFER_ARB, 8, NULL, GL_DYNAMIC_COPY);
+ if (!r_shadow_occlusion_buf) {
+ qglGenBuffersARB(1, &r_shadow_occlusion_buf);
+ qglBindBufferARB(GL_QUERY_BUFFER_ARB, r_shadow_occlusion_buf);
+ qglBufferDataARB(GL_QUERY_BUFFER_ARB, 8, NULL, GL_DYNAMIC_COPY);
+ } else {
+ qglBindBufferARB(GL_QUERY_BUFFER_ARB, r_shadow_occlusion_buf);
+ }
qglGetQueryObjectivARB(rtlight->corona_queryindex_visiblepixels, GL_QUERY_RESULT_ARB, BUFFER_OFFSET(0));
qglGetQueryObjectivARB(rtlight->corona_queryindex_allpixels, GL_QUERY_RESULT_ARB, BUFFER_OFFSET(4));
qglGetQueryObjectivARB(rtlight->corona_queryindex_visiblepixels, GL_QUERY_RESULT_ARB, BUFFER_OFFSET(0));
qglGetQueryObjectivARB(rtlight->corona_queryindex_allpixels, GL_QUERY_RESULT_ARB, BUFFER_OFFSET(4));
- qglBindBufferBase(GL_UNIFORM_BUFFER, 0, rtlight->occlusion_buf);
+ qglBindBufferBase(GL_UNIFORM_BUFFER, 0, r_shadow_occlusion_buf);
occlude = MATERIALFLAG_OCCLUDE;
} else {
qglGetQueryObjectivARB(rtlight->corona_queryindex_visiblepixels, GL_QUERY_RESULT_ARB, &visiblepixels);
occlude = MATERIALFLAG_OCCLUDE;
} else {
qglGetQueryObjectivARB(rtlight->corona_queryindex_visiblepixels, GL_QUERY_RESULT_ARB, &visiblepixels);
if(negated)
GL_BlendEquationSubtract(false);
}
if(negated)
GL_BlendEquationSubtract(false);
}
- if (rtlight->occlusion_buf) {
- qglDeleteBuffersARB(1, &rtlight->occlusion_buf);
- }
}
void R_Shadow_DrawCoronas(void)
}
void R_Shadow_DrawCoronas(void)