Add the ability to query texture sizes and specification.

Also added mipmap level checking.
Add a utility function to calculate the maximal number of mipmap levels.