]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
UNMERGE
authorhavoc havoc@d7cf8633-e32d-0410-b094-e92efae38249 <>
Thu, 16 Sep 2010 09:14:39 +0000 (09:14 +0000)
committerRudolf Polzer <divverent@alientrap.org>
Fri, 24 Sep 2010 20:00:14 +0000 (22:00 +0200)
restructure the previous fix so it actually does something

git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@10464 d7cf8633-e32d-0410-b094-e92efae38249
::stable-branch::unmerge=f3581bd039cdb478dfd0e7bbc48a66bad593ae7a

gl_textures.c

index c6f1f553a2f8234522f3385d0873bf9d31511edc..0d8c0feb5898d1b1e10bb714228bed65b5efe1d6 100644 (file)
@@ -493,6 +493,25 @@ static void GL_Texture_CalcImageSize(int texturetype, int flags, int miplevel, i
 {
        int picmip = 0, maxsize = 0, width2 = 1, height2 = 1, depth2 = 1, miplevels = 1;
 
+       switch(vid.renderpath)
+       {
+       case RENDERPATH_GL11:
+       case RENDERPATH_GL13:
+       case RENDERPATH_GL20:
+       case RENDERPATH_CGGL:
+       case RENDERPATH_D3D10:
+       case RENDERPATH_D3D11:
+               break;
+       case RENDERPATH_D3D9:
+               // for some reason the REF rasterizer (and hence the PIX debugger) does not like small textures...
+               if (indepth == 1)
+               {
+                       width2 = max(width2, 2);
+                       height2 = max(height2, 2);
+               }
+               break;
+       }
+
        switch (texturetype)
        {
        default:
@@ -512,39 +531,38 @@ static void GL_Texture_CalcImageSize(int texturetype, int flags, int miplevel, i
                break;
        }
 
-       if (vid.support.arb_texture_non_power_of_two)
+       if (outwidth)
        {
-               width2 = min(inwidth >> picmip, maxsize);
-               height2 = min(inheight >> picmip, maxsize);
-               depth2 = min(indepth >> picmip, maxsize);
+               if (vid.support.arb_texture_non_power_of_two)
+                       width2 = min(inwidth >> picmip, maxsize);
+               else
+               {
+                       for (width2 = 1;width2 < inwidth;width2 <<= 1);
+                       for (width2 >>= picmip;width2 > maxsize;width2 >>= 1);
+               }
+               *outwidth = max(1, width2);
        }
-       else
+       if (outheight)
        {
-               for (width2 = 1;width2 < inwidth;width2 <<= 1);
-               for (width2 >>= picmip;width2 > maxsize;width2 >>= 1);
-               for (height2 = 1;height2 < inheight;height2 <<= 1);
-               for (height2 >>= picmip;height2 > maxsize;height2 >>= 1);
-               for (depth2 = 1;depth2 < indepth;depth2 <<= 1);
-               for (depth2 >>= picmip;depth2 > maxsize;depth2 >>= 1);
+               if (vid.support.arb_texture_non_power_of_two)
+                       height2 = min(inheight >> picmip, maxsize);
+               else
+               {
+                       for (height2 = 1;height2 < inheight;height2 <<= 1);
+                       for (height2 >>= picmip;height2 > maxsize;height2 >>= 1);
+               }
+               *outheight = max(1, height2);
        }
-
-       switch(vid.renderpath)
+       if (outdepth)
        {
-       case RENDERPATH_GL11:
-       case RENDERPATH_GL13:
-       case RENDERPATH_GL20:
-       case RENDERPATH_CGGL:
-       case RENDERPATH_D3D10:
-       case RENDERPATH_D3D11:
-               break;
-       case RENDERPATH_D3D9:
-               // for some reason the REF rasterizer (and hence the PIX debugger) does not like small textures...
-               if (texturetype == GLTEXTURETYPE_2D)
+               if (vid.support.arb_texture_non_power_of_two)
+                       depth2 = min(indepth >> picmip, maxsize);
+               else
                {
-                       width2 = max(width2, 2);
-                       height2 = max(height2, 2);
+                       for (depth2 = 1;depth2 < indepth;depth2 <<= 1);
+                       for (depth2 >>= picmip;depth2 > maxsize;depth2 >>= 1);
                }
-               break;
+               *outdepth = max(1, depth2);
        }
 
        miplevels = 1;
@@ -554,13 +572,6 @@ static void GL_Texture_CalcImageSize(int texturetype, int flags, int miplevel, i
                while(extent >>= 1)
                        miplevels++;
        }
-
-       if (outwidth)
-               *outwidth = max(1, width2);
-       if (outheight)
-               *outheight = max(1, height2);
-       if (outdepth)
-               *outdepth = max(1, depth2);
        if (outmiplevels)
                *outmiplevels = miplevels;
 }