From 9fc8c667d45245fc038b317d18c9f7a39c640d85 Mon Sep 17 00:00:00 2001 From: "havoc havoc@d7cf8633-e32d-0410-b094-e92efae38249" <> Date: Thu, 16 Sep 2010 09:14:39 +0000 Subject: [PATCH] UNMERGE 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 | 77 +++++++++++++++++++++++++++++---------------------- 1 file changed, 44 insertions(+), 33 deletions(-) diff --git a/gl_textures.c b/gl_textures.c index c6f1f553..0d8c0feb 100644 --- a/gl_textures.c +++ b/gl_textures.c @@ -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; } -- 2.39.2