From: havoc Date: Sun, 16 Oct 2011 13:50:53 +0000 (+0000) Subject: if vid_samples is > 1 then do not use fbo view or water renders X-Git-Tag: xonotic-v0.6.0~163^2~127 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=0e0847b55300c06ea49db519a78cb8a27528ea8a;p=xonotic%2Fdarkplaces.git if vid_samples is > 1 then do not use fbo view or water renders git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@11430 d7cf8633-e32d-0410-b094-e92efae38249 --- diff --git a/gl_rmain.c b/gl_rmain.c index fc01940a..c38f2ee5 100644 --- a/gl_rmain.c +++ b/gl_rmain.c @@ -5526,6 +5526,7 @@ static void R_Water_StartFrame(void) int i; int waterwidth, waterheight, texturewidth, textureheight, camerawidth, cameraheight; r_waterstate_waterplane_t *p; + qboolean usewaterfbo = (r_viewfbo.integer >= 1 || r_water_fbo.integer >= 1) && vid.support.ext_framebuffer_object && vid.samples < 2; if (vid.width > (int)vid.maxtexturesize_2d || vid.height > (int)vid.maxtexturesize_2d) return; @@ -5569,7 +5570,7 @@ static void R_Water_StartFrame(void) } // allocate textures as needed - if (r_fb.water.texturewidth != texturewidth || r_fb.water.textureheight != textureheight || r_fb.water.camerawidth != camerawidth || r_fb.water.cameraheight != cameraheight) + if (r_fb.water.texturewidth != texturewidth || r_fb.water.textureheight != textureheight || r_fb.water.camerawidth != camerawidth || r_fb.water.cameraheight != cameraheight || (r_fb.depthtexture && !usewaterfbo)) { r_fb.water.maxwaterplanes = MAX_WATERPLANES; for (i = 0, p = r_fb.water.waterplanes;i < r_fb.water.maxwaterplanes;i++, p++) @@ -5739,6 +5740,7 @@ static void R_Water_ProcessPlanes(int fbo, rtexture_t *depthtexture, rtexture_t int planeindex, qualityreduction = 0, old_r_dynamic = 0, old_r_shadows = 0, old_r_worldrtlight = 0, old_r_dlight = 0, old_r_particles = 0, old_r_decals = 0; r_waterstate_waterplane_t *p; vec3_t visorigin; + qboolean usewaterfbo = (r_viewfbo.integer >= 1 || r_water_fbo.integer >= 1) && vid.support.ext_framebuffer_object && vid.samples < 2; originalview = r_refdef.view; @@ -5775,7 +5777,7 @@ static void R_Water_ProcessPlanes(int fbo, rtexture_t *depthtexture, rtexture_t p->texture_refraction = R_LoadTexture2D(r_main_texturepool, va("waterplane%i_refraction", planeindex), r_fb.water.texturewidth, r_fb.water.textureheight, NULL, r_fb.textype, TEXF_RENDERTARGET | TEXF_FORCELINEAR | TEXF_CLAMP, -1, NULL); if (!p->texture_refraction) goto error; - if (r_water_fbo.integer >= 1 && vid.support.ext_framebuffer_object) + if (usewaterfbo) { if (r_fb.water.depthtexture == NULL) r_fb.water.depthtexture = R_LoadTextureShadowMap2D(r_main_texturepool, "waterviewdepth", r_fb.water.texturewidth, r_fb.water.textureheight, 24, false); @@ -5789,7 +5791,7 @@ static void R_Water_ProcessPlanes(int fbo, rtexture_t *depthtexture, rtexture_t p->texture_camera = R_LoadTexture2D(r_main_texturepool, va("waterplane%i_camera", planeindex), r_fb.water.camerawidth, r_fb.water.cameraheight, NULL, r_fb.textype, TEXF_RENDERTARGET | TEXF_FORCELINEAR, -1, NULL); if (!p->texture_camera) goto error; - if (r_water_fbo.integer >= 1 && vid.support.ext_framebuffer_object) + if (usewaterfbo) { if (r_fb.water.depthtexture == NULL) r_fb.water.depthtexture = R_LoadTextureShadowMap2D(r_main_texturepool, "waterviewdepth", r_fb.water.texturewidth, r_fb.water.textureheight, 24, false); @@ -5804,7 +5806,7 @@ static void R_Water_ProcessPlanes(int fbo, rtexture_t *depthtexture, rtexture_t p->texture_reflection = R_LoadTexture2D(r_main_texturepool, va("waterplane%i_reflection", planeindex), r_fb.water.texturewidth, r_fb.water.textureheight, NULL, r_fb.textype, TEXF_RENDERTARGET | TEXF_FORCELINEAR | TEXF_CLAMP, -1, NULL); if (!p->texture_reflection) goto error; - if (r_water_fbo.integer >= 1 && vid.support.ext_framebuffer_object) + if (usewaterfbo) { if (r_fb.water.depthtexture == NULL) r_fb.water.depthtexture = R_LoadTextureShadowMap2D(r_main_texturepool, "waterviewdepth", r_fb.water.texturewidth, r_fb.water.textureheight, 24, false); @@ -6005,16 +6007,17 @@ void R_Bloom_StartFrame(void) int i; int bloomtexturewidth, bloomtextureheight, screentexturewidth, screentextureheight; int viewwidth, viewheight; + qboolean useviewfbo = r_viewfbo.integer >= 1 && vid.support.ext_framebuffer_object && vid.samples < 2; + textype_t textype = TEXTYPE_COLORBUFFER; - r_fb.textype = TEXTYPE_COLORBUFFER; switch (vid.renderpath) { case RENDERPATH_GL20: case RENDERPATH_GLES2: if (vid.support.ext_framebuffer_object) { - if (r_viewfbo.integer == 2) r_fb.textype = TEXTYPE_COLORBUFFER16F; - if (r_viewfbo.integer == 3) r_fb.textype = TEXTYPE_COLORBUFFER32F; + if (r_viewfbo.integer == 2) textype = TEXTYPE_COLORBUFFER16F; + if (r_viewfbo.integer == 3) textype = TEXTYPE_COLORBUFFER32F; } break; case RENDERPATH_GL11: @@ -6092,7 +6095,12 @@ void R_Bloom_StartFrame(void) Cvar_SetValueQuick(&r_damageblur, 0); } - if (!(r_glsl_postprocess.integer || (!R_Stereo_ColorMasking() && r_glsl_saturation.value != 1) || (v_glslgamma.integer && !vid_gammatables_trivial)) && !r_bloom.integer && (R_Stereo_Active() || (r_motionblur.value <= 0 && r_damageblur.value <= 0)) && r_viewfbo.integer < 1 && r_viewscale.value == 1.0f && !r_viewscale_fpsscaling.integer) + if (!(r_glsl_postprocess.integer || (!R_Stereo_ColorMasking() && r_glsl_saturation.value != 1) || (v_glslgamma.integer && !vid_gammatables_trivial)) + && !r_bloom.integer + && (R_Stereo_Active() || (r_motionblur.value <= 0 && r_damageblur.value <= 0)) + && !useviewfbo + && r_viewscale.value == 1.0f + && !r_viewscale_fpsscaling.integer) screentexturewidth = screentextureheight = 0; if (!r_bloom.integer) bloomtexturewidth = bloomtextureheight = 0; @@ -6102,7 +6110,8 @@ void R_Bloom_StartFrame(void) || r_fb.screentextureheight != screentextureheight || r_fb.bloomtexturewidth != bloomtexturewidth || r_fb.bloomtextureheight != bloomtextureheight - || r_fb.viewfbo != r_viewfbo.integer) + || r_fb.textype != textype + || useviewfbo != (r_fb.fbo != 0)) { for (i = 0;i < (int)(sizeof(r_fb.bloomtexture)/sizeof(r_fb.bloomtexture[i]));i++) { @@ -6135,7 +6144,7 @@ void R_Bloom_StartFrame(void) r_fb.screentextureheight = screentextureheight; r_fb.bloomtexturewidth = bloomtexturewidth; r_fb.bloomtextureheight = bloomtextureheight; - r_fb.viewfbo = r_viewfbo.integer; + r_fb.textype = textype; if (r_fb.screentexturewidth && r_fb.screentextureheight) { @@ -6143,7 +6152,7 @@ void R_Bloom_StartFrame(void) r_fb.ghosttexture = R_LoadTexture2D(r_main_texturepool, "framebuffermotionblur", r_fb.screentexturewidth, r_fb.screentextureheight, NULL, r_fb.textype, TEXF_RENDERTARGET | TEXF_FORCELINEAR | TEXF_CLAMP, -1, NULL); r_fb.ghosttexture_valid = false; r_fb.colortexture = R_LoadTexture2D(r_main_texturepool, "framebuffercolor", r_fb.screentexturewidth, r_fb.screentextureheight, NULL, r_fb.textype, TEXF_RENDERTARGET | TEXF_FORCELINEAR | TEXF_CLAMP, -1, NULL); - if (r_viewfbo.integer >= 1 && vid.support.ext_framebuffer_object) + if (useviewfbo) { // FIXME: choose depth bits based on a cvar r_fb.depthtexture = R_LoadTextureShadowMap2D(r_main_texturepool, "framebufferdepth", r_fb.screentexturewidth, r_fb.screentextureheight, 24, false); @@ -6169,7 +6178,7 @@ void R_Bloom_StartFrame(void) for (i = 0;i < (int)(sizeof(r_fb.bloomtexture)/sizeof(r_fb.bloomtexture[i]));i++) { r_fb.bloomtexture[i] = R_LoadTexture2D(r_main_texturepool, "framebufferbloom", r_fb.bloomtexturewidth, r_fb.bloomtextureheight, NULL, r_fb.textype, TEXF_RENDERTARGET | TEXF_FORCELINEAR | TEXF_CLAMP, -1, NULL); - if (r_viewfbo.integer >= 1 && vid.support.ext_framebuffer_object) + if (useviewfbo) r_fb.bloomfbo[i] = R_Mesh_CreateFramebufferObject(NULL, r_fb.bloomtexture[i], NULL, NULL, NULL); } } diff --git a/render.h b/render.h index 6df54b1c..46c0c658 100644 --- a/render.h +++ b/render.h @@ -466,11 +466,6 @@ r_waterstate_waterplane_t; typedef struct r_waterstate_s { - qboolean enabled; - - qboolean renderingscene; // true while rendering a refraction or reflection texture, disables water surfaces - qboolean hideplayer; - int waterwidth, waterheight; int texturewidth, textureheight; int camerawidth, cameraheight; @@ -482,13 +477,16 @@ typedef struct r_waterstate_s float screenscale[2]; float screencenter[2]; + + qboolean enabled; + + qboolean renderingscene; // true while rendering a refraction or reflection texture, disables water surfaces + qboolean hideplayer; } r_waterstate_t; typedef struct r_framebufferstate_s { - int viewfbo; // copy of r_viewfbo cvar (to cause reallocation of textures if needed) - textype_t textype; // type of color buffer we're using (dependent on r_viewfbo cvar) int fbo; // non-zero if r_viewfbo is enabled and working int screentexturewidth, screentextureheight; // dimensions of texture diff --git a/vid_shared.c b/vid_shared.c index 1e1d4ae1..925ef592 100644 --- a/vid_shared.c +++ b/vid_shared.c @@ -1126,15 +1126,7 @@ void VID_CheckExtensions(void) int samples = 0; qglGetIntegerv(GL_SAMPLES_ARB, &samples); if (samples > 1) - { qglEnable(GL_MULTISAMPLE_ARB); - - // currently, multisampling is not supported by our FBO paths - // so for now, disable FBOs if multisample is requested - // FIXME instead, support FBOs + multisampling, and turn off - // multisampling on chipsets that don't support this combination - vid.support.ext_framebuffer_object = false; - } else vid.allowalphatocoverage = false; }