[iortcw] 35/152: All: Rend2: Fix some GL errors and no sun shadows on older OpenGLs

Simon McVittie smcv at debian.org
Fri Sep 8 10:39:54 UTC 2017


This is an automated email from the git hooks/post-receive script.

smcv pushed a commit to annotated tag 1.5a
in repository iortcw.

commit a7e00c9fdddaf7b0beec9876219b3dc1697d4e91
Author: MAN-AT-ARMS <M4N4T4RMS at gmail.com>
Date:   Fri Feb 19 17:30:44 2016 -0500

    All: Rend2: Fix some GL errors and no sun shadows on older OpenGLs
---
 MP/code/rend2/tr_dsa.c   | 2 +-
 MP/code/rend2/tr_fbo.c   | 8 ++++++--
 MP/code/rend2/tr_image.c | 4 +---
 SP/code/rend2/tr_dsa.c   | 2 +-
 SP/code/rend2/tr_fbo.c   | 8 ++++++--
 SP/code/rend2/tr_image.c | 4 +---
 6 files changed, 16 insertions(+), 12 deletions(-)

diff --git a/MP/code/rend2/tr_dsa.c b/MP/code/rend2/tr_dsa.c
index a766263..9cd481b 100644
--- a/MP/code/rend2/tr_dsa.c
+++ b/MP/code/rend2/tr_dsa.c
@@ -210,7 +210,7 @@ void GL_BindNullFramebuffers()
 	qglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
 	glDsaState.drawFramebuffer = glDsaState.readFramebuffer = 0;
 	qglBindRenderbufferEXT(GL_RENDERBUFFER_EXT, 0);
-	glDsaState.readFramebuffer = 0;
+	glDsaState.renderbuffer = 0;
 }
 
 void GL_BindFramebuffer(GLenum target, GLuint framebuffer)
diff --git a/MP/code/rend2/tr_fbo.c b/MP/code/rend2/tr_fbo.c
index 59b1703..1229376 100644
--- a/MP/code/rend2/tr_fbo.c
+++ b/MP/code/rend2/tr_fbo.c
@@ -251,7 +251,7 @@ FBO_Init
 void FBO_Init(void)
 {
 	int             i;
-	int             hdrFormat, multisample;
+	int             hdrFormat, multisample = 0;
 
 	ri.Printf(PRINT_ALL, "------- FBO_Init -------\n");
 
@@ -268,7 +268,8 @@ void FBO_Init(void)
 	if (r_hdr->integer && glRefConfig.framebufferObject && glRefConfig.textureFloat)
 		hdrFormat = GL_RGBA16F_ARB;
 
-	qglGetIntegerv(GL_MAX_SAMPLES_EXT, &multisample);
+	if (glRefConfig.framebufferMultisample)
+		qglGetIntegerv(GL_MAX_SAMPLES_EXT, &multisample);
 
 	if (r_ext_framebuffer_multisample->integer < multisample)
 		multisample = r_ext_framebuffer_multisample->integer;
@@ -334,6 +335,9 @@ void FBO_Init(void)
 		for ( i = 0; i < 4; i++)
 		{
 			tr.sunShadowFbo[i] = FBO_Create("_sunshadowmap", tr.sunShadowDepthImage[i]->width, tr.sunShadowDepthImage[i]->height);
+			// FIXME: this next line wastes 16mb with 4x1024x1024 sun shadow maps, skip if OpenGL 4.3+ or ARB_framebuffer_no_attachments
+			// This at least gets sun shadows working on older GPUs (Intel)
+			FBO_CreateBuffer(tr.sunShadowFbo[i], GL_RGBA8, 0, 0);
 			FBO_AttachImage(tr.sunShadowFbo[i], tr.sunShadowDepthImage[i], GL_DEPTH_ATTACHMENT_EXT, 0);
 			R_CheckFBO(tr.sunShadowFbo[i]);
 		}
diff --git a/MP/code/rend2/tr_image.c b/MP/code/rend2/tr_image.c
index 65cde8e..d6c1b80 100644
--- a/MP/code/rend2/tr_image.c
+++ b/MP/code/rend2/tr_image.c
@@ -132,7 +132,7 @@ void GL_TextureMode( const char *string ) {
 	// change all the existing mipmap texture objects
 	for ( i = 0 ; i < tr.numImages ; i++ ) {
 		glt = tr.images[ i ];
-		if ( glt->flags & IMGFLAG_MIPMAP ) {
+		if ( glt->flags & IMGFLAG_MIPMAP && !(glt->flags & IMGFLAG_CUBEMAP) ) {
 			qglTextureParameterf(glt->texnum, GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gl_filter_min);
 			qglTextureParameterf(glt->texnum, GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gl_filter_max);
 		}
@@ -2990,8 +2990,6 @@ void R_CreateBuiltinImages( void ) {
 			for ( x = 0; x < 4; x++)
 			{
 				tr.sunShadowDepthImage[x] = R_CreateImage(va("*sunshadowdepth%i", x), NULL, r_shadowMapSize->integer, r_shadowMapSize->integer, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, GL_DEPTH_COMPONENT24_ARB);
-				qglTextureParameterf(tr.sunShadowDepthImage[x]->texnum, GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
-				qglTextureParameterf(tr.sunShadowDepthImage[x]->texnum, GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
 				qglTextureParameterf(tr.sunShadowDepthImage[x]->texnum, GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_R_TO_TEXTURE);
 				qglTextureParameterf(tr.sunShadowDepthImage[x]->texnum, GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL);
 			}
diff --git a/SP/code/rend2/tr_dsa.c b/SP/code/rend2/tr_dsa.c
index a766263..9cd481b 100644
--- a/SP/code/rend2/tr_dsa.c
+++ b/SP/code/rend2/tr_dsa.c
@@ -210,7 +210,7 @@ void GL_BindNullFramebuffers()
 	qglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
 	glDsaState.drawFramebuffer = glDsaState.readFramebuffer = 0;
 	qglBindRenderbufferEXT(GL_RENDERBUFFER_EXT, 0);
-	glDsaState.readFramebuffer = 0;
+	glDsaState.renderbuffer = 0;
 }
 
 void GL_BindFramebuffer(GLenum target, GLuint framebuffer)
diff --git a/SP/code/rend2/tr_fbo.c b/SP/code/rend2/tr_fbo.c
index 59b1703..1229376 100644
--- a/SP/code/rend2/tr_fbo.c
+++ b/SP/code/rend2/tr_fbo.c
@@ -251,7 +251,7 @@ FBO_Init
 void FBO_Init(void)
 {
 	int             i;
-	int             hdrFormat, multisample;
+	int             hdrFormat, multisample = 0;
 
 	ri.Printf(PRINT_ALL, "------- FBO_Init -------\n");
 
@@ -268,7 +268,8 @@ void FBO_Init(void)
 	if (r_hdr->integer && glRefConfig.framebufferObject && glRefConfig.textureFloat)
 		hdrFormat = GL_RGBA16F_ARB;
 
-	qglGetIntegerv(GL_MAX_SAMPLES_EXT, &multisample);
+	if (glRefConfig.framebufferMultisample)
+		qglGetIntegerv(GL_MAX_SAMPLES_EXT, &multisample);
 
 	if (r_ext_framebuffer_multisample->integer < multisample)
 		multisample = r_ext_framebuffer_multisample->integer;
@@ -334,6 +335,9 @@ void FBO_Init(void)
 		for ( i = 0; i < 4; i++)
 		{
 			tr.sunShadowFbo[i] = FBO_Create("_sunshadowmap", tr.sunShadowDepthImage[i]->width, tr.sunShadowDepthImage[i]->height);
+			// FIXME: this next line wastes 16mb with 4x1024x1024 sun shadow maps, skip if OpenGL 4.3+ or ARB_framebuffer_no_attachments
+			// This at least gets sun shadows working on older GPUs (Intel)
+			FBO_CreateBuffer(tr.sunShadowFbo[i], GL_RGBA8, 0, 0);
 			FBO_AttachImage(tr.sunShadowFbo[i], tr.sunShadowDepthImage[i], GL_DEPTH_ATTACHMENT_EXT, 0);
 			R_CheckFBO(tr.sunShadowFbo[i]);
 		}
diff --git a/SP/code/rend2/tr_image.c b/SP/code/rend2/tr_image.c
index 12dc5ea..f2eaaab 100644
--- a/SP/code/rend2/tr_image.c
+++ b/SP/code/rend2/tr_image.c
@@ -133,7 +133,7 @@ void GL_TextureMode( const char *string ) {
 	// change all the existing mipmap texture objects
 	for ( i = 0 ; i < tr.numImages ; i++ ) {
 		glt = tr.images[ i ];
-		if ( glt->flags & IMGFLAG_MIPMAP ) {
+		if ( glt->flags & IMGFLAG_MIPMAP && !(glt->flags & IMGFLAG_CUBEMAP) ) {
 			qglTextureParameterf(glt->texnum, GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gl_filter_min);
 			qglTextureParameterf(glt->texnum, GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gl_filter_max);
 		}
@@ -2999,8 +2999,6 @@ void R_CreateBuiltinImages( void ) {
 			for ( x = 0; x < 4; x++)
 			{
 				tr.sunShadowDepthImage[x] = R_CreateImage(va("*sunshadowdepth%i", x), NULL, r_shadowMapSize->integer, r_shadowMapSize->integer, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, GL_DEPTH_COMPONENT24_ARB);
-				qglTextureParameterf(tr.sunShadowDepthImage[x]->texnum, GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
-				qglTextureParameterf(tr.sunShadowDepthImage[x]->texnum, GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
 				qglTextureParameterf(tr.sunShadowDepthImage[x]->texnum, GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_R_TO_TEXTURE);
 				qglTextureParameterf(tr.sunShadowDepthImage[x]->texnum, GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL);
 			}

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/iortcw.git



More information about the Pkg-games-commits mailing list