X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=r_shadow.c;h=c0ecf32056c314380b30b4803267859309c682a6;hb=refs%2Fheads%2FMario%2Fflag_slide_fix;hp=ff8792db3f8df1a5ed9047bef59715919eaf5a86;hpb=33cefdeb9044350e531ca015aafcb44dc644c178;p=xonotic%2Fdarkplaces.git diff --git a/r_shadow.c b/r_shadow.c index ff8792db..c0ecf320 100644 --- a/r_shadow.c +++ b/r_shadow.c @@ -269,6 +269,9 @@ static rtexture_t *r_shadow_fb_colortexture; // 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; @@ -3527,7 +3530,7 @@ void R_RTLight_Compile(rtlight_t *rtlight) lighttris++; shadowtris = 0; - if (rtlight->static_numlighttrispvsbytes) + if (rtlight->static_numshadowtrispvsbytes) for (i = 0;i < rtlight->static_numshadowtrispvsbytes*8;i++) if (CHECKPVSBIT(rtlight->static_shadowtrispvs, i)) shadowtris++; @@ -3941,7 +3944,6 @@ static void R_Shadow_PrepareLight(rtlight_t *rtlight) 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; @@ -5166,12 +5168,16 @@ static void R_DrawCorona(rtlight_t *rtlight, float cscale, float scale) // 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)); - 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); @@ -5224,9 +5230,6 @@ static void R_DrawCorona(rtlight_t *rtlight, float cscale, float scale) if(negated) GL_BlendEquationSubtract(false); } - if (rtlight->occlusion_buf) { - qglDeleteBuffersARB(1, &rtlight->occlusion_buf); - } } void R_Shadow_DrawCoronas(void)