{
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:
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;
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;
}