]> git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
raised MAX_TEXTUREUNITS from 16 to 64
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Fri, 22 Dec 2006 13:05:38 +0000 (13:05 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Fri, 22 Dec 2006 13:05:38 +0000 (13:05 +0000)
fixed bug with backendimageunits/backendarrayunits not being limited to MAX_TEXTUREUNITS (caused memory corruption on NVIDIA GeForce 8 series which have 32 texture image units), backendunits was already limited properly

git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@6663 d7cf8633-e32d-0410-b094-e92efae38249

gl_backend.c
gl_backend.h

index 5770fb455e5e3517c2d5303befb1348f78aa496e..286b5452f87b03788db5f949fe03264d7365903d 100644 (file)
@@ -157,7 +157,7 @@ static void gl_backend_start(void)
                Con_Printf("glDrawRangeElements detected (max vertices %i, max indices %i)\n", gl_maxdrawrangeelementsvertices, gl_maxdrawrangeelementsindices);
        }
 
-       backendunits = min(MAX_TEXTUREUNITS, gl_textureunits);
+       backendunits = bound(1, gl_textureunits, MAX_TEXTUREUNITS);
        backendimageunits = backendunits;
        backendarrayunits = backendunits;
        if (gl_support_fragment_shader)
@@ -168,6 +168,8 @@ static void gl_backend_start(void)
                qglGetIntegerv(GL_MAX_TEXTURE_COORDS_ARB, (int *)&backendarrayunits);
                CHECKGLERROR
                Con_Printf("GLSL shader support detected: texture units = %i texenv, %i image, %i array\n", backendunits, backendimageunits, backendarrayunits);
+               backendimageunits = bound(1, backendimageunits, MAX_TEXTUREUNITS);
+               backendarrayunits = bound(1, backendarrayunits, MAX_TEXTUREUNITS);
        }
        else if (backendunits > 1)
                Con_Printf("multitexture detected: texture units = %i\n", backendunits);
index 0c66d2f1b3ba11216e55517ddaa7b2626ef65f94..6dd8d0ae531016fea5cc8afeb020f630e9aac734 100644 (file)
@@ -2,7 +2,8 @@
 #ifndef GL_BACKEND_H
 #define GL_BACKEND_H
 
-#define MAX_TEXTUREUNITS 16
+// how many texture units to track state on (backendunits/backendimageunits/backendarrayunits are limited to this value)
+#define MAX_TEXTUREUNITS 64
 
 #define POLYGONELEMENTS_MAXPOINTS 258
 extern int polygonelements[(POLYGONELEMENTS_MAXPOINTS-2)*3];